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