carlos / platform Public

e2e: isolate the route fixture and remaining migrate/secrets helpers

The routeTestFixture family (~20 tests) and four run helpers still
built subprocess envs straight from os.Environ() with cwd in the real
checkout. Same scrub as the rest: HOME and CARLOS_CONSOLE overridden,
cmd.Dir in scratch.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KxXEWoRXU8WVTXjTJypuJ5
Paul Campbell a94384d3689f2f5bae6a4dc5b2af4fe65d584c07 parent 5af2e30
1 file changed, +32 −6
  • e2e_test.go +32 −6
diff --git a/e2e_test.go b/e2e_test.go
index b146aaa60..7639c96f0 100644
--- a/e2e_test.go
+++ b/e2e_test.go
@@ -915,11 +915,16 @@ func TestAccountsMigrateTakesTheLiveObjects(t *testing.T) {
}
env := append(os.Environ(),
"CARLOS_DEPLOYMENT_DIR="+storeDir,
- "CARLOS_RELEASE_PUBKEY="+pubB64)
+ "CARLOS_RELEASE_PUBKEY="+pubB64,
+ "HOME="+tmp,
+ "CARLOS_CONSOLE=",
+ )
run := func(args ...string) (string, error) {
t.Helper()
cmd := exec.Command(carlosBin, args...)
cmd.Env = env
+ // pick() walks cwd ancestors for .carlos/config, so the subprocess must not run from the real checkout.
+ cmd.Dir = tmp
out, err := cmd.CombinedOutput()
return string(out), err
}
@@ -1069,11 +1074,16 @@ func TestAccountsMigrateConvergesADivergedPointer(t *testing.T) {
}
env := append(os.Environ(),
"CARLOS_DEPLOYMENT_DIR="+storeDir,
- "CARLOS_RELEASE_PUBKEY="+pubB64)
+ "CARLOS_RELEASE_PUBKEY="+pubB64,
+ "HOME="+tmp,
+ "CARLOS_CONSOLE=",
+ )
run := func(args ...string) (string, error) {
t.Helper()
cmd := exec.Command(carlosBin, args...)
cmd.Env = env
+ // pick() walks cwd ancestors for .carlos/config, so the subprocess must not run from the real checkout.
+ cmd.Dir = tmp
out, err := cmd.CombinedOutput()
return string(out), err
}
@@ -1265,11 +1275,16 @@ func TestAccountsMigrateLegacyIntoOps(t *testing.T) {
}
env := append(os.Environ(),
"CARLOS_DEPLOYMENT_DIR="+storeDir,
- "CARLOS_RELEASE_PUBKEY="+pubB64)
+ "CARLOS_RELEASE_PUBKEY="+pubB64,
+ "HOME="+tmp,
+ "CARLOS_CONSOLE=",
+ )
run := func(args ...string) (string, error) {
t.Helper()
cmd := exec.Command(carlosBin, args...)
cmd.Env = env
+ // pick() walks cwd ancestors for .carlos/config, so the subprocess must not run from the real checkout.
+ cmd.Dir = tmp
out, err := cmd.CombinedOutput()
return string(out), err
}
@@ -1433,11 +1448,16 @@ func TestSecretsCLI(t *testing.T) {
}
storeDir := filepath.Join(tmp, "store")
regPath := filepath.Join(tmp, "registry.db")
- baseEnv := os.Environ()
+ baseEnv := append(os.Environ(),
+ "HOME="+tmp,
+ "CARLOS_CONSOLE=",
+ )
run := func(env []string, args ...string) string {
t.Helper()
cmd := exec.Command(carlosBin, args...)
cmd.Env = env
+ // pick() walks cwd ancestors for .carlos/config, so the subprocess must not run from the real checkout.
+ cmd.Dir = tmp
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("carlos %s: %v\n%s", strings.Join(args, " "), err, out)
@@ -2140,6 +2160,7 @@ type routeTestFixture struct {
bin string
storeDir string
regPath string
+ tmpDir string
store release.Store
priv ed25519.PrivateKey
pubB64 string
@@ -2169,7 +2190,7 @@ func newRouteTestFixture(t *testing.T) *routeTestFixture {
}
return &routeTestFixture{
t: t, bin: bin, storeDir: storeDir, regPath: filepath.Join(tmp, "registry.db"),
- store: release.NewDirStore(storeDir), priv: priv, pubB64: pubB64,
+ tmpDir: tmp, store: release.NewDirStore(storeDir), priv: priv, pubB64: pubB64,
}
}
@@ -2180,6 +2201,8 @@ func (f *routeTestFixture) run(env []string, args ...string) (string, error) {
f.t.Helper()
cmd := exec.Command(f.bin, args...)
cmd.Env = env
+ // pick() walks cwd ancestors for .carlos/config, so the subprocess must not run from the real checkout.
+ cmd.Dir = f.tmpDir
out, err := cmd.CombinedOutput()
return string(out), err
}
@@ -2187,7 +2210,10 @@ func (f *routeTestFixture) run(env []string, args ...string) (string, error) {
func (f *routeTestFixture) fullEnv() []string {
return append(os.Environ(),
"CARLOS_DEPLOYMENT_DIR="+f.storeDir,
- "CARLOS_RELEASE_PUBKEY="+f.pubB64)
+ "CARLOS_RELEASE_PUBKEY="+f.pubB64,
+ "HOME="+f.tmpDir,
+ "CARLOS_CONSOLE=",
+ )
}
func (f *routeTestFixture) ship(acct, app, version string) {