fix: repair nightly test failures for TestInitCancel_E2E and dolt autostart#2969
Conversation
…ostart TestInitCancel_E2E: The --contributor flag was rejected because isNonInteractiveInit() detected non-interactive mode (CI=true + piped stdin). Fix by supporting BD_NON_INTERACTIVE=0/false to explicitly force interactive mode, and set it in the test env. TestE2E_AutoStartedRepoLocalServerPersistsAcrossCommands: init defaulted to embedded mode since a35edfd, but the test needs server mode for dolt status/start/stop. Fix by adding --server to init args. Also adds unit tests for the new BD_NON_INTERACTIVE=0 override. Amp-Thread-ID: https://ampcode.com/threads/T-019d4f2d-9137-742b-bf44-ed413fe59cd0 Co-authored-by: Amp <amp@ampcode.com>
hilmes
left a comment
There was a problem hiding this comment.
Review: fix: repair nightly test failures for TestInitCancel_E2E and dolt autostart
Verdict: Clean, correct fix for two independent test failures. Ship it.
4 files, +27 −4. 1 commit. Two fixes: BD_NON_INTERACTIVE=0 override support (init.go, init_cancel_e2e_test.go, init_noninteractive_test.go) and --server flag for autostart lifecycle test (dolt_autostart_lifecycle_integration_test.go).
Fix 1: BD_NON_INTERACTIVE=0/false forces interactive mode
Root cause is clear. Commit 5e60961 added isNonInteractiveInit() which detects CI environments. TestInitCancel_E2E runs with --contributor, which line 119 rejects in non-interactive mode: FatalError("--contributor requires interactive prompts and cannot be used with --non-interactive"). The test never reaches the prompt it's waiting for.
The fix is correct and clean. The new logic:
if v := os.Getenv("BD_NON_INTERACTIVE"); v != "" {
if v == "1" || v == "true" { return true }
return false // explicit opt-in to interactive
}BD_NON_INTERACTIVE=0 enters the block (non-empty), doesn't match "1" or "true", and returns false — bypassing both CI detection and terminal detection. This is the right behavior: an explicit env var should take full precedence over heuristics.
Test env setup is thorough. The e2e test:
- Adds
BD_NON_INTERACTIVEandCIto thefilteredEnvstrip list (removes any inherited values) - Sets
BD_NON_INTERACTIVE=0(explicit interactive mode) - Sets
CI=(empty string, disables CI detection as a belt-and-suspenders measure)
Step 3 is technically redundant since BD_NON_INTERACTIVE=0 short-circuits before CI is checked, but it's good defensive practice — if the precedence logic ever changes, the test still works.
Unit tests cover both 0 and false variants with CI=true set, confirming the override works even when CI would otherwise trigger non-interactive mode. ✅
🟡 Minor: unrecognized values silently force interactive mode
With the new logic, BD_NON_INTERACTIVE=yes or BD_NON_INTERACTIVE=anything returns false (interactive), where previously these fell through to CI/terminal detection. This is a semantic change for non-standard values. Only "1"/"true"/"0"/"false" are documented, so this is unlikely to bite anyone in practice, but a log.Printf("warning: unrecognized BD_NON_INTERACTIVE value %q, treating as interactive override", v) would help debugging. Not blocking.
Fix 2: --server flag in autostart lifecycle test ✅
Trivially correct. Commit a35edfd changed the default backend mode from server to embedded. The lifecycle test exercises dolt status/dolt start/dolt stop — commands that only exist in server mode. Adding --server to the bd init call is the minimal, correct fix. The test was never testing embedded mode; it was testing server lifecycle management.
Summary
| Fix | Verdict | Notes |
|---|---|---|
BD_NON_INTERACTIVE=0 override |
✅ Clean | Correct precedence, good defensive test env setup |
--server in autostart test |
✅ Trivial | One-line fix, obviously correct |
No performance concerns. No new allocations or I/O in the hot path — isNonInteractiveInit is called once during init. Style is consistent with the existing codebase.
Summary
Two nightly integration tests have been failing on main for 5+ consecutive days.
TestInitCancel_E2E
Broken by 5e60961 which added
--non-interactiveauto-detection. The test runsbd init --contributorwith a piped stdin, butisNonInteractiveInit()detects non-interactive mode (CI=true + non-TTY stdin) and rejects the--contributorflag.Fix: Support
BD_NON_INTERACTIVE=0/falseto explicitly force interactive mode, overriding CI and terminal detection. The test sets this in its env.TestE2E_AutoStartedRepoLocalServerPersistsAcrossCommands
Broken by a35edfd which made embedded mode the default. The test needs server mode for
dolt status/start/stoplifecycle testing, but init now defaults to embedded mode where those commands aren't supported.Fix: Add
--serverflag to thebd initcall in the test.Changes
cmd/bd/init.go:isNonInteractiveInit()now treatsBD_NON_INTERACTIVE=0/falseas an explicit opt-in to interactive modecmd/bd/init_noninteractive_test.go: Added unit tests for the new override behaviorcmd/bd/init_cancel_e2e_test.go: SetBD_NON_INTERACTIVE=0and clearCIin test envcmd/bd/dolt_autostart_lifecycle_integration_test.go: Add--serverto init args