@@ -766,11 +766,26 @@ final class ExplicitModuleBuildTests: XCTestCase {
766
766
}
767
767
768
768
func checkInputOutputIntegrity( _ job: Job ) {
769
- let name = job. outputs [ 0 ] . file. basename
769
+ let name = job. outputs [ 0 ] . file. basenameWithoutExt
770
+ XCTAssertTrue ( job. outputs [ 0 ] . file. extension == " swiftmodule " )
770
771
job. inputs. forEach { input in
771
- XCTAssertTrue ( input. file. basename == name)
772
+ XCTAssertTrue ( input. file. extension == " swiftmodule " )
773
+ let inputName = input. file. basenameWithoutExt
774
+ // arm64 interface can depend on ar64e interface
775
+ if inputName. starts ( with: " arm64e- " ) && name. starts ( with: " arm64- " ) {
776
+ return
777
+ }
778
+ XCTAssertTrue ( inputName == name)
779
+ }
780
+ }
781
+
782
+ func findJob( _ jobs: [ Job ] , _ module: String , _ basenameWithoutExt: String ) -> Job ? {
783
+ return jobs. first { job in
784
+ return job. moduleName == module &&
785
+ job. outputs [ 0 ] . file. basenameWithoutExt == basenameWithoutExt
772
786
}
773
787
}
788
+
774
789
let packageRootPath = URL ( fileURLWithPath: #file) . pathComponents
775
790
. prefix ( while: { $0 != " Tests " } ) . joined ( separator: " / " ) . dropFirst ( )
776
791
let testInputsPath = packageRootPath + " /TestInputs "
@@ -783,7 +798,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
783
798
XCTAssertTrue ( interfaceMap [ " Swift " ] !. count == 2 )
784
799
XCTAssertTrue ( interfaceMap [ " A " ] !. count == 2 )
785
800
XCTAssertTrue ( interfaceMap [ " E " ] !. count == 2 )
786
- XCTAssertTrue ( interfaceMap [ " F " ] !. count == 2 )
801
+ XCTAssertTrue ( interfaceMap [ " F " ] !. count == 3 )
787
802
XCTAssertTrue ( interfaceMap [ " G " ] !. count == 2 )
788
803
XCTAssertTrue ( interfaceMap [ " H " ] !. count == 2 )
789
804
@@ -809,7 +824,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
809
824
XCTAssertTrue ( danglingJobs. allSatisfy { job in
810
825
job. moduleName == " MissingKit "
811
826
} )
812
- XCTAssertTrue ( jobs. count == 12 )
827
+ XCTAssertTrue ( jobs. count == 13 )
813
828
XCTAssertTrue ( jobs. allSatisfy { $0. outputs. count == 1 } )
814
829
XCTAssertTrue ( jobs. allSatisfy { $0. kind == . compile} )
815
830
XCTAssertTrue ( jobs. allSatisfy { $0. commandLine. contains ( . flag( " -compile-module-from-interface " ) ) } )
@@ -842,7 +857,7 @@ final class ExplicitModuleBuildTests: XCTestCase {
842
857
exhaustive: false )
843
858
844
859
XCTAssertTrue ( danglingJobs. isEmpty)
845
- XCTAssertTrue ( jobs. count == 12 )
860
+ XCTAssertTrue ( jobs. count == 13 )
846
861
XCTAssertTrue ( jobs. allSatisfy { $0. outputs. count == 1 } )
847
862
XCTAssertTrue ( jobs. allSatisfy { $0. kind == . compile} )
848
863
XCTAssertTrue ( jobs. allSatisfy { $0. commandLine. contains ( . flag( " -compile-module-from-interface " ) ) } )
@@ -892,13 +907,36 @@ final class ExplicitModuleBuildTests: XCTestCase {
892
907
exhaustive: false )
893
908
894
909
XCTAssertTrue ( danglingJobs. isEmpty)
895
- XCTAssertTrue ( jobs. count == 6 )
910
+ XCTAssertTrue ( jobs. count == 7 )
896
911
jobs. forEach ( { job in
897
912
// Check we don't pull in other modules than A, F and Swift
898
913
XCTAssertTrue ( [ " A " , " F " , " Swift " ] . contains ( job. moduleName) )
899
914
checkInputOutputIntegrity ( job)
900
915
} )
901
916
}
917
+ try withTemporaryDirectory { path in
918
+ let main = path. appending ( component: " testPrebuiltModuleGenerationJobs.swift " )
919
+ try localFileSystem. writeFileContents ( main) {
920
+ $0 <<< " import H \n "
921
+ }
922
+ var driver = try Driver ( args: [ " swiftc " , main. pathString,
923
+ " -sdk " , mockSDKPath,
924
+ ] )
925
+
926
+ let ( jobs, _) = try driver. generatePrebuitModuleGenerationJobs ( with: interfaceMap,
927
+ into: VirtualPath ( path: " /tmp/ " ) . absolutePath!,
928
+ exhaustive: false )
929
+ let F = findJob ( jobs, " F " , " arm64-apple-macos " ) !
930
+ let H = findJob ( jobs, " H " , " arm64e-apple-macos " ) !
931
+ // Test arm64 interface requires arm64e interfaces as inputs
932
+ XCTAssertTrue ( F . inputs. contains { input in
933
+ input. file. basenameWithoutExt == " arm64e-apple-macos "
934
+ } )
935
+ // Test arm64e interface doesn't require arm64 interfaces as inputs
936
+ XCTAssertTrue ( !H. inputs. contains { input in
937
+ input. file. basenameWithoutExt == " arm64-apple-macos "
938
+ } )
939
+ }
902
940
}
903
941
#endif
904
942
}
0 commit comments