8
8
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
9
9
*/
10
10
11
+ import Foundation
11
12
import IntegrationTestSupport
12
13
import Testing
13
14
import TSCBasic
@@ -22,13 +23,15 @@ private struct BasicTests {
22
23
@Test (
23
24
. skipSwiftCISelfHosted(
24
25
" These packages don't use the latest runtime library, which doesn't work with self-hosted builds. "
25
- )
26
+ ) ,
27
+ . skipHostOS( . windows, " random.swift:34:8: error: unsupported platform " )
26
28
)
27
29
func testExamplePackageDealer( ) throws {
28
30
try withTemporaryDirectory { tempDir in
29
31
let packagePath = tempDir. appending ( component: " dealer " )
30
- try sh ( " git " , " clone " , " https://github.com/apple/example-package-dealer " , packagePath)
32
+ try sh ( " git \( ProcessInfo . exeSuffix ) " , " clone " , " https://github.com/apple/example-package-dealer " , packagePath)
31
33
let build1Output = try sh ( swiftBuild, " --package-path " , packagePath) . stdout
34
+
32
35
// Check the build log.
33
36
#expect( build1Output. contains ( " Build complete " ) )
34
37
@@ -40,7 +43,7 @@ private struct BasicTests {
40
43
41
44
// Verify that the 'git status' is clean after a build.
42
45
try localFileSystem. changeCurrentWorkingDirectory ( to: packagePath)
43
- let gitOutput = try sh ( " git " , " status " ) . stdout
46
+ let gitOutput = try sh ( " git \( ProcessInfo . exeSuffix ) " , " status " ) . stdout
44
47
#expect( gitOutput. contains ( " nothing to commit, working tree clean " ) )
45
48
46
49
// Verify that another 'swift build' does nothing.
@@ -83,7 +86,7 @@ private struct BasicTests {
83
86
// Verify that the tool exists and works.
84
87
let toolOutput = try sh ( packagePath. appending ( components: " .build " , " debug " , " tool " ) )
85
88
. stdout
86
- #expect( toolOutput == " HI \n " )
89
+ #expect( toolOutput == " HI \( ProcessInfo . EOL ) " )
87
90
}
88
91
}
89
92
@@ -103,7 +106,7 @@ private struct BasicTests {
103
106
104
107
// Check the file runs.
105
108
let helloOutput = try sh ( helloBinaryPath) . stdout
106
- #expect( helloOutput == " hello \n " )
109
+ #expect( helloOutput == " hello \( ProcessInfo . EOL ) " )
107
110
}
108
111
}
109
112
@@ -133,24 +136,26 @@ private struct BasicTests {
133
136
}
134
137
}
135
138
136
- @Test ( . skip ( " FIXME: swift-test invocations are timing out in Xcode and self-hosted CI " ) )
139
+ @Test
137
140
func testSwiftPackageInitExecTests( ) throws {
138
141
try withTemporaryDirectory { tempDir in
139
142
// Create a new package with an executable target.
140
143
let packagePath = tempDir. appending ( component: " Project " )
141
144
try localFileSystem. createDirectory ( packagePath)
142
- try sh ( swiftPackage, " --package-path " , packagePath, " init " , " --type " , " executable " )
143
- let testOutput = try sh ( swiftTest, " --package-path " , packagePath) . stdout
144
-
145
- // Check the test log.
146
- let checker = StringChecker ( string: testOutput)
147
- #expect( checker. check ( . regex( " Compiling .*ProjectTests.* " ) ) )
148
- #expect( checker. check ( " Test Suite 'All tests' passed " ) )
149
- #expect( checker. checkNext ( " Executed 1 test " ) )
150
-
151
- // Check there were no compile errors or warnings.
152
- #expect( testOutput. contains ( " error " ) == false )
153
- #expect( testOutput. contains ( " warning " ) == false )
145
+ withKnownIssue ( " error: no tests found; create a target in the 'Tests' directory " ) {
146
+ try sh ( swiftPackage, " --package-path " , packagePath, " init " , " --type " , " executable " )
147
+ let testOutput = try sh ( swiftTest, " --package-path " , packagePath) . stdout
148
+
149
+ // Check the test log.
150
+ let checker = StringChecker ( string: testOutput)
151
+ #expect( checker. check ( . regex( " Compiling .*ProjectTests.* " ) ) )
152
+ #expect( checker. check ( " Test Suite 'All tests' passed " ) )
153
+ #expect( checker. checkNext ( " Executed 1 test " ) )
154
+
155
+ // Check there were no compile errors or warnings.
156
+ #expect( testOutput. contains ( " error " ) == false )
157
+ #expect( testOutput. contains ( " warning " ) == false )
158
+ }
154
159
}
155
160
}
156
161
@@ -173,7 +178,7 @@ private struct BasicTests {
173
178
}
174
179
}
175
180
176
- @Test ( . skip ( " FIXME: swift-test invocations are timing out in Xcode and self-hosted CI " ) )
181
+ @Test
177
182
func testSwiftPackageLibsTests( ) throws {
178
183
try withTemporaryDirectory { tempDir in
179
184
// Create a new package with an executable target.
@@ -184,9 +189,9 @@ private struct BasicTests {
184
189
185
190
// Check the test log.
186
191
let checker = StringChecker ( string: testOutput)
187
- #expect( checker. check ( . regex ( " Compiling .*ProjectTests.* " ) ) )
188
- #expect( checker. check ( " Test Suite 'All tests' passed " ) )
189
- #expect( checker. checkNext ( " Executed 1 test" ) )
192
+ #expect( checker. check ( . contains ( " Test Suite 'All tests' started " ) ) )
193
+ #expect( checker. check ( . contains ( " Test example() passed after " ) ) )
194
+ #expect( checker. checkNext ( . contains ( " Test run with 1 test passed after " ) ) )
190
195
191
196
// Check there were no compile errors or warnings.
192
197
#expect( testOutput. contains ( " error " ) == false )
@@ -226,17 +231,19 @@ private struct BasicTests {
226
231
227
232
// Check the build.
228
233
let buildOutput = try sh ( swiftBuild, " --package-path " , packagePath, " -v " ) . stdout
229
- #expect( try
230
- #/swiftc.* -module-name special_tool .* '@.*/more spaces/special tool/.build/[^/]+/debug/special_tool.build/sources'/#
231
- . firstMatch ( in: buildOutput) != nil
232
- )
234
+ let expression = ProcessInfo
235
+ . hostOperatingSystem != . windows ?
236
+ #/swiftc.* -module-name special_tool .* '@.*/more spaces/special tool/.build/[^/]+/debug/special_tool.build/sources'/# :
237
+ #/swiftc.* -module-name special_tool .* "@.*\\more spaces\\special tool\\.build\\[^\\]+\\debug\\special_tool.build\\sources"/#
238
+ #expect( try expression. firstMatch ( in: buildOutput) != nil )
233
239
#expect( buildOutput. contains ( " Build complete " ) )
234
240
235
241
// Verify that the tool exists and works.
236
242
let toolOutput = try sh (
237
243
packagePath. appending ( components: " .build " , " debug " , " special tool " )
238
244
) . stdout
239
- #expect( toolOutput == " HI \n " )
245
+
246
+ #expect( toolOutput == " HI \( ProcessInfo . EOL) " )
240
247
}
241
248
}
242
249
@@ -273,11 +280,10 @@ private struct BasicTests {
273
280
#expect( checker. check ( . regex( " Linking .*secho " ) ) )
274
281
#expect( checker. check ( . contains( " Build of product 'secho' complete " ) ) )
275
282
276
- #expect( runOutput == " 1 \" two \" \n " )
283
+ #expect( runOutput == " 1 \" two \" \( ProcessInfo . EOL ) " )
277
284
}
278
285
}
279
286
280
- @Test ( . skip( " FIXME: swift-test invocations are timing out in Xcode and self-hosted CI " ) )
281
287
func testSwiftTest( ) throws {
282
288
try withTemporaryDirectory { tempDir in
283
289
let packagePath = tempDir. appending ( component: " swiftTest " )
@@ -314,7 +320,7 @@ private struct BasicTests {
314
320
}
315
321
}
316
322
317
- @Test ( . skip ( " FIXME: swift-test invocations are timing out in Xcode and self-hosted CI " ) )
323
+ @Test
318
324
func testSwiftTestWithResources( ) throws {
319
325
try withTemporaryDirectory { tempDir in
320
326
let packagePath = tempDir. appending ( component: " swiftTestResources " )
@@ -395,7 +401,7 @@ private struct BasicTests {
395
401
396
402
let testOutput = try sh (
397
403
swiftTest, " --package-path " , packagePath, " --filter " , " MyTests.* "
398
- ) . stderr
404
+ ) . stdout
399
405
400
406
// Check the test log.
401
407
let checker = StringChecker ( string: testOutput)
0 commit comments