Skip to content

Commit 494dd5d

Browse files
authored
test: run every Windows e2e combo against a VFOX_HOME containing a space (#82)
1 parent a9c3ab8 commit 494dd5d

3 files changed

Lines changed: 10 additions & 37 deletions

File tree

‎tests/e2e/windows/e2e_test.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ func buildImage(t *testing.T, ctx context.Context, repoRoot, image, platform, ba
132132
// runOne starts one long-lived container per combo and drives the whole
133133
// E2E flow (setup -> install -> verify) through pwsh exec calls, asserting
134134
// in Go. A combo passes when every phase exits 0 and the outputs carry the
135-
// expected markers. vfox main combos run against a VFOX_HOME containing a
136-
// space (see vfoxHome).
135+
// expected markers. Every combo runs against a VFOX_HOME containing a
136+
// space (see spacedVfoxHome).
137137
func runOne(t *testing.T, ctx context.Context, image, platform, arch string, c common.Combo) {
138138
t.Helper()
139139
prefix := c.Prefix(platform)
@@ -181,7 +181,7 @@ func runOne(t *testing.T, ctx context.Context, image, platform, arch string, c c
181181
procArch := procArchOfContainer(ctx, t, ctr)
182182
t.Logf("=== vfox %s, java@%s, %s (%s) ===", c.Vfox, common.Spec(c.Distribution, version), platform, procArch)
183183

184-
box := setupSlotEnv(ctx, t, ctr, c.Slug(), c.Vfox)
184+
box := setupSlotEnv(ctx, t, ctr, c.Slug())
185185
setupVfox(ctx, t, ctr, box, c.Vfox)
186186
checkMissingVersionRejected(ctx, t, ctr, box, c.Distribution, version, arch)
187187

‎tests/e2e/windows/matrix_test.go‎

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414

1515
package windows
1616

17-
import (
18-
"strings"
19-
"testing"
20-
)
17+
import "testing"
2118

2219
func TestMaxJobsDefault(t *testing.T) {
2320
t.Setenv("E2E_MAX_JOBS", "")
@@ -31,21 +28,6 @@ func TestMaxJobsDefault(t *testing.T) {
3128
}
3229
}
3330

34-
func TestVfoxHome(t *testing.T) {
35-
profile := `C:\Users\ContainerAdministrator`
36-
if got, want := vfoxHome(profile, "latest-tem", "latest"),
37-
`C:\Users\ContainerAdministrator\vfox-e2e-runs\latest-tem\.vfox`; got != want {
38-
t.Errorf("vfoxHome(latest) = %q, want %q", got, want)
39-
}
40-
got := vfoxHome(profile, "main-tem", "main")
41-
if got != spacedVfoxHome {
42-
t.Errorf("vfoxHome(main) = %q, want %q", got, spacedVfoxHome)
43-
}
44-
if !strings.Contains(got, " ") {
45-
t.Errorf("vfoxHome(main) = %q, want a path containing a space", got)
46-
}
47-
}
48-
4931
func TestPwshQuote(t *testing.T) {
5032
if got := pwshQuote(`C:\a\b`); got != `'C:\a\b'` {
5133
t.Errorf("pwshQuote = %q", got)

‎tests/e2e/windows/setup.go‎

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,6 @@ const (
3939
spacedVfoxHome = `C:\Users\John Doe\.vfox`
4040
)
4141

42-
// vfoxHome returns the $VFOX_HOME for a combo. The fix for Windows homes
43-
// containing a space (https://github.com/version-fox/vfox/pull/712) is on
44-
// vfox main only: released builds still fail on such paths, so only main
45-
// runs against spacedVfoxHome while the others keep an unspaced slot home.
46-
func vfoxHome(userProfile, slot, vfoxVersion string) string {
47-
if vfoxVersion == "main" {
48-
return spacedVfoxHome
49-
}
50-
return userProfile + `\vfox-e2e-runs\` + slot + `\.vfox`
51-
}
52-
5342
// pwshQuote renders a single-quoted PowerShell string literal.
5443
func pwshQuote(s string) string {
5544
return "'" + strings.ReplaceAll(s, "'", "''") + "'"
@@ -69,15 +58,17 @@ type slotBox struct {
6958
}
7059

7160
// setupSlotEnv isolates the combo: USERPROFILE/TEMP/TMP point under
72-
// vfox-e2e-runs\<slot>, while VFOX_HOME is a sibling .vfox (spacedVfoxHome
73-
// for main), so parallel combos on one daemon never share vfox state.
74-
func setupSlotEnv(ctx context.Context, t *testing.T, ctr tc.Container, slot, vfoxVersion string) slotBox {
61+
// vfox-e2e-runs\<slot>, while VFOX_HOME is spacedVfoxHome. Each combo runs in
62+
// its own container, so the shared VFOX_HOME never leaks between combos. Both
63+
// vfox main and releases since v1.0.13 handle a home containing a space
64+
// (https://github.com/version-fox/vfox/pull/712).
65+
func setupSlotEnv(ctx context.Context, t *testing.T, ctr tc.Container, slot string) slotBox {
7566
t.Helper()
7667
userProfile := strings.TrimSpace(execOK(ctx, t, ctr, "$env:USERPROFILE"))
7768
containerPath := strings.TrimSpace(execOK(ctx, t, ctr, "$env:PATH"))
7869
procArch := strings.TrimSpace(execOK(ctx, t, ctr, "$env:PROCESSOR_ARCHITECTURE"))
7970

80-
home := vfoxHome(userProfile, slot, vfoxVersion)
71+
home := spacedVfoxHome
8172
box := slotBox{slot: slot}
8273
box.slotRoot = userProfile + `\vfox-e2e-runs\` + slot
8374
box.tmp = box.slotRoot + `\tmp`

0 commit comments

Comments
 (0)