提交记录修改internal/cage/storage_test.go+5 −0看文件
修改scripts/ci-windows-build.ps1+17 −5看文件
| @@ -5,7 +5,9 @@ import ( | ||
| 5 | 5 | "context" |
| 6 | 6 | "os" |
| 7 | 7 | "path/filepath" |
| 8 | 新增: "runtime" | |
| 8 | 9 | "strconv" |
| 10 | 新增: "strings" | |
| 9 | 11 | "testing" |
| 10 | 12 | ) |
| 11 | 13 | |
| @@ -200,6 +202,9 @@ func TestStorageAcrossMountedVolume(t *testing.T) { | ||
| 200 | 202 | t.Fatal(err) |
| 201 | 203 | } |
| 202 | 204 | t.Cleanup(func() { os.RemoveAll(testDir) }) |
| 205 | 新增: if runtime.GOOS == "windows" && strings.EqualFold(filepath.VolumeName(profile), filepath.VolumeName(testDir)) { | |
| 206 | 新增: t.Fatal("CAGE_TEST_STORAGE_VOLUME must be on a different drive from the temporary profile") | |
| 207 | 新增: } | |
| 203 | 208 | data := make([]byte, 2<<20) |
| 204 | 209 | copy(data[len(data)-32:], []byte("second volume")) |
| 205 | 210 | rel := filepath.Join("lima", "guest", "disk") |
| @@ -13,6 +13,8 @@ $certificates = @() | ||
| 13 | 13 | $qemuSource = $null |
| 14 | 14 | $savedPath = $env:PATH |
| 15 | 15 | $savedCertificate = $env:CAGE_WINDOWS_CERT_SHA1 |
| 16 | 新增:$savedStorageVolume = $env:CAGE_TEST_STORAGE_VOLUME | |
| 17 | 新增:$storageTestRoot = $null | |
| 16 | 18 | try { |
| 17 | 19 | $actual = (& git rev-parse HEAD).Trim() |
| 18 | 20 | if ($LASTEXITCODE -ne 0 -or $actual -ne $env:CAGE_BUILD_REF) { throw 'Checkout differs from the requested commit.' } |
| @@ -66,13 +68,21 @@ try { | ||
| 66 | 68 | '-GuestToolsDirectory', "$repository/_output/windows-amd64/app/resources/guest-os") |
| 67 | 69 | } |
| 68 | 70 | Invoke-BuildTool 'dotnet' @('run', '--project', 'desktop/windows.tests/Cage.Windows.Tests.csproj') |
| 71 | 新增: # RUNNER_TEMP and the checkout share D: on hosted runners. Use a | |
| 72 | 新增: # unique system-drive directory, outside user data, for the other side. | |
| 73 | 新增: if (-not $env:CAGE_TEST_STORAGE_VOLUME) { | |
| 74 | 新增: $systemDrive = [IO.Path]::GetPathRoot($env:SystemRoot) | |
| 75 | 新增: $testDrive = [IO.Path]::GetPathRoot((Get-WindowsWorkbenchTestBase)) | |
| 76 | 新增: if ($systemDrive -ne $testDrive) { | |
| 77 | 新增: $storageTestRoot = (New-Item -ItemType Directory -Path (Join-Path $systemDrive ('cage-storage-volume-' + [guid]::NewGuid().ToString('N')))).FullName | |
| 78 | 新增: $env:CAGE_TEST_STORAGE_VOLUME = $storageTestRoot | |
| 79 | 新增: Write-Host "Storage migration tests use separate drives: $testDrive -> $systemDrive" | |
| 80 | 新增: } else { | |
| 81 | 新增: Write-Warning 'No second test volume is configured; the cross-volume storage test will be skipped.' | |
| 82 | 新增: } | |
| 83 | 新增: } | |
| 69 | 84 | Invoke-InIsolatedTestTemp { |
| 70 | 85 | Invoke-BuildTool 'go' @('test', './internal/workbench', './internal/appupdate', './internal/host', './internal/managedproxy', './internal/env', './internal/paths', './internal/mounts') |
| 71 | 删除: # Exercise a second volume when the runner keeps its workspace and temp on different drives. | |
| 72 | 删除: if ($env:GITHUB_WORKSPACE -and -not $env:CAGE_TEST_STORAGE_VOLUME -and | |
| 73 | 删除: [IO.Path]::GetPathRoot($env:GITHUB_WORKSPACE) -ne [IO.Path]::GetPathRoot([IO.Path]::GetTempPath())) { | |
| 74 | 删除: $env:CAGE_TEST_STORAGE_VOLUME = $env:GITHUB_WORKSPACE | |
| 75 | 删除: } | |
| 76 | 86 | Invoke-BuildTool 'go' @('test', './internal/cage', '-run', 'Test(Storage|Gate|ProxyRevision|ConfigChange|JobStop|CONNECT|SOCKS|DNS|RejectHostLAN|Credentials|ProxyHostname|SafetyReport|Renew)') |
| 77 | 87 | Invoke-BuildTool 'go' @('test', './internal/vm', '-run', 'Test(NetworkConfined|WindowsQEMUIdentity)') |
| 78 | 88 | Invoke-BuildTool 'go' @('test', 'github.com/lima-vm/lima/v2/pkg/driver/qemu', '-run', 'Test(WindowsFirmwareArgument|WindowsPackagedFirmwareBeatsOldUserCopy|WHPXQEMU64Features|WindowsCPUResolution)$') |
| @@ -101,6 +111,8 @@ try { | ||
| 101 | 111 | # Verified QEMU sources remain in the build cache; packaging copies them separately. |
| 102 | 112 | $env:PATH = $savedPath |
| 103 | 113 | $env:CAGE_WINDOWS_CERT_SHA1 = $savedCertificate |
| 114 | 新增: $env:CAGE_TEST_STORAGE_VOLUME = $savedStorageVolume | |
| 115 | 新增: if ($storageTestRoot) { Remove-Item -LiteralPath $storageTestRoot -Recurse -Force -ErrorAction SilentlyContinue } | |
| 104 | 116 | Remove-Item Env:CAGE_ESIGNER_PASSWORD, Env:CAGE_ESIGNER_TOTP_SECRET -ErrorAction SilentlyContinue |
| 105 | 117 | Pop-Location |
| 106 | 118 | } |

