Skip to content

fix: repair nightly test failures for TestInitCancel_E2E and dolt autostart#2969

Merged
maphew merged 1 commit into
gastownhall:mainfrom
maphew:fix/nightly-test-failures
Apr 2, 2026
Merged

fix: repair nightly test failures for TestInitCancel_E2E and dolt autostart#2969
maphew merged 1 commit into
gastownhall:mainfrom
maphew:fix/nightly-test-failures

Conversation

@maphew

@maphew maphew commented Apr 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

Two nightly integration tests have been failing on main for 5+ consecutive days.

TestInitCancel_E2E

Broken by 5e60961 which added --non-interactive auto-detection. The test runs bd init --contributor with a piped stdin, but isNonInteractiveInit() detects non-interactive mode (CI=true + non-TTY stdin) and rejects the --contributor flag.

Fix: Support BD_NON_INTERACTIVE=0/false to 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/stop lifecycle testing, but init now defaults to embedded mode where those commands aren't supported.

Fix: Add --server flag to the bd init call in the test.

Changes

  • cmd/bd/init.go: isNonInteractiveInit() now treats BD_NON_INTERACTIVE=0/false as an explicit opt-in to interactive mode
  • cmd/bd/init_noninteractive_test.go: Added unit tests for the new override behavior
  • cmd/bd/init_cancel_e2e_test.go: Set BD_NON_INTERACTIVE=0 and clear CI in test env
  • cmd/bd/dolt_autostart_lifecycle_integration_test.go: Add --server to init args

…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 hilmes left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. Adds BD_NON_INTERACTIVE and CI to the filteredEnv strip list (removes any inherited values)
  2. Sets BD_NON_INTERACTIVE=0 (explicit interactive mode)
  3. 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.

@maphew maphew merged commit ba46bd5 into gastownhall:main Apr 2, 2026
31 checks passed
@maphew maphew deleted the fix/nightly-test-failures branch April 2, 2026 18:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants