@@ -606,16 +606,22 @@ final class ExplicitModuleBuildTests: XCTestCase {
606
606
607
607
// Create Bar.swiftmodule
608
608
var driver = try Driver ( args: [ " swiftc " ,
609
- " -explicit-module-build " ,
610
- srcBar. pathString. nativePathString ( ) . escaped ( ) ,
611
- " -module-name " ,
612
- " Bar " ,
613
- " -emit-module " ,
614
- " -emit-module-path " , moduleBarPath,
615
- " -I " , stdLibPath. pathString. nativePathString ( ) . escaped ( ) ,
616
- " -I " , shimsPath. pathString. nativePathString ( ) . escaped ( ) ,
617
- ] + sdkArgumentsForTesting,
618
- env: ProcessEnv . vars)
609
+ " -explicit-module-build " ,
610
+ " -working-directory " ,
611
+ path. pathString. nativePathString ( ) . escaped ( ) ,
612
+ srcBar. pathString. nativePathString ( ) . escaped ( ) ,
613
+ " -module-name " ,
614
+ " Bar " ,
615
+ " -emit-module " ,
616
+ " -emit-module-path " , moduleBarPath,
617
+ " -I " , stdLibPath. pathString. nativePathString ( ) . escaped ( ) ,
618
+ " -I " , shimsPath. pathString. nativePathString ( ) . escaped ( ) ,
619
+ ] + sdkArgumentsForTesting,
620
+ env: ProcessEnv . vars)
621
+ guard driver. isFrontendArgSupported ( . moduleAlias) else {
622
+ throw XCTSkip ( " Skipping: compiler does not support '-module-alias' " )
623
+ }
624
+
619
625
let jobs = try driver. planBuild ( )
620
626
try driver. run ( jobs: jobs)
621
627
XCTAssertFalse ( driver. diagnosticEngine. hasErrors)
@@ -635,6 +641,8 @@ final class ExplicitModuleBuildTests: XCTestCase {
635
641
var driverA = try Driver ( args: [ " swiftc " ,
636
642
" -nonlib-dependency-scanner " ,
637
643
" -explicit-module-build " ,
644
+ " -working-directory " ,
645
+ path. pathString. nativePathString ( ) . escaped ( ) ,
638
646
srcFoo. pathString. nativePathString ( ) . escaped ( ) ,
639
647
" -module-alias " , " Car=Bar " ,
640
648
" -I " ,
@@ -659,6 +667,8 @@ final class ExplicitModuleBuildTests: XCTestCase {
659
667
// Module alias with the default scanner (driver scanner)
660
668
var driverB = try Driver ( args: [ " swiftc " ,
661
669
" -explicit-module-build " ,
670
+ " -working-directory " ,
671
+ path. pathString. nativePathString ( ) . escaped ( ) ,
662
672
srcFoo. pathString. nativePathString ( ) . escaped ( ) ,
663
673
" -module-alias " , " Car=Bar " ,
664
674
" -I " ,
@@ -707,6 +717,9 @@ final class ExplicitModuleBuildTests: XCTestCase {
707
717
" -I " ,
708
718
swiftModuleInterfacesPath. nativePathString ( ) . escaped ( ) ,
709
719
] )
720
+ guard driverA. isFrontendArgSupported ( . moduleAlias) else {
721
+ throw XCTSkip ( " Skipping: compiler does not support '-module-alias' " )
722
+ }
710
723
711
724
// Resulting graph should contain the real module name Bar
712
725
let dependencyGraphA = try driverA. gatherModuleDependencies ( )
@@ -728,6 +741,8 @@ final class ExplicitModuleBuildTests: XCTestCase {
728
741
" -explicit-module-build " ,
729
742
srcFoo. pathString. nativePathString ( ) . escaped ( ) ,
730
743
" -module-alias " , " Car=F " ,
744
+ " -working-directory " ,
745
+ path. pathString. nativePathString ( ) . escaped ( ) ,
731
746
" -I " ,
732
747
swiftModuleInterfacesPath. nativePathString ( ) . escaped ( ) ,
733
748
] )
@@ -752,6 +767,11 @@ final class ExplicitModuleBuildTests: XCTestCase {
752
767
func testModuleAliasingWithImportPrescan( ) throws {
753
768
let ( _, _, toolchain, hostTriple) = try getDriverArtifactsForScanning ( )
754
769
770
+ let dummyDriver = try Driver ( args: [ " swiftc " , " -module-name " , " dummyDriverCheck " , " test.swift " ] )
771
+ guard dummyDriver. isFrontendArgSupported ( . moduleAlias) else {
772
+ throw XCTSkip ( " Skipping: compiler does not support '-module-alias' " )
773
+ }
774
+
755
775
// The dependency oracle wraps an instance of libSwiftScan and ensures thread safety across
756
776
// queries.
757
777
let dependencyOracle = InterModuleDependencyOracle ( )
@@ -805,13 +825,19 @@ final class ExplicitModuleBuildTests: XCTestCase {
805
825
" -explicit-module-build " ,
806
826
" -module-name " ,
807
827
" Bar " ,
828
+ " -working-directory " ,
829
+ path. pathString. nativePathString ( ) . escaped ( ) ,
808
830
" -emit-module " ,
809
831
" -emit-module-path " , moduleBarPath,
810
832
srcBar. pathString. nativePathString ( ) . escaped ( ) ,
811
833
" -I " , stdLibPath. pathString. nativePathString ( ) . escaped ( ) ,
812
834
" -I " , shimsPath. pathString. nativePathString ( ) . escaped ( ) ,
813
835
] + sdkArgumentsForTesting,
814
836
env: ProcessEnv . vars)
837
+ guard driver1. isFrontendArgSupported ( . moduleAlias) else {
838
+ throw XCTSkip ( " Skipping: compiler does not support '-module-alias' " )
839
+ }
840
+
815
841
let jobs1 = try driver1. planBuild ( )
816
842
try driver1. run ( jobs: jobs1)
817
843
XCTAssertFalse ( driver1. diagnosticEngine. hasErrors)
@@ -834,6 +860,8 @@ final class ExplicitModuleBuildTests: XCTestCase {
834
860
" -explicit-module-build " ,
835
861
" -module-name " ,
836
862
" Foo " ,
863
+ " -working-directory " ,
864
+ path. pathString. nativePathString ( ) . escaped ( ) ,
837
865
" -emit-module " ,
838
866
" -emit-module-path " ,
839
867
moduleFooPath,
@@ -878,10 +906,6 @@ final class ExplicitModuleBuildTests: XCTestCase {
878
906
" -I " , swiftModuleInterfacesPath. nativePathString ( ) . escaped ( ) ,
879
907
" -explicit-module-build " ,
880
908
" -working-directory " , path. pathString. nativePathString ( ) . escaped ( ) ,
881
- // TODO: clang targets need to be taught
882
- // how to work with explicit modules
883
- // properly.
884
- " -disable-clang-target " ,
885
909
main. pathString. escaped ( ) ] + sdkArgumentsForTesting,
886
910
env: ProcessEnv . vars)
887
911
let jobs = try driver. planBuild ( )
0 commit comments