nikivdev/code · error

Commit blocked by testing gate

Error message

Commit blocked by testing gate

What it means

apply_testing_gate_failure centralizes testing-gate enforcement: it prints the violation message and, when mode == "block", bails so the commit is aborted. In "warn" mode it only prints a warning and returns Ok. The pre-commit test gate uses this to block commits that fail required tests.

Source

Thrown at src/commit.rs:3677

            ));
            continue;
        }

        if strict_bun_repo && !cmd.contains("bun bd test") {
            violations.push(format!(
                "task '{}' must use `bun bd test` in Bun repo: {}",
                task.name, task.command
            ));
        }
    }

    violations
}

fn apply_testing_gate_failure(mode: &str, message: &str) -> Result<()> {
    eprintln!("  testing: {}", message);
    if mode == "block" {
        bail!("Commit blocked by testing gate");
    }
    eprintln!("  testing: warning only (mode=warn)");
    Ok(())
}

fn run_pre_commit_test_gate(
    repo_root: &Path,
    changed_files: &[String],
    gate_overrides: CommitGateOverrides,
) -> Result<()> {
    if gate_overrides.skip_quality || gate_overrides.skip_tests {
        if gate_overrides.skip_tests {
            println!("Skipping test gate due to --skip-tests");
        }
        return Ok(());
    }

    let policy = resolve_commit_testing_policy(repo_root);

View on GitHub (pinned to a747e741ae)

Solutions

  1. Run the project's test suite locally, fix failures, then commit again.
  2. Check the printed `testing: <message>` line to see exactly which test/requirement failed.
  3. Ensure the test toolchain is installed and runnable in your environment.
  4. For known-flaky tests, stabilize or quarantine them rather than disabling the gate.

Example fix

// before: commit attempted with failing test
$ commit -m "wip"
// testing: test parse_config failed
// after fixing
$ cargo test -- parse_config // green
$ commit -m "wip" // passes gate
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the test suite is green before attempting a gated commit
let ok = Command::new("cargo").args(["test"]).status()?.success();
if !ok { return Err("tests must pass before committing (testing gate mode=block)".into()); }

Try / catch

if let Err(e) = commit_flow() {
    if e.to_string().contains("Commit blocked by testing gate") {
        eprintln!("run the test suite, fix the failure shown in 'testing: ...', retry");
    } else { return Err(e.into()); }
}

Prevention

When it happens

Trigger: Committing while the pre-commit test gate (run_pre_commit_test_gate) detects violations — failing or missing required tests — with gate mode configured to "block".

Common situations: Committing with a red test suite; tests not yet written for new code where policy requires them; flaky tests failing in the pre-commit run; test runner unavailable in the environment (missing toolchain/CI deps).

Related errors


AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01). Data as JSON: /api/errors/c0622ed116035f4e. Report an issue: GitHub.