Skip to content

Commit 0e9d786

Browse files
authored
Merge pull request swiftlang#974 from apple/es-testfix
Test fix: import a swiftinterface that does not have objc dependency Resolves rdar://87457400
2 parents ff679c3 + 9fbd81c commit 0e9d786

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -700,31 +700,32 @@ final class ExplicitModuleBuildTests: XCTestCase {
700700
.pathString
701701

702702
// Foo imports Car which is mapped to the real module Bar via
703-
// `-module-alias Car=Bar`; it allows Car (alias) to be referenced
704-
// in source files, while its contents are compiled as Bar (real
703+
// `-module-alias Car=E`; it allows Car (alias) to be referenced
704+
// in source files, while its contents are compiled as E (real
705705
// name on disk).
706706
let srcFoo = path.appending(component: "Foo.swift")
707707
try localFileSystem.writeFileContents(srcFoo) {
708708
$0 <<< "import Car\n"
709709
}
710-
710+
let sdkArgumentsForTesting = (try? Driver.sdkArgumentsForTesting()) ?? []
711+
711712
// Module alias with the fallback scanner (frontend scanner)
712713
var driverA = try Driver(args: ["swiftc",
713714
"-nonlib-dependency-scanner",
714715
"-explicit-module-build",
715716
srcFoo.pathString.nativePathString().escaped(),
716-
"-module-alias", "Car=F",
717+
"-module-alias", "Car=E",
717718
"-I",
718719
swiftModuleInterfacesPath.nativePathString().escaped(),
719-
])
720+
] + sdkArgumentsForTesting)
720721
guard driverA.isFrontendArgSupported(.moduleAlias) else {
721722
throw XCTSkip("Skipping: compiler does not support '-module-alias'")
722723
}
723724

724725
// Resulting graph should contain the real module name Bar
725726
let dependencyGraphA = try driverA.gatherModuleDependencies()
726727
XCTAssertTrue(dependencyGraphA.modules.contains { (key: ModuleDependencyId, value: ModuleInfo) in
727-
key.moduleName == "F"
728+
key.moduleName == "E"
728729
})
729730
XCTAssertFalse(dependencyGraphA.modules.contains { (key: ModuleDependencyId, value: ModuleInfo) in
730731
key.moduleName == "Car"
@@ -733,24 +734,24 @@ final class ExplicitModuleBuildTests: XCTestCase {
733734
let plannedJobsA = try driverA.planBuild()
734735
XCTAssertTrue(plannedJobsA.contains { job in
735736
job.commandLine.contains(.flag("-module-alias")) &&
736-
job.commandLine.contains(.flag("Car=F"))
737+
job.commandLine.contains(.flag("Car=E"))
737738
})
738739

739740
// Module alias with the default scanner (driver scanner)
740741
var driverB = try Driver(args: ["swiftc",
741742
"-explicit-module-build",
742743
srcFoo.pathString.nativePathString().escaped(),
743-
"-module-alias", "Car=F",
744+
"-module-alias", "Car=E",
744745
"-working-directory",
745746
path.pathString.nativePathString().escaped(),
746747
"-I",
747748
swiftModuleInterfacesPath.nativePathString().escaped(),
748-
])
749+
] + sdkArgumentsForTesting)
749750

750751
// Resulting graph should contain the real module name Bar
751752
let dependencyGraphB = try driverB.gatherModuleDependencies()
752753
XCTAssertTrue(dependencyGraphB.modules.contains { (key: ModuleDependencyId, value: ModuleInfo) in
753-
key.moduleName == "F"
754+
key.moduleName == "E"
754755
})
755756
XCTAssertFalse(dependencyGraphB.modules.contains { (key: ModuleDependencyId, value: ModuleInfo) in
756757
key.moduleName == "Car"
@@ -759,7 +760,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
759760
let plannedJobsB = try driverB.planBuild()
760761
XCTAssertTrue(plannedJobsB.contains { job in
761762
job.commandLine.contains(.flag("-module-alias")) &&
762-
job.commandLine.contains(.flag("Car=F"))
763+
job.commandLine.contains(.flag("Car=E"))
763764
})
764765
}
765766
}

0 commit comments

Comments
 (0)