Skip to content

Commit f1d90db

Browse files
committed
utils: add support for testing self-hosted SPM
`-Test swiftpm` will use the self-hosted build of SPM to run the test suite. By using the `SWIFTCI_USE_LOCAL_DEPS=1` environment variable, we do reduce some of the cost of this by not recloning the repositories, but the entire dependency tree must be built a second time due to the switch in the build system.
1 parent a037974 commit f1d90db

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

utils/build.ps1

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,7 @@ function Build-SPMProject {
768768
[string] $Src,
769769
[string] $Bin,
770770
[hashtable] $Arch,
771+
[switch] $Test = $false,
771772
[Parameter(ValueFromRemainingArguments)]
772773
[string[]] $AdditionalArguments
773774
)
@@ -804,7 +805,8 @@ function Build-SPMProject {
804805
$Arguments += @("-debug-info-format", "none")
805806
}
806807

807-
Invoke-Program "$ToolchainInstallRoot\usr\bin\swift.exe" "build" @Arguments @AdditionalArguments
808+
$Action = if ($Test) { "test" } else { "build" }
809+
Invoke-Program "$ToolchainInstallRoot\usr\bin\swift.exe" $Action @Arguments @AdditionalArguments
808810
}
809811

810812
if (-not $ToBatch) {
@@ -1728,6 +1730,20 @@ function Build-DocC() {
17281730
}
17291731
}
17301732

1733+
function Test-PackageManager() {
1734+
$OutDir = Join-Path -Path $HostArch.BinaryCache -ChildPath swift-package-manager
1735+
1736+
Isolate-EnvVars {
1737+
$env:SWIFTCI_USE_LOCAL_DEPS=1
1738+
Build-SPMProject `
1739+
-Test `
1740+
-Src $SourceCache\swift-package-manager `
1741+
-Bin $OutDir `
1742+
-Arch $HostArch `
1743+
-Xcc -Xclang -Xcc -fno-split-cold-code -Xcc "-I$LibraryRoot\sqlite-3.43.2\usr\include" -Xlinker "-L$LibraryRoot\sqlite-3.43.2\usr\lib"
1744+
}
1745+
}
1746+
17311747
function Build-Installer($Arch) {
17321748
$Properties = @{
17331749
BundleFlavor = "offline";
@@ -1875,6 +1891,7 @@ if ($Test -contains "dispatch") { Build-Dispatch $HostArch -Test }
18751891
if ($Test -contains "foundation") { Build-Foundation $HostArch -Test }
18761892
if ($Test -contains "xctest") { Build-XCTest $HostArch -Test }
18771893
if ($Test -contains "llbuild") { Build-LLBuild $HostArch -Test }
1894+
if ($Test -contains "swiftpm") { Test-PackageManager $HostArch }
18781895

18791896
# Custom exception printing for more detailed exception information
18801897
} catch {

0 commit comments

Comments
 (0)