Skip to content

Commit 0c78e30

Browse files
MaxDesiatovrauhul
andauthored
Update tests to allow multiple -F options (#742) (#775)
Cherry-pick of #742 required to unblock swiftlang/swift-package-manager#6709. Updates tests to allow compile arguments with multiple `-F` options such as `-F <foo> -Xcc -F -Xcc <foo>`. This change is required to support SwiftPM changes which forward C compiler flags to the Swift compiler in more cases. Co-authored-by: Rauhul Varma <[email protected]>
1 parent 651aced commit 0c78e30

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Tests/SKSwiftPMWorkspaceTests/SwiftPMWorkspaceTests.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ final class SwiftPMWorkspaceTests: XCTestCase {
123123
let versionString = PackageModel.Platform.macOS.oldestSupportedVersion.versionString
124124
check("-target", hostTriple.tripleString(forPlatformVersion: versionString), arguments: arguments)
125125
check("-sdk", arguments: arguments)
126-
check("-F", arguments: arguments)
126+
check("-F", arguments: arguments, allowMultiple: true)
127127
#else
128128
check("-target", hostTriple.tripleString, arguments: arguments)
129129
#endif
@@ -365,7 +365,7 @@ final class SwiftPMWorkspaceTests: XCTestCase {
365365
check("-target",
366366
hostTriple.tripleString(forPlatformVersion: versionString), arguments: arguments)
367367
check("-isysroot", arguments: arguments)
368-
check("-F", arguments: arguments)
368+
check("-F", arguments: arguments, allowMultiple: true)
369369
#else
370370
check("-target", hostTriple.tripleString, arguments: arguments)
371371
#endif
@@ -609,6 +609,7 @@ private func checkNot(
609609
private func check(
610610
_ pattern: String...,
611611
arguments: [String],
612+
allowMultiple: Bool = false,
612613
file: StaticString = #filePath,
613614
line: UInt = #line)
614615
{
@@ -617,7 +618,7 @@ private func check(
617618
return
618619
}
619620

620-
if let index2 = arguments[(index+1)...].firstIndex(of: pattern) {
621+
if !allowMultiple, let index2 = arguments[(index+1)...].firstIndex(of: pattern) {
621622
XCTFail(
622623
"pattern \(pattern) found twice (\(index), \(index2)) in \(arguments)",
623624
file: file, line: line)

0 commit comments

Comments
 (0)