@@ -1440,6 +1440,63 @@ struct BuildCommandTestCases {
1440
1440
}
1441
1441
}
1442
1442
}
1443
+
1444
+ @Test ( . requireHostOS( . macOS) , arguments: SupportedBuildSystemOnPlatform)
1445
+ func buildingPackageWhichRequiresOlderDeploymentTarget( buildSystem: BuildSystemProvider . Kind ) async throws {
1446
+ // This fixture specifies a deployment target of macOS 12, and uses API obsoleted in macOS 13. The goal
1447
+ // of this test is to ensure that SwiftPM respects the deployment target specified in the package manifest
1448
+ // when passed no triple of an unversioned triple, rather than using the latests deployment target.
1449
+
1450
+ // No triple - build should pass
1451
+ try await fixture ( name: " Miscellaneous/RequiresOlderDeploymentTarget " ) { path in
1452
+ try await executeSwiftBuild (
1453
+ path,
1454
+ buildSystem: buildSystem,
1455
+ throwIfCommandFails: true
1456
+ )
1457
+ }
1458
+
1459
+ let hostArch : String
1460
+ #if arch(arm64)
1461
+ hostArch = " arm64 "
1462
+ #else
1463
+ hostArch = " x86_64 "
1464
+ #endif
1465
+
1466
+ // Unversioned triple - build should pass
1467
+ try await fixture ( name: " Miscellaneous/RequiresOlderDeploymentTarget " ) { path in
1468
+ try await executeSwiftBuild (
1469
+ path,
1470
+ extraArgs: [ " --triple " , " \( hostArch) -apple-macosx " ] ,
1471
+ buildSystem: buildSystem,
1472
+ throwIfCommandFails: true
1473
+ )
1474
+ }
1475
+
1476
+ // Versioned triple with supported deployment target - build should pass
1477
+ try await fixture ( name: " Miscellaneous/RequiresOlderDeploymentTarget " ) { path in
1478
+ try await executeSwiftBuild (
1479
+ path,
1480
+ extraArgs: [ " --triple " , " \( hostArch) -apple-macosx12.0 " ] ,
1481
+ buildSystem: buildSystem,
1482
+ throwIfCommandFails: true
1483
+ )
1484
+ }
1485
+
1486
+ if buildSystem == . swiftbuild {
1487
+ // Versioned triple with unsupported deployment target - build should fail
1488
+ try await fixture ( name: " Miscellaneous/RequiresOlderDeploymentTarget " ) { path in
1489
+ await #expect( throws: Error . self) {
1490
+ try await executeSwiftBuild (
1491
+ path,
1492
+ extraArgs: [ " --triple " , " \( hostArch) -apple-macosx14.0 " ] ,
1493
+ buildSystem: buildSystem,
1494
+ throwIfCommandFails: true
1495
+ )
1496
+ }
1497
+ }
1498
+ }
1499
+ }
1443
1500
}
1444
1501
1445
1502
extension Triple {
0 commit comments