@@ -137,7 +137,7 @@ final class SwiftPMWorkspaceTests: XCTestCase {
137
137
assertNotNil ( await ws. indexStorePath)
138
138
let arguments = try await ws. buildSettings ( for: aswift. asURI, language: . swift) !. compilerArguments
139
139
140
- check (
140
+ assertArgumentsContain (
141
141
" -module-name " ,
142
142
" lib " ,
143
143
" -incremental " ,
@@ -146,21 +146,25 @@ final class SwiftPMWorkspaceTests: XCTestCase {
146
146
" -emit-module-path " ,
147
147
arguments: arguments
148
148
)
149
- check ( " -parse-as-library " , " -c " , arguments: arguments)
149
+ assertArgumentsContain ( " -parse-as-library " , " -c " , arguments: arguments)
150
150
151
- check ( " -target " , arguments: arguments) // Only one!
151
+ assertArgumentsContain ( " -target " , arguments: arguments) // Only one!
152
152
#if os(macOS)
153
153
let versionString = PackageModel . Platform. macOS. oldestSupportedVersion. versionString
154
- check ( " -target " , hostTriple. tripleString ( forPlatformVersion: versionString) , arguments: arguments)
155
- check ( " -sdk " , arguments: arguments)
156
- check ( " -F " , arguments: arguments, allowMultiple: true )
154
+ assertArgumentsContain (
155
+ " -target " ,
156
+ hostTriple. tripleString ( forPlatformVersion: versionString) ,
157
+ arguments: arguments
158
+ )
159
+ assertArgumentsContain ( " -sdk " , arguments: arguments)
160
+ assertArgumentsContain ( " -F " , arguments: arguments, allowMultiple: true )
157
161
#else
158
- check ( " -target " , hostTriple. tripleString, arguments: arguments)
162
+ assertArgumentsContain ( " -target " , hostTriple. tripleString, arguments: arguments)
159
163
#endif
160
164
161
- check ( " -I " , build. appending ( component: " Modules " ) . pathString, arguments: arguments)
165
+ assertArgumentsContain ( " -I " , build. appending ( component: " Modules " ) . pathString, arguments: arguments)
162
166
163
- check ( aswift. pathString, arguments: arguments)
167
+ assertArgumentsContain ( aswift. pathString, arguments: arguments)
164
168
}
165
169
}
166
170
@@ -203,9 +207,9 @@ final class SwiftPMWorkspaceTests: XCTestCase {
203
207
assertEqual ( await ws. buildPath, build)
204
208
let arguments = try await ws. buildSettings ( for: aswift. asURI, language: . swift) !. compilerArguments
205
209
206
- check ( " -typecheck " , arguments: arguments)
207
- check ( " -Xcc " , " -m32 " , arguments: arguments)
208
- check ( " -O " , arguments: arguments)
210
+ assertArgumentsContain ( " -typecheck " , arguments: arguments)
211
+ assertArgumentsContain ( " -Xcc " , " -m32 " , arguments: arguments)
212
+ assertArgumentsContain ( " -O " , arguments: arguments)
209
213
}
210
214
}
211
215
@@ -236,8 +240,8 @@ final class SwiftPMWorkspaceTests: XCTestCase {
236
240
let source = try resolveSymlinks ( packageRoot. appending ( component: " Package.swift " ) )
237
241
let arguments = try await ws. buildSettings ( for: source. asURI, language: . swift) !. compilerArguments
238
242
239
- check ( " -swift-version " , " 4.2 " , arguments: arguments)
240
- check ( source. pathString, arguments: arguments)
243
+ assertArgumentsContain ( " -swift-version " , " 4.2 " , arguments: arguments)
244
+ assertArgumentsContain ( source. pathString, arguments: arguments)
241
245
}
242
246
}
243
247
@@ -270,11 +274,11 @@ final class SwiftPMWorkspaceTests: XCTestCase {
270
274
let bswift = packageRoot. appending ( components: " Sources " , " lib " , " b.swift " )
271
275
272
276
let argumentsA = try await ws. buildSettings ( for: aswift. asURI, language: . swift) !. compilerArguments
273
- check ( aswift. pathString, arguments: argumentsA)
274
- check ( bswift. pathString, arguments: argumentsA)
277
+ assertArgumentsContain ( aswift. pathString, arguments: argumentsA)
278
+ assertArgumentsContain ( bswift. pathString, arguments: argumentsA)
275
279
let argumentsB = try await ws. buildSettings ( for: aswift. asURI, language: . swift) !. compilerArguments
276
- check ( aswift. pathString, arguments: argumentsB)
277
- check ( bswift. pathString, arguments: argumentsB)
280
+ assertArgumentsContain ( aswift. pathString, arguments: argumentsB)
281
+ assertArgumentsContain ( bswift. pathString, arguments: argumentsB)
278
282
}
279
283
}
280
284
@@ -312,30 +316,30 @@ final class SwiftPMWorkspaceTests: XCTestCase {
312
316
let aswift = packageRoot. appending ( components: " Sources " , " libA " , " a.swift " )
313
317
let bswift = packageRoot. appending ( components: " Sources " , " libB " , " b.swift " )
314
318
let arguments = try await ws. buildSettings ( for: aswift. asURI, language: . swift) !. compilerArguments
315
- check ( aswift. pathString, arguments: arguments)
316
- checkNot ( bswift. pathString, arguments: arguments)
319
+ assertArgumentsContain ( aswift. pathString, arguments: arguments)
320
+ assertArgumentsDoNotContain ( bswift. pathString, arguments: arguments)
317
321
// Temporary conditional to work around revlock between SourceKit-LSP and SwiftPM
318
322
// as a result of fix for SR-12050. Can be removed when that fix has been merged.
319
323
if arguments. joined ( separator: " " ) . contains ( " -Xcc -I -Xcc " ) {
320
- check (
324
+ assertArgumentsContain (
321
325
" -Xcc " ,
322
326
" -I " ,
323
327
" -Xcc " ,
324
328
packageRoot. appending ( components: " Sources " , " libC " , " include " ) . pathString,
325
329
arguments: arguments
326
330
)
327
331
} else {
328
- check (
332
+ assertArgumentsContain (
329
333
" -I " ,
330
334
packageRoot. appending ( components: " Sources " , " libC " , " include " ) . pathString,
331
335
arguments: arguments
332
336
)
333
337
}
334
338
335
339
let argumentsB = try await ws. buildSettings ( for: bswift. asURI, language: . swift) !. compilerArguments
336
- check ( bswift. pathString, arguments: argumentsB)
337
- checkNot ( aswift. pathString, arguments: argumentsB)
338
- checkNot (
340
+ assertArgumentsContain ( bswift. pathString, arguments: argumentsB)
341
+ assertArgumentsDoNotContain ( aswift. pathString, arguments: argumentsB)
342
+ assertArgumentsDoNotContain (
339
343
" -I " ,
340
344
packageRoot. appending ( components: " Sources " , " libC " , " include " ) . pathString,
341
345
arguments: argumentsB
@@ -414,54 +418,54 @@ final class SwiftPMWorkspaceTests: XCTestCase {
414
418
assertNotNil ( await ws. indexStorePath)
415
419
416
420
let checkArgsCommon = { ( arguments: [ String ] ) in
417
- check ( " -std=c++14 " , arguments: arguments)
421
+ assertArgumentsContain ( " -std=c++14 " , arguments: arguments)
418
422
419
- checkNot ( " -arch " , arguments: arguments)
420
- check ( " -target " , arguments: arguments) // Only one!
423
+ assertArgumentsDoNotContain ( " -arch " , arguments: arguments)
424
+ assertArgumentsContain ( " -target " , arguments: arguments) // Only one!
421
425
#if os(macOS)
422
426
let versionString = PackageModel . Platform. macOS. oldestSupportedVersion. versionString
423
- check (
427
+ assertArgumentsContain (
424
428
" -target " ,
425
429
hostTriple. tripleString ( forPlatformVersion: versionString) ,
426
430
arguments: arguments
427
431
)
428
- check ( " -isysroot " , arguments: arguments)
429
- check ( " -F " , arguments: arguments, allowMultiple: true )
432
+ assertArgumentsContain ( " -isysroot " , arguments: arguments)
433
+ assertArgumentsContain ( " -F " , arguments: arguments, allowMultiple: true )
430
434
#else
431
- check ( " -target " , hostTriple. tripleString, arguments: arguments)
435
+ assertArgumentsContain ( " -target " , hostTriple. tripleString, arguments: arguments)
432
436
#endif
433
437
434
- check (
438
+ assertArgumentsContain (
435
439
" -I " ,
436
440
packageRoot. appending ( components: " Sources " , " lib " , " include " ) . pathString,
437
441
arguments: arguments
438
442
)
439
- checkNot ( " -I " , build. pathString, arguments: arguments)
440
- checkNot ( bcxx. pathString, arguments: arguments)
443
+ assertArgumentsDoNotContain ( " -I " , build. pathString, arguments: arguments)
444
+ assertArgumentsDoNotContain ( bcxx. pathString, arguments: arguments)
441
445
}
442
446
443
447
let args = try await ws. buildSettings ( for: acxx. asURI, language: . cpp) !. compilerArguments
444
448
checkArgsCommon ( args)
445
449
446
450
URL ( fileURLWithPath: build. appending ( components: " lib.build " , " a.cpp.d " ) . pathString)
447
451
. withUnsafeFileSystemRepresentation {
448
- check ( " -MD " , " -MT " , " dependencies " , " -MF " , String ( cString: $0!) , arguments: args)
452
+ assertArgumentsContain ( " -MD " , " -MT " , " dependencies " , " -MF " , String ( cString: $0!) , arguments: args)
449
453
}
450
454
451
455
URL ( fileURLWithPath: acxx. pathString) . withUnsafeFileSystemRepresentation {
452
- check ( " -c " , String ( cString: $0!) , arguments: args)
456
+ assertArgumentsContain ( " -c " , String ( cString: $0!) , arguments: args)
453
457
}
454
458
455
459
URL ( fileURLWithPath: build. appending ( components: " lib.build " , " a.cpp.o " ) . pathString)
456
460
. withUnsafeFileSystemRepresentation {
457
- check ( " -o " , String ( cString: $0!) , arguments: args)
461
+ assertArgumentsContain ( " -o " , String ( cString: $0!) , arguments: args)
458
462
}
459
463
460
464
let header = packageRoot. appending ( components: " Sources " , " lib " , " include " , " a.h " )
461
465
let headerArgs = try await ws. buildSettings ( for: header. asURI, language: . cpp) !. compilerArguments
462
466
checkArgsCommon ( headerArgs)
463
467
464
- check (
468
+ assertArgumentsContain (
465
469
" -c " ,
466
470
" -x " ,
467
471
" c++-header " ,
@@ -498,17 +502,17 @@ final class SwiftPMWorkspaceTests: XCTestCase {
498
502
499
503
let aswift = packageRoot. appending ( components: " Sources " , " lib " , " a.swift " )
500
504
let arguments = try await ws. buildSettings ( for: aswift. asURI, language: . swift) !. compilerArguments
501
- check ( " -target " , arguments: arguments) // Only one!
505
+ assertArgumentsContain ( " -target " , arguments: arguments) // Only one!
502
506
let hostTriple = await ws. buildParameters. targetTriple
503
507
504
508
#if os(macOS)
505
- check (
509
+ assertArgumentsContain (
506
510
" -target " ,
507
511
hostTriple. tripleString ( forPlatformVersion: " 10.13 " ) ,
508
512
arguments: arguments
509
513
)
510
514
#else
511
- check ( " -target " , hostTriple. tripleString, arguments: arguments)
515
+ assertArgumentsContain ( " -target " , hostTriple. tripleString, arguments: arguments)
512
516
#endif
513
517
}
514
518
}
@@ -556,14 +560,14 @@ final class SwiftPMWorkspaceTests: XCTestCase {
556
560
XCTAssertNotNil ( arguments2)
557
561
XCTAssertEqual ( arguments1, arguments2)
558
562
559
- checkNot ( aswift1. pathString, arguments: arguments1 ?? [ ] )
560
- check ( try resolveSymlinks ( aswift1) . pathString, arguments: arguments1 ?? [ ] )
563
+ assertArgumentsDoNotContain ( aswift1. pathString, arguments: arguments1 ?? [ ] )
564
+ assertArgumentsContain ( try resolveSymlinks ( aswift1) . pathString, arguments: arguments1 ?? [ ] )
561
565
562
566
let argsManifest = try await ws. buildSettings ( for: manifest. asURI, language: . swift) ? . compilerArguments
563
567
XCTAssertNotNil ( argsManifest)
564
568
565
- checkNot ( manifest. pathString, arguments: argsManifest ?? [ ] )
566
- check ( try resolveSymlinks ( manifest) . pathString, arguments: argsManifest ?? [ ] )
569
+ assertArgumentsDoNotContain ( manifest. pathString, arguments: argsManifest ?? [ ] )
570
+ assertArgumentsContain ( try resolveSymlinks ( manifest) . pathString, arguments: argsManifest ?? [ ] )
567
571
}
568
572
}
569
573
@@ -606,13 +610,13 @@ final class SwiftPMWorkspaceTests: XCTestCase {
606
610
607
611
let argsCxx = try await ws. buildSettings ( for: acxx. asURI, language: . cpp) ? . compilerArguments
608
612
XCTAssertNotNil ( argsCxx)
609
- check ( acxx. pathString, arguments: argsCxx ?? [ ] )
610
- checkNot ( try resolveSymlinks ( acxx) . pathString, arguments: argsCxx ?? [ ] )
613
+ assertArgumentsContain ( acxx. pathString, arguments: argsCxx ?? [ ] )
614
+ assertArgumentsDoNotContain ( try resolveSymlinks ( acxx) . pathString, arguments: argsCxx ?? [ ] )
611
615
612
616
let argsH = try await ws. buildSettings ( for: ah. asURI, language: . cpp) ? . compilerArguments
613
617
XCTAssertNotNil ( argsH)
614
- checkNot ( ah. pathString, arguments: argsH ?? [ ] )
615
- check ( try resolveSymlinks ( ah) . pathString, arguments: argsH ?? [ ] )
618
+ assertArgumentsDoNotContain ( ah. pathString, arguments: argsH ?? [ ] )
619
+ assertArgumentsContain ( try resolveSymlinks ( ah) . pathString, arguments: argsH ?? [ ] )
616
620
}
617
621
}
618
622
@@ -647,7 +651,7 @@ final class SwiftPMWorkspaceTests: XCTestCase {
647
651
648
652
let aswift = packageRoot. appending ( components: " Sources " , " lib " , " a.swift " )
649
653
let arguments = try await ws. buildSettings ( for: aswift. asURI, language: . swift) !. compilerArguments
650
- check ( aswift. pathString, arguments: arguments)
654
+ assertArgumentsContain ( aswift. pathString, arguments: arguments)
651
655
XCTAssertNotNil (
652
656
arguments. firstIndex ( where: {
653
657
$0. hasSuffix ( " .swift " ) && $0. contains ( " DerivedSources " )
@@ -686,7 +690,7 @@ final class SwiftPMWorkspaceTests: XCTestCase {
686
690
}
687
691
}
688
692
689
- private func checkNot (
693
+ private func assertArgumentsDoNotContain (
690
694
_ pattern: String ... ,
691
695
arguments: [ String ] ,
692
696
file: StaticString = #filePath,
@@ -702,7 +706,7 @@ private func checkNot(
702
706
}
703
707
}
704
708
705
- private func check (
709
+ private func assertArgumentsContain (
706
710
_ pattern: String ... ,
707
711
arguments: [ String ] ,
708
712
allowMultiple: Bool = false ,
0 commit comments