Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/e2e/windows/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ func buildImage(t *testing.T, ctx context.Context, repoRoot, image, platform, ba
// runOne starts one long-lived container per combo and drives the whole
// E2E flow (setup -> install -> verify) through pwsh exec calls, asserting
// in Go. A combo passes when every phase exits 0 and the outputs carry the
// expected markers. vfox main combos run against a VFOX_HOME containing a
// space (see vfoxHome).
// expected markers. Every combo runs against a VFOX_HOME containing a
// space (see spacedVfoxHome).
func runOne(t *testing.T, ctx context.Context, image, platform, arch string, c common.Combo) {
t.Helper()
prefix := c.Prefix(platform)
Expand Down Expand Up @@ -181,7 +181,7 @@ func runOne(t *testing.T, ctx context.Context, image, platform, arch string, c c
procArch := procArchOfContainer(ctx, t, ctr)
t.Logf("=== vfox %s, java@%s, %s (%s) ===", c.Vfox, common.Spec(c.Distribution, version), platform, procArch)

box := setupSlotEnv(ctx, t, ctr, c.Slug(), c.Vfox)
box := setupSlotEnv(ctx, t, ctr, c.Slug())
setupVfox(ctx, t, ctr, box, c.Vfox)
checkMissingVersionRejected(ctx, t, ctr, box, c.Distribution, version, arch)

Expand Down
20 changes: 1 addition & 19 deletions tests/e2e/windows/matrix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@

package windows

import (
"strings"
"testing"
)
import "testing"

func TestMaxJobsDefault(t *testing.T) {
t.Setenv("E2E_MAX_JOBS", "")
Expand All @@ -31,21 +28,6 @@ func TestMaxJobsDefault(t *testing.T) {
}
}

func TestVfoxHome(t *testing.T) {
profile := `C:\Users\ContainerAdministrator`
if got, want := vfoxHome(profile, "latest-tem", "latest"),
`C:\Users\ContainerAdministrator\vfox-e2e-runs\latest-tem\.vfox`; got != want {
t.Errorf("vfoxHome(latest) = %q, want %q", got, want)
}
got := vfoxHome(profile, "main-tem", "main")
if got != spacedVfoxHome {
t.Errorf("vfoxHome(main) = %q, want %q", got, spacedVfoxHome)
}
if !strings.Contains(got, " ") {
t.Errorf("vfoxHome(main) = %q, want a path containing a space", got)
}
}

func TestPwshQuote(t *testing.T) {
if got := pwshQuote(`C:\a\b`); got != `'C:\a\b'` {
t.Errorf("pwshQuote = %q", got)
Expand Down
21 changes: 6 additions & 15 deletions tests/e2e/windows/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,6 @@ const (
spacedVfoxHome = `C:\Users\John Doe\.vfox`
)

// vfoxHome returns the $VFOX_HOME for a combo. The fix for Windows homes
// containing a space (https://github.com/version-fox/vfox/pull/712) is on
// vfox main only: released builds still fail on such paths, so only main
// runs against spacedVfoxHome while the others keep an unspaced slot home.
func vfoxHome(userProfile, slot, vfoxVersion string) string {
if vfoxVersion == "main" {
return spacedVfoxHome
}
return userProfile + `\vfox-e2e-runs\` + slot + `\.vfox`
}

// pwshQuote renders a single-quoted PowerShell string literal.
func pwshQuote(s string) string {
return "'" + strings.ReplaceAll(s, "'", "''") + "'"
Expand All @@ -69,15 +58,17 @@ type slotBox struct {
}

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

home := vfoxHome(userProfile, slot, vfoxVersion)
home := spacedVfoxHome
box := slotBox{slot: slot}
box.slotRoot = userProfile + `\vfox-e2e-runs\` + slot
box.tmp = box.slotRoot + `\tmp`
Expand Down
Loading