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
@@ -25,13 +26,15 @@ private struct BasicTests {
25
26
. skipSwiftCISelfHosted(
26
27
" These packages don't use the latest runtime library, which doesn't work with self-hosted builds. "
27
28
) ,
28
- . requireUnrestrictedNetworkAccess( " Test requires access to https://github.com " )
29
+ . requireUnrestrictedNetworkAccess( " Test requires access to https://github.com " ) ,
30
+ . skipHostOS( . windows, " Issue #8409 - random.swift:34:8: error: unsupported platform " )
29
31
)
30
32
func testExamplePackageDealer( ) throws {
31
33
try withTemporaryDirectory { tempDir in
32
34
let packagePath = tempDir. appending ( component: " dealer " )
33
- try sh ( " git " , " clone " , " https://github.com/apple/example-package-dealer " , packagePath)
35
+ try sh ( " git \( ProcessInfo . exeSuffix ) " , " clone " , " https://github.com/apple/example-package-dealer " , packagePath)
34
36
let build1Output = try sh ( swiftBuild, " --package-path " , packagePath) . stdout
37
+
35
38
// Check the build log.
36
39
#expect( build1Output. contains ( " Build complete " ) )
37
40
@@ -43,7 +46,7 @@ private struct BasicTests {
43
46
44
47
// Verify that the 'git status' is clean after a build.
45
48
try localFileSystem. changeCurrentWorkingDirectory ( to: packagePath)
46
- let gitOutput = try sh ( " git " , " status " ) . stdout
49
+ let gitOutput = try sh ( " git \( ProcessInfo . exeSuffix ) " , " status " ) . stdout
47
50
#expect( gitOutput. contains ( " nothing to commit, working tree clean " ) )
48
51
49
52
// Verify that another 'swift build' does nothing.
@@ -84,9 +87,9 @@ private struct BasicTests {
84
87
#expect( try #/swiftc.* -module-name tool/# . firstMatch ( in: buildOutput) != nil )
85
88
86
89
// Verify that the tool exists and works.
87
- let toolOutput = try sh ( packagePath. appending ( components: " .build " , " debug " , " tool " ) ) . stdout
88
- #expect ( toolOutput . contains ( " HI " ) )
89
- #expect( toolOutput. contains ( " \n " ) )
90
+ let toolOutput = try sh ( packagePath. appending ( components: " .build " , " debug " , " tool " ) )
91
+ . stdout
92
+ #expect( toolOutput == " HI \( ProcessInfo . EOL ) " )
90
93
}
91
94
}
92
95
@@ -108,7 +111,7 @@ private struct BasicTests {
108
111
109
112
// Check the file runs.
110
113
let helloOutput = try sh ( helloBinaryPath) . stdout
111
- #expect( helloOutput == " hello \n " )
114
+ #expect( helloOutput == " hello \( ProcessInfo . EOL ) " )
112
115
}
113
116
}
114
117
@@ -140,24 +143,26 @@ private struct BasicTests {
140
143
}
141
144
}
142
145
143
- @Test ( . skip ( " FIXME: swift-test invocations are timing out in Xcode and self-hosted CI " ) )
146
+ @Test
144
147
func testSwiftPackageInitExecTests( ) throws {
145
148
try withTemporaryDirectory { tempDir in
146
149
// Create a new package with an executable target.
147
150
let packagePath = tempDir. appending ( component: " Project " )
148
151
try localFileSystem. createDirectory ( packagePath)
149
- try sh ( swiftPackage, " --package-path " , packagePath, " init " , " --type " , " executable " )
150
- let testOutput = try sh ( swiftTest, " --package-path " , packagePath) . stdout
151
-
152
- // Check the test log.
153
- let checker = StringChecker ( string: testOutput)
154
- #expect( checker. check ( . regex( " Compiling .*ProjectTests.* " ) ) )
155
- #expect( checker. check ( " Test Suite 'All tests' passed " ) )
156
- #expect( checker. checkNext ( " Executed 1 test " ) )
157
-
158
- // Check there were no compile errors or warnings.
159
- #expect( testOutput. contains ( " error " ) == false )
160
- #expect( testOutput. contains ( " warning " ) == false )
152
+ withKnownIssue ( " error: no tests found; create a target in the 'Tests' directory " ) {
153
+ try sh ( swiftPackage, " --package-path " , packagePath, " init " , " --type " , " executable " )
154
+ let testOutput = try sh ( swiftTest, " --package-path " , packagePath) . stdout
155
+
156
+ // Check the test log.
157
+ let checker = StringChecker ( string: testOutput)
158
+ #expect( checker. check ( . regex( " Compiling .*ProjectTests.* " ) ) )
159
+ #expect( checker. check ( " Test Suite 'All tests' passed " ) )
160
+ #expect( checker. checkNext ( " Executed 1 test " ) )
161
+
162
+ // Check there were no compile errors or warnings.
163
+ #expect( testOutput. contains ( " error " ) == false )
164
+ #expect( testOutput. contains ( " warning " ) == false )
165
+ }
161
166
}
162
167
}
163
168
@@ -180,7 +185,7 @@ private struct BasicTests {
180
185
}
181
186
}
182
187
183
- @Test ( . skip ( " FIXME: swift-test invocations are timing out in Xcode and self-hosted CI " ) )
188
+ @Test
184
189
func testSwiftPackageLibsTests( ) throws {
185
190
try withTemporaryDirectory { tempDir in
186
191
// Create a new package with an executable target.
@@ -191,9 +196,9 @@ private struct BasicTests {
191
196
192
197
// Check the test log.
193
198
let checker = StringChecker ( string: testOutput)
194
- #expect( checker. check ( . regex ( " Compiling .*ProjectTests.* " ) ) )
195
- #expect( checker. check ( " Test Suite 'All tests' passed " ) )
196
- #expect( checker. checkNext ( " Executed 1 test" ) )
199
+ #expect( checker. check ( . contains ( " Test Suite 'All tests' started " ) ) )
200
+ #expect( checker. check ( . contains ( " Test example() passed after " ) ) )
201
+ #expect( checker. checkNext ( . contains ( " Test run with 1 test passed after " ) ) )
197
202
198
203
// Check there were no compile errors or warnings.
199
204
#expect( testOutput. contains ( " error " ) == false )
@@ -235,17 +240,19 @@ private struct BasicTests {
235
240
236
241
// Check the build.
237
242
let buildOutput = try sh ( swiftBuild, " --package-path " , packagePath, " -v " ) . stdout
238
- #expect( try
239
- #/swiftc.* -module-name special_tool .* '@.*/more spaces/special tool/.build/[^/]+/debug/special_tool.build/sources'/#
240
- . firstMatch ( in: buildOutput) != nil
241
- )
243
+ let expression = ProcessInfo
244
+ . hostOperatingSystem != . windows ?
245
+ #/swiftc.* -module-name special_tool .* '@.*/more spaces/special tool/.build/[^/]+/debug/special_tool.build/sources'/# :
246
+ #/swiftc.* -module-name special_tool .* "@.*\\more spaces\\special tool\\.build\\[^\\]+\\debug\\special_tool.build\\sources"/#
247
+ #expect( try expression. firstMatch ( in: buildOutput) != nil )
242
248
#expect( buildOutput. contains ( " Build complete " ) )
243
249
244
250
// Verify that the tool exists and works.
245
251
let toolOutput = try sh (
246
252
packagePath. appending ( components: " .build " , " debug " , " special tool " )
247
253
) . stdout
248
- #expect( toolOutput == " HI \n " )
254
+
255
+ #expect( toolOutput == " HI \( ProcessInfo . EOL) " )
249
256
}
250
257
}
251
258
@@ -284,11 +291,10 @@ private struct BasicTests {
284
291
#expect( checker. check ( . regex( " Linking .*secho " ) ) )
285
292
#expect( checker. check ( . contains( " Build of product 'secho' complete " ) ) )
286
293
287
- #expect( runOutput == " 1 \" two \" \n " )
294
+ #expect( runOutput == " 1 \" two \" \( ProcessInfo . EOL ) " )
288
295
}
289
296
}
290
297
291
- @Test ( . skip( " FIXME: swift-test invocations are timing out in Xcode and self-hosted CI " ) )
292
298
func testSwiftTest( ) throws {
293
299
try withTemporaryDirectory { tempDir in
294
300
let packagePath = tempDir. appending ( component: " swiftTest " )
@@ -325,7 +331,7 @@ private struct BasicTests {
325
331
}
326
332
}
327
333
328
- @Test ( . skip ( " FIXME: swift-test invocations are timing out in Xcode and self-hosted CI " ) )
334
+ @Test
329
335
func testSwiftTestWithResources( ) throws {
330
336
try withTemporaryDirectory { tempDir in
331
337
let packagePath = tempDir. appending ( component: " swiftTestResources " )
@@ -406,7 +412,7 @@ private struct BasicTests {
406
412
407
413
let testOutput = try sh (
408
414
swiftTest, " --package-path " , packagePath, " --filter " , " MyTests.* "
409
- ) . stderr
415
+ ) . stdout
410
416
411
417
// Check the test log.
412
418
let checker = StringChecker ( string: testOutput)
0 commit comments