Adds --raw to config-get workflow.build_command|test_command reads in the post-merge, regression, verify-phase, and audit-fix gates so an unset key is a genuinely empty string, not the literal "" — restoring the auto-detect cascade and graceful skip instead of a false exit-127 failure. Regression guard sweeps all four gate files. Fixes #2350.
This commit is contained in:
@@ -91,3 +91,43 @@ describe('#1857: test gates normalize to one-shot and bound with a timeout', ()
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// #2350: `config-get KEY --default ""` WITHOUT `--raw` prints the JSON-encoded
|
||||
// empty string (the 2-byte literal `""`) for an unset key, so a `[ -z "$CMD" ]`
|
||||
// guard sees a non-empty string, SKIPS the whole Makefile/Cargo/go/npm/…
|
||||
// auto-detection cascade, and runs the literal `""` as a command → exit 127,
|
||||
// reported as a false build/test failure on any repo with no override and no
|
||||
// detectable tooling (docs-only / planning-only repos, or any repo before its
|
||||
// first build file). Every gate that resolves a build/test command this way MUST
|
||||
// pass `--raw` so an unset key is a genuinely empty bash string the `-z` guard
|
||||
// catches. This is a defect CLASS — post-merge-gate.md was the reported instance,
|
||||
// but regression-gate.md, verify-phase.md, and audit-fix.md shared it, so the
|
||||
// guard sweeps all of them (a single-file check gave false confidence). config-get's
|
||||
// own `--raw` behaviour is covered in config-get-default.test.cjs.
|
||||
describe('#2350: every gate resolves build/test commands with --raw', () => {
|
||||
// Each gate file that reads workflow.build_command / workflow.test_command to
|
||||
// build a shell command it then runs. Add new gates here as they appear.
|
||||
const GATE_FILES = [
|
||||
['post-merge gate', POST_MERGE_GATE],
|
||||
['regression gate', REGRESSION_GATE],
|
||||
['verify-phase gate', VERIFY_PHASE],
|
||||
['audit-fix gate', AUDIT_FIX],
|
||||
];
|
||||
|
||||
for (const [label, file] of GATE_FILES) {
|
||||
test(`${label}: no build/test_command config-get line is left without --raw`, () => {
|
||||
const lines = read(file)
|
||||
.split('\n')
|
||||
.filter((l) => /config-get\s+workflow\.(build|test)_command\s+--default\s+""/.test(l));
|
||||
// The gate must actually resolve a command this way (guards against the file
|
||||
// being renamed/refactored out from under this test without notice).
|
||||
assert.ok(lines.length > 0, `${label} (${path.basename(file)}) should resolve a build/test command via config-get`);
|
||||
const offending = lines.filter((l) => !/--raw/.test(l));
|
||||
assert.deepStrictEqual(
|
||||
offending,
|
||||
[],
|
||||
`${label}: every build/test_command config-get must pass --raw so an unset key is empty, not the literal ""; offending: ${offending.join(' | ')}`,
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user