mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-08-29 02:01:50 +08:00
fix(ci): run WSL2 contract tests via prebuilt binaries (#6472)
* ci: run WSL2 contract tests via prebuilt binaries link.exe/mt.exe fails to create manifests when TEMP points to a WSL UNC path (LNK1327). Run precompiled test binaries directly instead of re-invoking cargo, and explicitly set native TEMP during compilation. * ci: harden prebuilt WSL2 contract runner Keep the scheduled full-suite workflow unchanged until it can be validated independently. Drain Cargo's JSON stream before using the test binary and propagate its exit status. --------- Co-authored-by: saladday <1203511142@qq.com>
This commit is contained in:
@@ -205,15 +205,40 @@ jobs:
|
||||
|
||||
- name: Compile backend tests with native temp
|
||||
# link.exe/mt.exe cannot create manifests when TEMP points at a WSL UNC path.
|
||||
run: cargo test --lib --manifest-path src-tauri/Cargo.toml --no-run
|
||||
# Record the built test binary path so the run step below can execute
|
||||
# it directly instead of re-invoking cargo with TEMP on \\wsl.localhost.
|
||||
env:
|
||||
TEMP: ${{ runner.temp }}
|
||||
TMP: ${{ runner.temp }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
$testBinary = cargo test --lib --manifest-path src-tauri/Cargo.toml --no-run --message-format=json |
|
||||
ForEach-Object {
|
||||
if ($_ -match '"reason":"compiler-artifact"') {
|
||||
$artifact = $_ | ConvertFrom-Json
|
||||
if ($artifact.executable -and $artifact.profile.test -and $artifact.target.name -eq 'cc_switch_lib') {
|
||||
$artifact.executable
|
||||
}
|
||||
}
|
||||
} | Select-Object -First 1 -Wait
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
if (-not $testBinary) {
|
||||
throw "cc_switch_lib test binary not found in cargo compiler artifacts"
|
||||
}
|
||||
"CC_SWITCH_TEST_EXE=$testBinary" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
|
||||
- name: Run Windows-to-WSL2 filesystem contract
|
||||
# Run the test binary built in the previous step directly. Invoking cargo
|
||||
# here with TEMP pointing at a WSL UNC path can re-link the crate, and
|
||||
# link.exe/mt.exe cannot create manifest temp files on \\wsl.localhost.
|
||||
shell: pwsh
|
||||
run: |
|
||||
$env:TEMP = $env:CC_SWITCH_WSL_TEST_TEMP
|
||||
$env:TMP = $env:CC_SWITCH_WSL_TEST_TEMP
|
||||
$testName = "config::tests::atomic_write_replaces_existing_wsl_unc_file"
|
||||
$testList = cargo test --lib --manifest-path src-tauri/Cargo.toml -- --ignored --list
|
||||
$testList = & $env:CC_SWITCH_TEST_EXE --list --ignored
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
@@ -221,7 +246,7 @@ jobs:
|
||||
if ($testList -notcontains $expected) {
|
||||
throw "Expected ignored test was not discovered: $testName"
|
||||
}
|
||||
cargo test --lib --manifest-path src-tauri/Cargo.toml $testName -- --ignored --exact --nocapture
|
||||
& $env:CC_SWITCH_TEST_EXE $testName --ignored --exact --nocapture
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user