@@ -152,15 +152,15 @@ private struct SwiftPMTests {
152152 }
153153 }
154154
155- @Test ( . requireHostOS( . macOS) )
156- func testArchCustomization( ) async throws {
155+ @Test ( . requireHostOS( . macOS) , arguments : [ BuildSystemProvider . Kind . native , . swiftbuild ] )
156+ func testArchCustomization( buildSystem : BuildSystemProvider . Kind ) async throws {
157157 try await withTemporaryDirectory { tmpDir in
158158 let packagePath = tmpDir. appending ( component: " foo " )
159159 try localFileSystem. createDirectory ( packagePath)
160160 try await executeSwiftPackage (
161161 packagePath,
162162 extraArgs: [ " init " , " --type " , " executable " ] ,
163- buildSystem: . native ,
163+ buildSystem: buildSystem ,
164164 )
165165 // delete any files generated
166166 for entry in try localFileSystem. getDirectoryContents (
@@ -181,36 +181,61 @@ private struct SwiftPMTests {
181181 try await executeSwiftBuild (
182182 packagePath,
183183 extraArgs: [ " --arch " , arch] ,
184- buildSystem: . native,
185- )
186- let fooPath = try AbsolutePath (
187- validating: " .build/ \( arch) -apple-macosx/debug/foo " ,
188- relativeTo: packagePath
184+ buildSystem: buildSystem,
189185 )
186+ let fooPath : AbsolutePath
187+ switch buildSystem {
188+ case . native:
189+ fooPath = try AbsolutePath (
190+ validating: " .build/ \( arch) -apple-macosx/debug/foo " ,
191+ relativeTo: packagePath
192+ )
193+ case . swiftbuild:
194+ fooPath = try AbsolutePath (
195+ validating: " .build/ \( arch) -apple-macosx/Products/Debug/foo " ,
196+ relativeTo: packagePath
197+ )
198+ default :
199+ preconditionFailure ( " Unsupported backend: \( buildSystem) " )
200+ }
190201 #expect( localFileSystem. exists ( fooPath) )
202+ // Check the product has the expected slice
203+ #expect( try sh ( " /usr/bin/file " , fooPath. pathString) . stdout. contains ( arch) )
191204 }
192205
193- // let args =
194- // [swiftBuild.pathString, "--package-path", packagePath.pathString]
195- // + archs.flatMap { ["--arch", $0] }
196206 try await executeSwiftBuild (
197207 packagePath,
198208 extraArgs: archs. flatMap { [ " --arch " , $0] } ,
199- buildSystem: . native ,
209+ buildSystem: buildSystem ,
200210 )
201211
202- let fooPath = try AbsolutePath (
203- validating: " .build/apple/Products/Debug/foo " , relativeTo: packagePath
204- )
212+ let fooPath : AbsolutePath
213+ let hostArch : String
214+ #if arch(x86_64)
215+ hostArch = " x86_64 "
216+ #elseif arch(arm64)
217+ hostArch = " arm64 "
218+ #else
219+ precondition ( " Unsupported platform or host arch for test " )
220+ #endif
221+ switch buildSystem {
222+ case . native:
223+ fooPath = try AbsolutePath (
224+ validating: " .build/apple/Products/Debug/foo " , relativeTo: packagePath
225+ )
226+ case . swiftbuild:
227+ fooPath = try AbsolutePath (
228+ validating: " .build/ \( hostArch) -apple-macosx/Products/Debug/foo " ,
229+ relativeTo: packagePath
230+ )
231+ default :
232+ preconditionFailure ( " Unsupported backend: \( buildSystem) " )
233+ }
205234 #expect( localFileSystem. exists ( fooPath) )
206-
207- let objectsDir = try AbsolutePath (
208- validating:
209- " .build/apple/Intermediates.noindex/foo.build/Debug/foo.build/Objects-normal " ,
210- relativeTo: packagePath
211- )
235+ // Check the product has the expected slices
236+ let fileOutput = try sh ( " /usr/bin/file " , fooPath. pathString) . stdout
212237 for arch in archs {
213- #expect( localFileSystem . isDirectory ( objectsDir . appending ( component : arch) ) )
238+ #expect( fileOutput . contains ( arch) )
214239 }
215240 }
216241 }
0 commit comments