@@ -38,7 +38,7 @@ class BuildCommandTestCases: CommandsBuildProviderTestCase {
38
38
}
39
39
40
40
@discardableResult
41
- private func execute(
41
+ func execute(
42
42
_ args: [ String ] = [ ] ,
43
43
environment: Environment ? = nil ,
44
44
packagePath: AbsolutePath ? = nil
@@ -70,7 +70,19 @@ class BuildCommandTestCases: CommandsBuildProviderTestCase {
70
70
// is what `binContents` is meant to represent.
71
71
return contents != [ " output-file-map.json " ]
72
72
}
73
- let moduleContents = ( try ? localFileSystem. getDirectoryContents ( binPath. appending ( component: " Modules " ) ) ) ?? [ ]
73
+ var moduleContents : [ String ] = [ ]
74
+ if buildSystemProvider == . native {
75
+ moduleContents = ( try ? localFileSystem. getDirectoryContents ( binPath. appending ( component: " Modules " ) ) ) ?? [ ]
76
+ } else {
77
+ let moduleDirs = ( try ? localFileSystem. getDirectoryContents ( binPath) . filter {
78
+ $0. hasSuffix ( " .swiftmodule " )
79
+ } ) ?? [ ]
80
+ for dir : String in moduleDirs {
81
+ moduleContents +=
82
+ ( try ? localFileSystem. getDirectoryContents ( binPath. appending ( component: dir) ) . map { " \( dir) / \( $0) " } ) ?? [ ]
83
+ }
84
+ }
85
+
74
86
75
87
if cleanAfterward {
76
88
try ! await executeSwiftPackage (
@@ -103,6 +115,10 @@ class BuildCommandTestCases: CommandsBuildProviderTestCase {
103
115
XCTAssertMatch ( stdout, . contains( " USAGE: swift build " ) )
104
116
}
105
117
118
+ func testBinSymlink( ) async throws {
119
+ XCTAssertTrue ( false , " Must be implemented at build system test class. " )
120
+ }
121
+
106
122
func testSeeAlso( ) async throws {
107
123
let stdout = try await execute ( [ " --help " ] ) . stdout
108
124
XCTAssertMatch ( stdout, . contains( " SEE ALSO: swift run, swift package, swift test " ) )
@@ -190,48 +206,6 @@ class BuildCommandTestCases: CommandsBuildProviderTestCase {
190
206
}
191
207
}
192
208
193
- func testBinSymlink( ) async throws {
194
- try await fixture ( name: " ValidLayouts/SingleModule/ExecutableNew " ) { fixturePath in
195
- let fullPath = try resolveSymlinks ( fixturePath)
196
- let targetPath = try fullPath. appending (
197
- components: " .build " ,
198
- UserToolchain . default. targetTriple. platformBuildPathComponent
199
- )
200
- let xcbuildTargetPath = fullPath. appending ( components: " .build " , " apple " )
201
- try await XCTAssertAsyncEqual (
202
- try await self . execute ( [ " --show-bin-path " ] , packagePath: fullPath) . stdout,
203
- " \( targetPath. appending ( " debug " ) . pathString) \n "
204
- )
205
- try await XCTAssertAsyncEqual (
206
- try await self . execute ( [ " -c " , " release " , " --show-bin-path " ] , packagePath: fullPath) . stdout,
207
- " \( targetPath. appending ( " release " ) . pathString) \n "
208
- )
209
-
210
- guard buildSystemProvider == . xcode || buildSystemProvider == . swiftbuild else {
211
- // The remainder of this test only applies to XCBuild or Swift Build
212
- return
213
- }
214
-
215
- // Print correct path when building with XCBuild or Swift Build
216
- let xcodeDebugOutput = try await execute (
217
- [ " -c " , " debug " , " --show-bin-path " ] ,
218
- packagePath: fullPath)
219
- . stdout
220
- let xcodeReleaseOutput = try await execute (
221
- [ " -c " , " release " , " --show-bin-path " ] ,
222
- packagePath: fullPath
223
- ) . stdout
224
- XCTAssertEqual (
225
- xcodeDebugOutput,
226
- " \( xcbuildTargetPath. appending ( components: " Products " , " Debug " ) . pathString) \n "
227
- )
228
- XCTAssertEqual (
229
- xcodeReleaseOutput,
230
- " \( xcbuildTargetPath. appending ( components: " Products " , " Release " ) . pathString) \n "
231
- )
232
- }
233
- }
234
-
235
209
func testSymlink( ) async throws {
236
210
try await fixture ( name: " ValidLayouts/SingleModule/ExecutableNew " ) { fixturePath in
237
211
let fullPath = try resolveSymlinks ( fixturePath)
@@ -792,6 +766,25 @@ class BuildCommandNativeTests: BuildCommandTestCases {
792
766
override func testUsage( ) async throws {
793
767
try await super. testUsage ( )
794
768
}
769
+
770
+ override func testBinSymlink( ) async throws {
771
+ try await fixture ( name: " ValidLayouts/SingleModule/ExecutableNew " ) { fixturePath in
772
+ let fullPath = try resolveSymlinks ( fixturePath)
773
+ let targetPath = try fullPath. appending (
774
+ components: " .build " ,
775
+ UserToolchain . default. targetTriple. platformBuildPathComponent
776
+ )
777
+ try await XCTAssertAsyncEqual (
778
+ try await self . execute ( [ " --show-bin-path " ] , packagePath: fullPath) . stdout,
779
+ " \( targetPath. appending ( " debug " ) . pathString) \n "
780
+ )
781
+ try await XCTAssertAsyncEqual (
782
+ try await self . execute ( [ " -c " , " release " , " --show-bin-path " ] , packagePath: fullPath)
783
+ . stdout,
784
+ " \( targetPath. appending ( " release " ) . pathString) \n "
785
+ )
786
+ }
787
+ }
795
788
}
796
789
797
790
#if os(macOS)
@@ -806,51 +799,51 @@ class BuildCommandXcodeTests: BuildCommandTestCases {
806
799
}
807
800
808
801
override func testAutomaticParseableInterfacesWithLibraryEvolution( ) async throws {
809
- try XCTSkip ( " Test not implemented for xcode build system. " )
802
+ throw XCTSkip ( " Test not implemented for xcode build system. " )
810
803
}
811
804
812
805
override func testNonReachableProductsAndTargetsFunctional( ) async throws {
813
- try XCTSkip ( " Test not implemented for xcode build system. " )
806
+ throw XCTSkip ( " Test not implemented for xcode build system. " )
814
807
}
815
808
816
809
override func testCodeCoverage( ) async throws {
817
- try XCTSkip ( " Test not implemented for xcode build system. " )
810
+ throw XCTSkip ( " Test not implemented for xcode build system. " )
818
811
}
819
812
820
813
override func testBuildStartMessage( ) async throws {
821
- try XCTSkip ( " Test not implemented for xcode build system. " )
814
+ throw XCTSkip ( " Test not implemented for xcode build system. " )
822
815
}
823
816
824
817
override func testBinSymlink( ) async throws {
825
- try XCTSkip ( " Test not implemented for xcode build system. " )
818
+ throw XCTSkip ( " Test not implemented for xcode build system. " )
826
819
}
827
820
828
821
override func testSymlink( ) async throws {
829
- try XCTSkip ( " Test not implemented for xcode build system. " )
822
+ throw XCTSkip ( " Test not implemented for xcode build system. " )
830
823
}
831
824
832
825
override func testSwiftGetVersion( ) async throws {
833
- try XCTSkip ( " Test not implemented for xcode build system. " )
826
+ throw XCTSkip ( " Test not implemented for xcode build system. " )
834
827
}
835
828
836
829
override func testParseableInterfaces( ) async throws {
837
- try XCTSkip ( " Test not implemented for xcode build system. " )
830
+ throw XCTSkip ( " Test not implemented for xcode build system. " )
838
831
}
839
832
840
833
override func testProductAndTarget( ) async throws {
841
- try XCTSkip ( " Test not implemented for xcode build system. " )
834
+ throw XCTSkip ( " Test not implemented for xcode build system. " )
842
835
}
843
836
844
837
override func testImportOfMissedDepWarning( ) async throws {
845
- try XCTSkip ( " Test not implemented for xcode build system. " )
838
+ throw XCTSkip ( " Test not implemented for xcode build system. " )
846
839
}
847
840
848
841
override func testGetTaskAllowEntitlement( ) async throws {
849
- try XCTSkip ( " Test not implemented for xcode build system. " )
842
+ throw XCTSkip ( " Test not implemented for xcode build system. " )
850
843
}
851
844
852
845
override func testBuildCompleteMessage( ) async throws {
853
- try XCTSkip ( " Test not implemented for xcode build system. " )
846
+ throw XCTSkip ( " Test not implemented for xcode build system. " )
854
847
}
855
848
}
856
849
#endif
@@ -866,9 +859,31 @@ class BuildCommandSwiftBuildTests: BuildCommandTestCases {
866
859
}
867
860
868
861
override func testParseableInterfaces( ) async throws {
869
- throw XCTSkip ( " SWBINTTODO: Test failed with swiftbuild engine because the --enable-parseable-module-interfaces flag doesn't yet produce .swiftinterface files. This needs to be investigated " )
862
+ try await fixture ( name: " Miscellaneous/ParseableInterfaces " ) { fixturePath in
863
+ do {
864
+ let result = try await build ( [ " --enable-parseable-module-interfaces " ] , packagePath: fixturePath)
865
+ XCTAssertMatch ( result. moduleContents, [ . regex( #"A\.swiftmodule\/.*\.swiftinterface"# ) ] )
866
+ XCTAssertMatch ( result. moduleContents, [ . regex( #"B\.swiftmodule\/.*\.swiftmodule"# ) ] )
867
+ } catch SwiftPMError . executionFailure( _, _, let stderr) {
868
+ XCTFail ( stderr)
869
+ }
870
+ }
870
871
}
871
872
873
+ override func testBinSymlink( ) async throws {
874
+ try await fixture ( name: " ValidLayouts/SingleModule/ExecutableNew " ) { fixturePath in
875
+ let fullPath = try resolveSymlinks ( fixturePath)
876
+ let targetPath = try fullPath. appending (
877
+ components: " .build " ,
878
+ UserToolchain . default. targetTriple. platformBuildPathComponent
879
+ )
880
+ let debugPath = try await self . execute ( [ " --show-bin-path " ] , packagePath: fullPath) . stdout
881
+ XCTAssertMatch ( debugPath, . regex( targetPath. appending ( components: " Products " , " Debug " ) . pathString + " ( \\ -linux| \\ -Windows)? \\ n " ) )
882
+ let releasePath = try await self . execute ( [ " -c " , " release " , " --show-bin-path " ] , packagePath: fullPath) . stdout
883
+ XCTAssertMatch ( releasePath, . regex( targetPath. appending ( components: " Products " , " Release " ) . pathString + " ( \\ -linux| \\ -Windows)? \\ n " ) )
884
+ }
885
+ }
886
+
872
887
override func testGetTaskAllowEntitlement( ) async throws {
873
888
throw XCTSkip ( " SWBINTTODO: Test failed because swiftbuild doesn't output precis codesign commands. Once swift run works with swiftbuild the test can be investigated. " )
874
889
}
@@ -880,13 +895,20 @@ class BuildCommandSwiftBuildTests: BuildCommandTestCases {
880
895
override func testAtMainSupport( ) async throws {
881
896
#if !os(macOS)
882
897
throw XCTSkip ( " SWBINTTODO: File not found or missing libclang errors on non-macOS platforms. This needs to be investigated " )
883
- #endif
884
-
898
+ #else
885
899
try await super. testAtMainSupport ( )
900
+ #endif
886
901
}
887
902
888
903
override func testAutomaticParseableInterfacesWithLibraryEvolution( ) async throws {
889
- throw XCTSkip ( " SWBINTTODO: The test fails because when the unsafe flag for a target is set to '-enable-library-evolution' it is not producing the correct .swiftinterface files. This needs to be investigated " )
904
+ try await fixture ( name: " Miscellaneous/LibraryEvolution " ) { fixturePath in
905
+ do {
906
+ let result = try await build ( [ ] , packagePath: fixturePath)
907
+ XCTAssertMatch (
908
+ result. moduleContents, [ . regex( #"A\.swiftmodule\/.*\.swiftinterface"# ) ] )
909
+ XCTAssertMatch ( result. moduleContents, [ . regex( #"B\.swiftmodule\/.*\.swiftmodule"# ) ] )
910
+ }
911
+ }
890
912
}
891
913
892
914
override func testImportOfMissedDepWarning( ) async throws {
@@ -901,10 +923,6 @@ class BuildCommandSwiftBuildTests: BuildCommandTestCases {
901
923
throw XCTSkip ( " SWBINTTODO: Test fails because the dummy-swiftc used in the test isn't accepted by swift-build. This needs to be investigated " )
902
924
}
903
925
904
- override func testBinSymlink( ) async throws {
905
- throw XCTSkip ( " SWBINTTODO: Test fails because of a difference in the build layout. This needs to be updated to the expected path " )
906
- }
907
-
908
926
override func testSymlink( ) async throws {
909
927
throw XCTSkip ( " SWBINTTODO: Test fails because of a difference in the build layout. This needs to be updated to the expected path " )
910
928
}
@@ -927,7 +945,7 @@ class BuildCommandSwiftBuildTests: BuildCommandTestCases {
927
945
928
946
override func testBuildSystemDefaultSettings( ) async throws {
929
947
#if os(Linux)
930
- if FileManager . default. contents ( atPath: " /etc/system-release " ) . map { String ( decoding: $0, as: UTF8 . self) == " Amazon Linux release 2 (Karoo) \n " } ?? false {
948
+ if FileManager . default. contents ( atPath: " /etc/system-release " ) . map ( { String ( decoding: $0, as: UTF8 . self) == " Amazon Linux release 2 (Karoo) \n " } ) ?? false {
931
949
throw XCTSkip ( " Skipping SwiftBuild testing on Amazon Linux because of platform issues. " )
932
950
}
933
951
#endif
@@ -941,9 +959,10 @@ class BuildCommandSwiftBuildTests: BuildCommandTestCases {
941
959
942
960
override func testBuildCompleteMessage( ) async throws {
943
961
#if os(Linux)
944
- try XCTSkip ( " SWBINTTODO: Need to properly set LD_LIBRARY_PATH on linux " )
945
- #endif
962
+ throw XCTSkip ( " SWBINTTODO: Need to properly set LD_LIBRARY_PATH on linux " )
963
+ #else
946
964
try await super. testBuildCompleteMessage ( )
965
+ #endif
947
966
}
948
967
949
968
}
0 commit comments