@@ -19,7 +19,10 @@ import _InternalTestSupport
1919import Workspace
2020import Testing
2121
22+ import struct SPMBuildCore. BuildSystemProvider
23+
2224@Suite (
25+ . serialized, // crash occurs when executed in parallel. needs investigation
2326 . tags(
2427 . FunctionalArea. ModuleMaps,
2528 ) ,
@@ -29,14 +32,15 @@ struct ModuleMapsTestCase {
2932 name: String ,
3033 cModuleName: String ,
3134 rootpkg: String ,
35+ buildSystem: BuildSystemProvider . Kind ,
3236 config: BuildConfiguration ,
3337 body: @escaping ( AbsolutePath , [ String ] ) async throws -> Void
3438 ) async throws {
3539 try await fixture ( name: name) { fixturePath in
3640 let input = fixturePath. appending ( components: cModuleName, " C " , " foo.c " )
37- let triple = try UserToolchain . default. targetTriple
38- let outdir = fixturePath. appending ( components: rootpkg, " .build " , triple. platformBuildPathComponent, " \( config) " )
41+ let outdir = try fixturePath. appending ( components: [ rootpkg] + buildSystem. binPath ( for: config) )
3942 try makeDirectories ( outdir)
43+ let triple = try UserToolchain . default. targetTriple
4044 let output = outdir. appending ( " libfoo \( triple. dynamicLibraryExtension) " )
4145 try await AsyncProcess . checkNonZeroExit ( args: executableName ( " clang " ) , " -shared " , input. pathString, " -o " , output. pathString)
4246
@@ -50,53 +54,67 @@ struct ModuleMapsTestCase {
5054 }
5155
5256 @Test (
53- arguments: BuildConfiguration . allCases ,
57+ arguments: getBuildData ( for : SupportedBuildSystemOnAllPlatforms ) ,
5458 )
5559 func directDependency(
56- configuration : BuildConfiguration ,
60+ buildData : BuildData ,
5761 ) async throws {
62+ let configuration = buildData. config
63+ let buildSystem = buildData. buildSystem
5864 try await withKnownIssue ( isIntermittent: true ) {
59- try await localFixture ( name: " ModuleMaps/Direct " , cModuleName: " CFoo " , rootpkg: " App " , config: configuration) { fixturePath, Xld in
60- await #expect( throws: Never . self) {
61- try await executeSwiftBuild (
62- fixturePath. appending ( " App " ) ,
63- configuration: configuration,
64- Xld: Xld,
65- buildSystem: . native,
66- )
67- }
65+ try await localFixture (
66+ name: " ModuleMaps/Direct " ,
67+ cModuleName: " CFoo " ,
68+ rootpkg: " App " ,
69+ buildSystem: buildSystem,
70+ config: configuration,
71+ ) { fixturePath, Xld in
72+ try await executeSwiftBuild (
73+ fixturePath. appending ( " App " ) ,
74+ configuration: configuration,
75+ Xld: Xld,
76+ buildSystem: buildSystem,
77+ )
6878
69- let triple = try UserToolchain . default . targetTriple
79+ let executable = try fixturePath . appending ( components : [ " App " ] + buildSystem . binPath ( for : configuration ) + [ " App " ] )
7080 let releaseout = try await AsyncProcess . checkNonZeroExit (
71- args: fixturePath . appending ( components : " App " , " .build " , triple . platformBuildPathComponent , " \( configuration ) " , " App " ) . pathString
81+ args: executable . pathString
7282 )
7383 #expect( releaseout == " 123 \n " )
7484 }
7585 } when: {
7686 ProcessInfo . hostOperatingSystem == . windows
87+ || ( buildSystem == . swiftbuild && configuration == . release)
7788 }
7889 }
7990
8091 @Test (
81- arguments: BuildConfiguration . allCases,
92+ . serialized, // crash occurs when executed in parallel. needs investigation
93+ arguments: getBuildData ( for: SupportedBuildSystemOnAllPlatforms) ,
8294 )
8395 func transitiveDependency(
84- configuration : BuildConfiguration ,
96+ buildData : BuildData ,
8597 ) async throws {
98+ let configuration = buildData. config
99+ let buildSystem = buildData. buildSystem
86100 try await withKnownIssue ( isIntermittent: true ) {
87- try await localFixture ( name: " ModuleMaps/Transitive " , cModuleName: " packageD " , rootpkg: " packageA " , config: configuration) { fixturePath, Xld in
88- await #expect( throws: Never . self) {
89- try await executeSwiftBuild (
90- fixturePath. appending ( " packageA " ) ,
91- configuration: configuration,
92- Xld: Xld,
93- buildSystem: . native,
94- )
95- }
101+ try await localFixture (
102+ name: " ModuleMaps/Transitive " ,
103+ cModuleName: " packageD " ,
104+ rootpkg: " packageA " ,
105+ buildSystem: buildSystem,
106+ config: configuration,
107+ ) { fixturePath, Xld in
108+ try await executeSwiftBuild (
109+ fixturePath. appending ( " packageA " ) ,
110+ configuration: configuration,
111+ Xld: Xld,
112+ buildSystem: buildSystem,
113+ )
96114
97- let triple = try UserToolchain . default . targetTriple
115+ let executable = try fixturePath . appending ( components : [ " packageA " ] + buildSystem . binPath ( for : configuration ) + [ " packageA " ] )
98116 let out = try await AsyncProcess . checkNonZeroExit (
99- args: fixturePath . appending ( components : " packageA " , " .build " , triple . platformBuildPathComponent , " \( configuration ) " , " packageA " ) . pathString
117+ args: executable . pathString
100118 )
101119 #expect( out == """
102120 calling Y.bar()
@@ -108,6 +126,7 @@ struct ModuleMapsTestCase {
108126 }
109127 } when: {
110128 ProcessInfo . hostOperatingSystem == . windows
129+ || ( buildSystem == . swiftbuild && configuration == . release)
111130 }
112131 }
113132}
0 commit comments