@@ -93,7 +93,9 @@ final class BasicTests: XCTestCase {
93
93
}
94
94
95
95
func testSwiftPackageInitExec( ) throws {
96
- try XCTSkipUnless ( swiftcSupportsRenamingMainSymbol ( ) , " skipping because host compiler doesn't support `-entry-point-function-name` " )
96
+ #if swift(<5.5)
97
+ try XCTSkipIf ( true , " skipping because host compiler doesn't support '-entry-point-function-name' " )
98
+ #endif
97
99
98
100
try withTemporaryDirectory { dir in
99
101
// Create a new package with an executable target.
@@ -106,31 +108,73 @@ final class BasicTests: XCTestCase {
106
108
XCTAssertContents ( buildOutput) { checker in
107
109
checker. check ( . regex( " Compiling .*Project.* " ) )
108
110
checker. check ( . regex( " Linking .*Project " ) )
111
+ checker. check ( . contains( " Build complete " ) )
109
112
}
110
113
111
114
// Verify that the tool was built and works.
112
115
let toolOutput = try sh ( projectDir. appending ( components: " .build " , " debug " , " Project " ) ) . stdout
113
- XCTAssertEqual ( toolOutput, " Hello , world!\n " )
116
+ XCTAssertMatch ( toolOutput. lowercased ( ) , . contains ( " hello , world!" ) )
114
117
115
118
// Check there were no compile errors or warnings.
116
119
XCTAssertNoMatch ( buildOutput, . contains( " error " ) )
117
120
XCTAssertNoMatch ( buildOutput, . contains( " warning " ) )
118
121
}
119
122
}
120
123
121
- func testSwiftPackageInitLib( ) throws {
124
+ func testSwiftPackageInitExecTests( ) throws {
125
+ #if swift(<5.5)
126
+ try XCTSkipIf ( true , " skipping because host compiler doesn't support '-entry-point-function-name' " )
127
+ #endif
128
+
122
129
try XCTSkip ( " FIXME: swift-test invocations are timing out in Xcode and self-hosted CI " )
123
130
131
+ try withTemporaryDirectory { dir in
132
+ // Create a new package with an executable target.
133
+ let projectDir = dir. appending ( component: " Project " )
134
+ try localFileSystem. createDirectory ( projectDir)
135
+ try sh ( swiftPackage, " --package-path " , projectDir, " init " , " --type " , " executable " )
136
+ let testOutput = try sh ( swiftTest, " --package-path " , projectDir) . stdout
137
+
138
+ // Check the test log.
139
+ XCTAssertContents ( testOutput) { checker in
140
+ checker. check ( . regex( " Compiling .*ProjectTests.* " ) )
141
+ checker. check ( " Test Suite 'All tests' passed " )
142
+ checker. checkNext ( " Executed 1 test " )
143
+ }
144
+
145
+ // Check there were no compile errors or warnings.
146
+ XCTAssertNoMatch ( testOutput, . contains( " error " ) )
147
+ XCTAssertNoMatch ( testOutput, . contains( " warning " ) )
148
+ }
149
+ }
150
+
151
+ func testSwiftPackageInitLib( ) throws {
124
152
try withTemporaryDirectory { dir in
125
153
// Create a new package with an executable target.
126
154
let projectDir = dir. appending ( component: " Project " )
127
155
try localFileSystem. createDirectory ( projectDir)
128
156
try sh ( swiftPackage, " --package-path " , projectDir, " init " , " --type " , " library " )
129
157
let buildOutput = try sh ( swiftBuild, " --package-path " , projectDir) . stdout
130
- let testOutput = try sh ( swiftTest, " --package-path " , projectDir) . stdout
131
158
132
159
// Check the build log.
133
160
XCTAssertMatch ( buildOutput, . regex( " Compiling .*Project.* " ) )
161
+ XCTAssertMatch ( buildOutput, . contains( " Build complete " ) )
162
+
163
+ // Check there were no compile errors or warnings.
164
+ XCTAssertNoMatch ( buildOutput, . contains( " error " ) )
165
+ XCTAssertNoMatch ( buildOutput, . contains( " warning " ) )
166
+ }
167
+ }
168
+
169
+ func testSwiftPackageLibsTests( ) throws {
170
+ try XCTSkip ( " FIXME: swift-test invocations are timing out in Xcode and self-hosted CI " )
171
+
172
+ try withTemporaryDirectory { dir in
173
+ // Create a new package with an executable target.
174
+ let projectDir = dir. appending ( component: " Project " )
175
+ try localFileSystem. createDirectory ( projectDir)
176
+ try sh ( swiftPackage, " --package-path " , projectDir, " init " , " --type " , " library " )
177
+ let testOutput = try sh ( swiftTest, " --package-path " , projectDir) . stdout
134
178
135
179
// Check the test log.
136
180
XCTAssertContents ( testOutput) { checker in
@@ -140,8 +184,8 @@ final class BasicTests: XCTestCase {
140
184
}
141
185
142
186
// Check there were no compile errors or warnings.
143
- XCTAssertNoMatch ( buildOutput , . contains( " error " ) )
144
- XCTAssertNoMatch ( buildOutput , . contains( " warning " ) )
187
+ XCTAssertNoMatch ( testOutput , . contains( " error " ) )
188
+ XCTAssertNoMatch ( testOutput , . contains( " warning " ) )
145
189
}
146
190
}
147
191
@@ -172,6 +216,7 @@ final class BasicTests: XCTestCase {
172
216
// Check the build.
173
217
let buildOutput = try sh ( swiftBuild, " --package-path " , toolDir, " -v " ) . stdout
174
218
XCTAssertMatch ( buildOutput, . regex( #"swiftc.* -module-name special_tool .* ".*/more spaces/special tool/some file.swift""# ) )
219
+ XCTAssertMatch ( buildOutput, . contains( " Build complete " ) )
175
220
176
221
// Verify that the tool exists and works.
177
222
let toolOutput = try sh ( toolDir. appending ( components: " .build " , " debug " , " special tool " ) ) . stdout
@@ -180,12 +225,18 @@ final class BasicTests: XCTestCase {
180
225
}
181
226
182
227
func testSwiftRun( ) throws {
183
- try XCTSkipUnless ( swiftcSupportsRenamingMainSymbol ( ) , " skipping because host compiler doesn't support `-entry-point-function-name` " )
228
+ #if swift(<5.5)
229
+ try XCTSkipIf ( true , " skipping because host compiler doesn't support '-entry-point-function-name' " )
230
+ #endif
184
231
185
232
try withTemporaryDirectory { dir in
186
233
let toolDir = dir. appending ( component: " secho " )
187
234
try localFileSystem. createDirectory ( toolDir)
188
235
try sh ( swiftPackage, " --package-path " , toolDir, " init " , " --type " , " executable " )
236
+ // delete any files generated
237
+ for entry in try localFileSystem. getDirectoryContents ( toolDir. appending ( components: " Sources " , " secho " ) ) {
238
+ try localFileSystem. removeFileTree ( toolDir. appending ( components: " Sources " , " secho " , entry) )
239
+ }
189
240
try localFileSystem. writeFileContents (
190
241
toolDir. appending ( components: " Sources " , " secho " , " main.swift " ) ,
191
242
bytes: ByteString ( encodingAsUTF8: """
@@ -198,6 +249,7 @@ final class BasicTests: XCTestCase {
198
249
XCTAssertContents ( runError) { checker in
199
250
checker. check ( . regex( " Compiling .*secho.* " ) )
200
251
checker. check ( . regex( " Linking .*secho " ) )
252
+ checker. check ( . contains( " Build complete " ) )
201
253
}
202
254
XCTAssertEqual ( runOutput, " 1 \" two \" \n " )
203
255
}
@@ -305,12 +357,12 @@ final class BasicTests: XCTestCase {
305
357
306
358
let testOutput = try sh ( swiftTest, " --package-path " , toolDir, " --filter " , " MyTests.* " ) . stderr
307
359
308
- // Check the test log.
309
- XCTAssertContents ( testOutput) { checker in
310
- checker. check ( . contains( " Test Suite 'MyTests' started " ) )
311
- checker. check ( . contains( " Test Suite 'MyTests' passed " ) )
312
- checker. check ( . contains( " Executed 2 tests, with 0 failures " ) )
313
- }
360
+ // Check the test log.
361
+ XCTAssertContents ( testOutput) { checker in
362
+ checker. check ( . contains( " Test Suite 'MyTests' started " ) )
363
+ checker. check ( . contains( " Test Suite 'MyTests' passed " ) )
364
+ checker. check ( . contains( " Executed 2 tests, with 0 failures " ) )
365
+ }
314
366
}
315
367
}
316
368
}
0 commit comments