Skip to content

Commit 7a005bf

Browse files
authored
Merge pull request #77084 from ahoppen/sourcekit-lsp-tests
[Windows] Run SourceKit-LSP tests from build.ps1
2 parents 0bab6e3 + 88382de commit 7a005bf

File tree

2 files changed

+110
-8
lines changed

2 files changed

+110
-8
lines changed

utils/build-windows-toolchain.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ set TMPDIR=%BuildRoot%\tmp
6060
set NINJA_STATUS=[%%f/%%t][%%p][%%es]
6161

6262
:: Build the -Test argument, if any, by subtracting skipped tests
63-
set TestArg=-Test lld,swift,dispatch,foundation,xctest,swift-format,
63+
set TestArg=-Test lld,swift,dispatch,foundation,xctest,swift-format,sourcekit-lsp,
6464
for %%I in (%SKIP_TESTS%) do (call set TestArg=%%TestArg:%%I,=%%)
6565
if "%TestArg:~-1%"=="," (set TestArg=%TestArg:~0,-1%) else (set TestArg= )
6666

utils/build.ps1

Lines changed: 109 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,13 +1217,22 @@ function Build-CMakeProject {
12171217
}
12181218
}
12191219

1220+
enum SPMBuildAction {
1221+
# 'swift build'
1222+
Build
1223+
# 'swift test'
1224+
Test
1225+
# 'swift test --parallel'
1226+
TestParallel
1227+
}
1228+
12201229
function Build-SPMProject {
12211230
[CmdletBinding(PositionalBinding = $false)]
12221231
param(
1232+
[SPMBuildAction] $Action,
12231233
[string] $Src,
12241234
[string] $Bin,
12251235
[hashtable] $Arch,
1226-
[switch] $Test = $false,
12271236
[Parameter(ValueFromRemainingArguments)]
12281237
[string[]] $AdditionalArguments
12291238
)
@@ -1263,8 +1272,20 @@ function Build-SPMProject {
12631272
$Arguments += @("-debug-info-format", "none")
12641273
}
12651274

1266-
$Action = if ($Test) { "test" } else { "build" }
1267-
Invoke-Program "$($HostArch.ToolchainInstallRoot)\usr\bin\swift.exe" $Action @Arguments @AdditionalArguments
1275+
switch ($Action) {
1276+
Build {
1277+
$ActionName = "build"
1278+
}
1279+
Test {
1280+
$ActionName = "test"
1281+
}
1282+
TestParallel {
1283+
$ActionName = "test"
1284+
$Arguments += @("--parallel")
1285+
}
1286+
}
1287+
1288+
Invoke-Program "$($HostArch.ToolchainInstallRoot)\usr\bin\swift.exe" $ActionName @Arguments @AdditionalArguments
12681289
}
12691290

12701291
if (-not $ToBatch) {
@@ -1817,7 +1838,7 @@ function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
18171838
Isolate-EnvVars {
18181839
$env:SWIFTCI_USE_LOCAL_DEPS=1
18191840
Build-SPMProject `
1820-
-Test `
1841+
-Action Test `
18211842
-Src $SourceCache\swift-foundation `
18221843
-Bin $OutDir `
18231844
-Arch $HostArch
@@ -1835,7 +1856,7 @@ function Build-Foundation([Platform]$Platform, $Arch, [switch]$Test = $false) {
18351856
$env:CURL_LIBRARY_PATH="$LibraryRoot/curl-8.9.1/usr/lib/$Platform/$ShortArch"
18361857
$env:CURL_INCLUDE_PATH="$LibraryRoot/curl-8.9.1/usr/include"
18371858
Build-SPMProject `
1838-
-Test `
1859+
-Action Test `
18391860
-Src $SourceCache\swift-corelibs-foundation `
18401861
-Bin $OutDir `
18411862
-Arch $HostArch
@@ -2403,11 +2424,14 @@ function Test-Format {
24032424

24042425
Isolate-EnvVars {
24052426
$env:SWIFTFORMAT_BUILD_ONLY_TESTS=1
2427+
# Testing swift-format is faster in serial mode than in parallel mode, probably because parallel test execution
2428+
# launches a process for every test class and the process launching overhead on Windows is greater than any
2429+
# gains from parallel test execution.
24062430
Build-SPMProject `
2431+
-Action Test `
24072432
-Src "$SourceCache\swift-format" `
24082433
-Bin (Join-Path -Path $HostArch.BinaryCache -ChildPath swift-format) `
24092434
-Arch $HostArch `
2410-
-Test `
24112435
@SwiftPMArguments
24122436
}
24132437
}
@@ -2452,6 +2476,81 @@ function Build-SourceKitLSP($Arch) {
24522476
}
24532477
}
24542478

2479+
function Test-SourceKitLSP {
2480+
$SwiftPMArguments = @(
2481+
# swift-syntax
2482+
"-Xswiftc", "-I$(Get-HostProjectBinaryCache Compilers)\lib\swift\host",
2483+
"-Xswiftc", "-L$(Get-HostProjectBinaryCache Compilers)\lib\swift\host",
2484+
# swift-cmark
2485+
"-Xswiftc", "-I$($SourceCache)\cmark\src\include",
2486+
"-Xswiftc", "-I$($SourceCache)\cmark\extensions\include",
2487+
"-Xlinker", "-I$($SourceCache)\cmark\extensions\include",
2488+
"-Xlinker", "$(Get-CMark-BinaryCache($HostArch))\src\cmark-gfm.lib",
2489+
"-Xlinker", "$(Get-CMark-BinaryCache($HostArch))\extensions\cmark-gfm-extensions.lib",
2490+
# swift-system
2491+
"-Xswiftc", "-I$($SourceCache)\swift-system\Sources\CSystem\include",
2492+
"-Xswiftc", "-I$(Get-HostProjectBinaryCache System)\swift",
2493+
"-Xlinker", "-L$(Get-HostProjectBinaryCache System)\lib",
2494+
# swift-tools-support-core
2495+
"-Xswiftc", "-I$(Get-HostProjectBinaryCache ToolsSupportCore)\swift",
2496+
"-Xlinker", "-L$(Get-HostProjectBinaryCache ToolsSupportCore)\lib",
2497+
# swift-llbuild
2498+
"-Xswiftc", "-I$($SourceCache)\llbuild\products\libllbuild\include",
2499+
"-Xswiftc", "-I$(Get-HostProjectBinaryCache LLBuild)\products\llbuildSwift",
2500+
"-Xlinker", "-L$(Get-HostProjectBinaryCache LLBuild)\lib",
2501+
# swift-argument-parser
2502+
"-Xswiftc", "-I$(Get-HostProjectBinaryCache ArgumentParser)\swift",
2503+
"-Xlinker", "-L$(Get-HostProjectBinaryCache ArgumentParser)\lib",
2504+
# swift-crypto
2505+
"-Xswiftc", "-I$(Get-HostProjectBinaryCache Crypto)\swift",
2506+
"-Xlinker", "-L$(Get-HostProjectBinaryCache Crypto)\lib",
2507+
"-Xlinker", "$(Get-HostProjectBinaryCache Crypto)\lib\CCryptoBoringSSL.lib",
2508+
# swift-package-manager
2509+
"-Xswiftc", "-I$(Get-HostProjectBinaryCache PackageManager)\swift",
2510+
"-Xlinker", "-L$(Get-HostProjectBinaryCache PackageManager)\lib",
2511+
# swift-markdown
2512+
"-Xswiftc", "-I$($SourceCache)\swift-markdown\Sources\CAtomic\inclde",
2513+
"-Xlinker", "$(Get-HostProjectBinaryCache Markdown)\lib\CAtomic.lib",
2514+
"-Xswiftc", "-I$(Get-HostProjectBinaryCache Markdown)\swift",
2515+
"-Xlinker", "-L$(Get-HostProjectBinaryCache Markdown)\lib",
2516+
# swift-format
2517+
"-Xswiftc", "-I$(Get-HostProjectBinaryCache Format)\swift",
2518+
"-Xlinker", "-L$(Get-HostProjectBinaryCache Format)\lib",
2519+
# indexstore-db
2520+
"-Xswiftc", "-I$(Get-HostProjectBinaryCache IndexStoreDB)\swift",
2521+
"-Xlinker", "-L$(Get-HostProjectBinaryCache IndexStoreDB)\Sources\IndexStoreDB",
2522+
"-Xlinker", "$(Get-HostProjectBinaryCache IndexStoreDB)\lib\CIndexStoreDB\CIndexStoreDB.lib",
2523+
"-Xlinker", "$(Get-HostProjectBinaryCache IndexStoreDB)\lib\Core\Core.lib",
2524+
"-Xlinker", "$(Get-HostProjectBinaryCache IndexStoreDB)\lib\Database\Database.lib",
2525+
"-Xlinker", "$(Get-HostProjectBinaryCache IndexStoreDB)\lib\Index\Index.lib",
2526+
"-Xlinker", "$(Get-HostProjectBinaryCache IndexStoreDB)\lib\LLVMSupport\LLVMSupport.lib",
2527+
"-Xlinker", "$(Get-HostProjectBinaryCache IndexStoreDB)\lib\Support\Support.lib",
2528+
# sourcekit-lsp
2529+
"-Xswiftc", "-I$($SourceCache)\sourcekit-lsp\Sources\CAtomics\include",
2530+
"-Xswiftc", "-I$($SourceCache)\sourcekit-lsp\Sources\CSourcekitd\include",
2531+
"-Xlinker", "$(Get-HostProjectBinaryCache SourceKitLSP)\lib\CSourcekitd.lib",
2532+
"-Xswiftc", "-I$(Get-HostProjectBinaryCache SourceKitLSP)\swift",
2533+
"-Xlinker", "-L$(Get-HostProjectBinaryCache SourceKitLSP)\lib"
2534+
)
2535+
2536+
Isolate-EnvVars {
2537+
$env:SOURCEKIT_LSP_BUILD_ONLY_TESTS=1
2538+
2539+
# CI doesn't contain any sensitive information. Log everything.
2540+
$env:SOURCEKIT_LSP_LOG_PRIVACY_LEVEL="sensitive"
2541+
2542+
# Log with the highest log level to simplify debugging of CI failures.
2543+
$env:SOURCEKIT_LSP_LOG_LEVEL="debug"
2544+
2545+
Build-SPMProject `
2546+
-Action TestParallel `
2547+
-Src "$SourceCache\sourcekit-lsp" `
2548+
-Bin (Join-Path -Path $HostArch.BinaryCache -ChildPath sourcekit-lsp) `
2549+
-Arch $HostArch `
2550+
@SwiftPMArguments
2551+
}
2552+
}
2553+
24552554
function Build-TestingMacros() {
24562555
[CmdletBinding(PositionalBinding = $false)]
24572556
param
@@ -2534,6 +2633,7 @@ function Build-Inspect() {
25342633
Isolate-EnvVars {
25352634
$env:SWIFTCI_USE_LOCAL_DEPS=1
25362635
Build-SPMProject `
2636+
-Action Build `
25372637
-Src $SourceCache\swift\tools\swift-inspect `
25382638
-Bin $OutDir `
25392639
-Arch $HostArch `
@@ -2547,6 +2647,7 @@ function Build-DocC() {
25472647
Isolate-EnvVars {
25482648
$env:SWIFTCI_USE_LOCAL_DEPS=1
25492649
Build-SPMProject `
2650+
-Action Build `
25502651
-Src $SourceCache\swift-docc `
25512652
-Bin $OutDir `
25522653
-Arch $HostArch `
@@ -2565,7 +2666,7 @@ function Test-PackageManager() {
25652666
Isolate-EnvVars {
25662667
$env:SWIFTCI_USE_LOCAL_DEPS=1
25672668
Build-SPMProject `
2568-
-Test `
2669+
-Action Test `
25692670
-Src $SrcDir `
25702671
-Bin $OutDir `
25712672
-Arch $HostArch `
@@ -2783,6 +2884,7 @@ if (-not $IsCrossCompiling) {
27832884
if ($Test -contains "llbuild") { Build-LLBuild $HostArch -Test }
27842885
if ($Test -contains "swiftpm") { Test-PackageManager $HostArch }
27852886
if ($Test -contains "swift-format") { Test-Format }
2887+
if ($Test -contains "sourcekit-lsp") { Test-SourceKitLSP }
27862888
}
27872889

27882890
# Custom exception printing for more detailed exception information

0 commit comments

Comments
 (0)