@soleur/opencode 3.357.15 → 3.357.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/affected-tests.sh +117 -16
- package/scripts/affected-tests.test.sh +581 -2
- package/scripts/collision-precheck.sh +141 -0
- package/scripts/lib/affected-tests/common.sh +20 -3
- package/scripts/lib/affected-tests/content-trigger.sh +248 -0
- package/skills/plan/SKILL.md +7 -5
- package/skills/review/SKILL.md +17 -18
- package/skills/ship/SKILL.md +6 -5
- package/skills/ship/references/affected-gate-contract.md +60 -3
- package/skills/work/SKILL.md +22 -26
|
@@ -690,7 +690,8 @@ reset_fakes() {
|
|
|
690
690
|
export FAKE_TURBO_RC=0 FAKE_TURBO_EXPECT=""
|
|
691
691
|
export FAKE_RUNNER_RC=0 FAKE_RUNNER_AFFECTED_RC="" FAKE_RUNNER_FULL_RC=""
|
|
692
692
|
export FAKE_PM_TEST_RC=0
|
|
693
|
-
export FAKE_GIT_FAIL_OTHERS=0
|
|
693
|
+
export FAKE_GIT_FAIL_OTHERS=0 FAKE_GIT_FAIL_VERB=""
|
|
694
|
+
export FAKE_CT_RC=0 FAKE_CT_SLEEP="" FAKE_CT_NOLEDGER=0
|
|
694
695
|
}
|
|
695
696
|
|
|
696
697
|
RSEQ=0; RC=0; OUT=""
|
|
@@ -1282,6 +1283,14 @@ GITFAILBIN="$TESTROOT/bin-gitfail"; mkdir -p "$GITFAILBIN"
|
|
|
1282
1283
|
ln -sf "$BIN"/* "$GITFAILBIN/"
|
|
1283
1284
|
cat > "$GITFAILBIN/git" <<'SHIM'
|
|
1284
1285
|
#!/usr/bin/env bash
|
|
1286
|
+
if [[ -n "${FAKE_GIT_FAIL_VERB:-}" ]]; then
|
|
1287
|
+
for _a in "$@"; do
|
|
1288
|
+
if [[ "$_a" == "$FAKE_GIT_FAIL_VERB" ]]; then
|
|
1289
|
+
echo "stub git: simulated $FAKE_GIT_FAIL_VERB failure" >&2
|
|
1290
|
+
exit 1
|
|
1291
|
+
fi
|
|
1292
|
+
done
|
|
1293
|
+
fi
|
|
1285
1294
|
if [[ "${FAKE_GIT_FAIL_OTHERS:-0}" == "1" ]]; then
|
|
1286
1295
|
_ls=0; _oth=0
|
|
1287
1296
|
for _a in "$@"; do
|
|
@@ -1757,6 +1766,574 @@ else
|
|
|
1757
1766
|
fi
|
|
1758
1767
|
unset _f _hits _head _PORT_FILES port_hits _BANNED _allsrc _h _golist_unb
|
|
1759
1768
|
|
|
1769
|
+
# ====================== Guard 4 — content trigger (#10924 P4b) ==================
|
|
1770
|
+
# A config-declared string, ADDED to a file under configured globs, makes a passing
|
|
1771
|
+
# selected/inert run also run a configured command. Every "ran" claim below is
|
|
1772
|
+
# asserted against the invocation ledger (the `ctcmd` line the stub appends), never
|
|
1773
|
+
# against an exit code alone, and every marker row pins the WHOLE line. The pattern
|
|
1774
|
+
# is a synthesized `zz-marker/` so nothing here is hard-coded to this repository.
|
|
1775
|
+
|
|
1776
|
+
CT_PAT='zz-marker/'
|
|
1777
|
+
CT_RUN='AFFECTED_GATE ran=- of=- skipped=- mode=selected reason=delegated stack=runner ci=none'
|
|
1778
|
+
|
|
1779
|
+
write_ct_cmd() { # <repo> — logs `ctcmd seq=<ledger line>`; honours FAKE_CT_RC / _SLEEP / _NOLEDGER
|
|
1780
|
+
mkdir -p "$1/scripts"
|
|
1781
|
+
cat > "$1/scripts/ct-cmd.sh" <<'CT'
|
|
1782
|
+
#!/usr/bin/env bash
|
|
1783
|
+
[[ "${FAKE_CT_NOLEDGER:-0}" == 1 ]] || printf 'ctcmd\tseq=%s\n' "$(( $(wc -l < "${FAKE_LOG:?}") + 1 ))" >> "$FAKE_LOG"
|
|
1784
|
+
[[ -z "${FAKE_CT_SLEEP:-}" ]] || sleep "$FAKE_CT_SLEEP"
|
|
1785
|
+
exit "${FAKE_CT_RC:-0}"
|
|
1786
|
+
CT
|
|
1787
|
+
cat > "$1/scripts/other-cmd.sh" <<'CT'
|
|
1788
|
+
#!/usr/bin/env bash
|
|
1789
|
+
printf 'otherctcmd\n' >> "${FAKE_LOG:?}"
|
|
1790
|
+
exit 0
|
|
1791
|
+
CT
|
|
1792
|
+
chmod +x "$1/scripts/ct-cmd.sh" "$1/scripts/other-cmd.sh"
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
ct_cfg() { # <paths-json> [pattern] [command] [extra-json-members]
|
|
1796
|
+
printf '{"content_trigger_pattern":"%s","content_trigger_paths":%s,"content_trigger_command":"%s"%s}' \
|
|
1797
|
+
"${2:-$CT_PAT}" "$1" "${3:-bash scripts/ct-cmd.sh}" "${4:-}"
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1800
|
+
# mk_ct_repo <name> <paths-json> [pattern] [command] [extra] — delegated-runner repo with
|
|
1801
|
+
# the trigger armed. Config, command stubs and a base test file that ALREADY names the
|
|
1802
|
+
# pattern are all committed in BASE, so only the rows' own changes are in the diff.
|
|
1803
|
+
mk_ct_repo() {
|
|
1804
|
+
local r; r="$(mk_repo "$1" "${CT_BRANCH:-main}")"
|
|
1805
|
+
write_runner_capable "$r"; write_ct_cmd "$r"
|
|
1806
|
+
write_config "$r" "$(ct_cfg "$2" "${3:-$CT_PAT}" "${4:-bash scripts/ct-cmd.sh}" "${5:-}")"
|
|
1807
|
+
mkdir -p "$r/tests"
|
|
1808
|
+
printf 'l1\n%s present\nl3\n' "$CT_PAT" > "$r/tests/base.test.sh"
|
|
1809
|
+
[[ "${CT_WITH_CI:-0}" == 1 ]] && seed_ci "$r"
|
|
1810
|
+
seal_base "$r"
|
|
1811
|
+
printf '%s' "$r"
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
ct_seq() { sed -n "/^$1/{=;q}" "$CALLS"; } # <ledger-prefix> -> first ledger line number
|
|
1815
|
+
want_marker() { # <label> <exact AFFECTED_GATE line>
|
|
1816
|
+
local got; got="$(sed -n 's/^.*\(AFFECTED_GATE ran=.*\)$/\1/p' <<<"$OUT" | tail -n 1)"
|
|
1817
|
+
if [[ "$got" == "$2" ]]; then pass "$1"
|
|
1818
|
+
else fail "$1 — marker '$got' want '$2'"; fi
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
# T1 [M1]: a committed file under a glob adds the pattern → the command runs, after the
|
|
1822
|
+
# runner, and the marker names it.
|
|
1823
|
+
R_T1="$(mk_ct_repo ct1 '["tests/*"]')"
|
|
1824
|
+
commit_chg "$R_T1" tests/new.test.sh "added $CT_PAT here"
|
|
1825
|
+
reset_fakes; run_gate "$R_T1" gate
|
|
1826
|
+
want_rc 0 "T1: a firing diff passes"
|
|
1827
|
+
want_call "T1: the runner ran" 'test-all --affected'
|
|
1828
|
+
want_call "T1: the content-trigger command ran (ledger)" '^ctcmd '
|
|
1829
|
+
want_marker "T1: whole marker line carries content_trigger=ran" "$CT_RUN content_trigger=ran"
|
|
1830
|
+
_rl="$(ct_seq 'test-all')"; _cl="$(ct_seq 'ctcmd')"
|
|
1831
|
+
if [[ -n "$_rl" && -n "$_cl" ]] && (( _rl < _cl )); then
|
|
1832
|
+
pass "T1/M3: the command ran AFTER the primary run (ledger sequence $_rl < $_cl)"
|
|
1833
|
+
else
|
|
1834
|
+
fail "T1/M3: ordering broken — runner line '$_rl', command line '$_cl'"
|
|
1835
|
+
fi
|
|
1836
|
+
unset _rl _cl
|
|
1837
|
+
|
|
1838
|
+
# T2 [M2]: two changed files; the first is clean, the SECOND matches — a scan that
|
|
1839
|
+
# stops at the first compliant file would miss it.
|
|
1840
|
+
R_T2="$(mk_ct_repo ct2 '["tests/*"]')"
|
|
1841
|
+
commit_chg "$R_T2" tests/a-clean.test.sh 'nothing to see'
|
|
1842
|
+
commit_chg "$R_T2" tests/b-hit.test.sh "x $CT_PAT y"
|
|
1843
|
+
reset_fakes; run_gate "$R_T2" gate
|
|
1844
|
+
want_call "T2: the second changed file fires the trigger" '^ctcmd '
|
|
1845
|
+
want_marker "T2: marker" "$CT_RUN content_trigger=ran"
|
|
1846
|
+
|
|
1847
|
+
# T3 [M8]: a NEW UNTRACKED file with the pattern fires (a typical in-progress fixture).
|
|
1848
|
+
R_T3="$(mk_ct_repo ct3 '["tests/*"]')"
|
|
1849
|
+
chg "$R_T3" tests/untracked.test.sh "u $CT_PAT"
|
|
1850
|
+
reset_fakes; run_gate "$R_T3" gate
|
|
1851
|
+
want_call "T3: an untracked file under the globs fires the trigger" '^ctcmd '
|
|
1852
|
+
want_marker "T3: marker" "$CT_RUN content_trigger=ran"
|
|
1853
|
+
|
|
1854
|
+
# T4 [M4]: the pattern is already in the file; an unrelated line is added ADJACENT to
|
|
1855
|
+
# it. A scan of whole files, or with context lines, would fire — the added line must be
|
|
1856
|
+
# the only text that counts.
|
|
1857
|
+
R_T4="$(mk_ct_repo ct4 '["tests/*"]')"
|
|
1858
|
+
printf 'l1\n%s present\nNEW unrelated line\nl3\n' "$CT_PAT" > "$R_T4/tests/base.test.sh"
|
|
1859
|
+
assert_fixture_dir "$R_T4"; git -C "$R_T4" add -A; git -C "$R_T4" commit -q -m "adjacent"
|
|
1860
|
+
reset_fakes; run_gate "$R_T4" gate
|
|
1861
|
+
want_no_call "T4: a pre-existing mention does not fire" '^ctcmd '
|
|
1862
|
+
want_marker "T4: marker says clear" "$CT_RUN content_trigger=clear"
|
|
1863
|
+
|
|
1864
|
+
# T5 [M5]: no resolvable base → the scan cannot decide → the command RUNS.
|
|
1865
|
+
R_T5="$(mk_repo ct5)"; write_runner_capable "$R_T5"; write_ct_cmd "$R_T5"
|
|
1866
|
+
write_config "$R_T5" "$(ct_cfg '["tests/*"]')"; mkdir -p "$R_T5/tests"; printf 'base\n' > "$R_T5/tests/base.test.sh"
|
|
1867
|
+
assert_fixture_dir "$R_T5"; git -C "$R_T5" add -A; git -C "$R_T5" commit -q -m base; git -C "$R_T5" checkout -q -b feature
|
|
1868
|
+
commit_chg "$R_T5" tests/x.test.sh 'no pattern at all'
|
|
1869
|
+
reset_fakes; run_gate "$R_T5" gate
|
|
1870
|
+
want_rc 0 "T5: an undecidable scan still passes when the command passes"
|
|
1871
|
+
want_call "T5: the command ran although the scan could not decide" '^ctcmd '
|
|
1872
|
+
want_marker "T5: marker names scan-error" "$CT_RUN content_trigger=scan-error"
|
|
1873
|
+
want_out "T5: the undecided leg is named" 'content-trigger scan could not decide \(leg=no-base\)'
|
|
1874
|
+
|
|
1875
|
+
# T6 [M6]: the command's own failure is the gate's failure.
|
|
1876
|
+
R_T6="$(mk_ct_repo ct6 '["tests/*"]')"
|
|
1877
|
+
commit_chg "$R_T6" tests/new.test.sh "$CT_PAT"
|
|
1878
|
+
reset_fakes; export FAKE_CT_RC=1; run_gate "$R_T6" gate
|
|
1879
|
+
want_rc 1 "T6: a failing command fails the gate"
|
|
1880
|
+
want_marker "T6: whole marker line" "AFFECTED_GATE ran=- of=- skipped=- mode=selected reason=content-trigger-failed stack=runner ci=none content_trigger=failed"
|
|
1881
|
+
want_out "T6: the failure is named on stdout with its rc" '^CONTENT_TRIGGER_FAILED rc=1$'
|
|
1882
|
+
want_out "T6: and a remedy points at the config key" 'remedy: run the content_trigger_command'
|
|
1883
|
+
|
|
1884
|
+
# T7 [M3]: a failing PRIMARY run skips the command (ledger proves it) and says so.
|
|
1885
|
+
R_T7="$(mk_ct_repo ct7 '["tests/*"]')"
|
|
1886
|
+
commit_chg "$R_T7" tests/new.test.sh "$CT_PAT"
|
|
1887
|
+
reset_fakes; export FAKE_RUNNER_RC=1; run_gate "$R_T7" gate
|
|
1888
|
+
want_rc 1 "T7: a failing primary run fails the gate"
|
|
1889
|
+
want_no_call "T7: the command did not run behind a failed primary" '^ctcmd '
|
|
1890
|
+
want_marker "T7: marker says skipped" "AFFECTED_GATE ran=- of=- skipped=- mode=selected reason=failed stack=runner ci=none content_trigger=skipped"
|
|
1891
|
+
|
|
1892
|
+
# T8: the pattern added OUTSIDE the globs does not fire.
|
|
1893
|
+
R_T8="$(mk_ct_repo ct8 '["tests/*"]')"
|
|
1894
|
+
commit_chg "$R_T8" src/outside.sh "$CT_PAT"
|
|
1895
|
+
reset_fakes; run_gate "$R_T8" gate
|
|
1896
|
+
want_no_call "T8: a changed file outside the globs does not fire" '^ctcmd '
|
|
1897
|
+
want_marker "T8: marker says clear" "$CT_RUN content_trigger=clear"
|
|
1898
|
+
|
|
1899
|
+
# T9 [M7]: a LARGE untracked file (many SHORT lines — one 300 KB line does not reproduce it)
|
|
1900
|
+
# naming the pattern on its first line. Read through a pipe under pipefail, grep -q's early exit SIGPIPEs the producer and the hit reads as a
|
|
1901
|
+
# miss; the scan reads the file directly.
|
|
1902
|
+
R_T9="$(mk_ct_repo ct9 '["tests/*"]')"
|
|
1903
|
+
{ printf '%s\n' "$CT_PAT"; yes 'filler line of text' | head -n 40000; } > "$R_T9/tests/big.test.sh"
|
|
1904
|
+
reset_fakes; run_gate "$R_T9" gate
|
|
1905
|
+
want_call "T9: a >64 KB untracked file with an early hit fires" '^ctcmd '
|
|
1906
|
+
want_marker "T9: and the scan DECIDED (ran, not scan-error: an undecided scan also runs the command)" "$CT_RUN content_trigger=ran"
|
|
1907
|
+
|
|
1908
|
+
# T10 [M9]: nothing here ADDS text containing the pattern, so none may fire:
|
|
1909
|
+
# (a) a path that names it; (b) a diff that only REMOVES the line naming it; (c) a pure
|
|
1910
|
+
# rename of a file that names it.
|
|
1911
|
+
R_T10A="$(mk_ct_repo ct10a '["tests/*"]')"
|
|
1912
|
+
commit_chg "$R_T10A" "tests/${CT_PAT}hello.txt" 'plain content'
|
|
1913
|
+
reset_fakes; run_gate "$R_T10A" gate
|
|
1914
|
+
want_no_call "T10a: a path naming the pattern does not fire" '^ctcmd '
|
|
1915
|
+
R_T10B="$(mk_ct_repo ct10b '["tests/*"]')"
|
|
1916
|
+
assert_fixture_dir "$R_T10B"; printf 'l1\nl3\n' > "$R_T10B/tests/base.test.sh"; git -C "$R_T10B" add -A; git -C "$R_T10B" commit -q -m "removal"
|
|
1917
|
+
reset_fakes; run_gate "$R_T10B" gate
|
|
1918
|
+
want_no_call "T10b: a removal-only diff does not fire" '^ctcmd '
|
|
1919
|
+
R_T10C="$(mk_ct_repo ct10c '["tests/*"]')"
|
|
1920
|
+
assert_fixture_dir "$R_T10C"; git -C "$R_T10C" mv tests/base.test.sh tests/renamed.test.sh; git -C "$R_T10C" commit -q -m "rename"
|
|
1921
|
+
reset_fakes; run_gate "$R_T10C" gate
|
|
1922
|
+
want_call "T10c: a rename of a file that names the string fires (--no-renames: delete plus add)" '^ctcmd '
|
|
1923
|
+
|
|
1924
|
+
# T11 [M10]: the exits that are not a selected verdict never run the command, and
|
|
1925
|
+
# --explain reports without running anything.
|
|
1926
|
+
R_T11="$(mk_ct_repo ct11 '["tests/*"]')"
|
|
1927
|
+
commit_chg "$R_T11" tests/new.test.sh "$CT_PAT"
|
|
1928
|
+
reset_fakes; run_gate "$R_T11" selfcheck --self-check
|
|
1929
|
+
want_no_call "T11: --self-check never runs the command" '^ctcmd '
|
|
1930
|
+
reset_fakes; run_gate "$R_T11" explain --explain
|
|
1931
|
+
want_rc 0 "T11: --explain exits 0"
|
|
1932
|
+
want_out "T11: --explain reports the armed trigger and its state" '^CONTENT_TRIGGER armed=1 state=fired paths=1$'
|
|
1933
|
+
want_no_call "T11: --explain never runs the command" '^ctcmd '
|
|
1934
|
+
reset_fakes; run_gate "$R_T11" gate --full
|
|
1935
|
+
want_no_call "T11: --full never runs the command" '^ctcmd '
|
|
1936
|
+
want_no_out "T11: a --full marker carries no content_trigger field" 'content_trigger='
|
|
1937
|
+
R_T11B="$(mk_ct_repo ct11b '["tests/*"]' "$CT_PAT" 'bash scripts/ct-cmd.sh' ',"test_command":"bash scripts/other-cmd.sh"')"
|
|
1938
|
+
reset_fakes; run_gate "$R_T11B" explain --explain
|
|
1939
|
+
want_no_out "T11: the test_command explain arm prints no CONTENT_TRIGGER line" 'CONTENT_TRIGGER'
|
|
1940
|
+
|
|
1941
|
+
# T12: the budget bounds the command. With a CI workflow the deferral is rc 6; with none
|
|
1942
|
+
# the command's own expiry exit (124) is a plain failure.
|
|
1943
|
+
R_T12="$(CT_WITH_CI=1 mk_ct_repo ct12 '["tests/*"]' "$CT_PAT" 'bash scripts/ct-cmd.sh' ',"budget_seconds":2')"
|
|
1944
|
+
commit_chg "$R_T12" tests/new.test.sh "$CT_PAT"
|
|
1945
|
+
reset_fakes; export FAKE_CT_SLEEP=6; run_gate "$R_T12" gate
|
|
1946
|
+
want_rc 6 "T12: the budget expiring inside the command defers (CI detected)"
|
|
1947
|
+
want_out "T12: the deferral marker prints" 'AFFECTED_GATE_BUDGET_DEFERRED'
|
|
1948
|
+
want_marker "T12: the command started and timed out: field is deferred, not skipped" "AFFECTED_GATE ran=- of=- skipped=- mode=selected reason=budget-deferred stack=runner ci=.github/workflows/ci.yml content_trigger=deferred"
|
|
1949
|
+
R_T12C="$(CT_WITH_CI=1 mk_ct_repo ct12c '["tests/*"]' "$CT_PAT" 'bash scripts/ct-cmd.sh' ',"budget_seconds":60')"
|
|
1950
|
+
commit_chg "$R_T12C" tests/new.test.sh "$CT_PAT"
|
|
1951
|
+
reset_fakes; run_gate "$R_T12C" gate
|
|
1952
|
+
want_rc 0 "T12: the same CI repo without the sleep passes (the budget, not the CI, caused the deferral)"
|
|
1953
|
+
want_marker "T12: and reports ran" "AFFECTED_GATE ran=- of=- skipped=- mode=selected reason=delegated stack=runner ci=.github/workflows/ci.yml content_trigger=ran"
|
|
1954
|
+
R_T12B="$(mk_ct_repo ct12b '["tests/*"]')"
|
|
1955
|
+
commit_chg "$R_T12B" tests/new.test.sh "$CT_PAT"
|
|
1956
|
+
reset_fakes; export FAKE_CT_RC=124; run_gate "$R_T12B" gate
|
|
1957
|
+
want_rc 1 "T12: an expiry-shaped exit without a CI workflow is a plain failure"
|
|
1958
|
+
|
|
1959
|
+
# T13: config errors are refused, each naming the key.
|
|
1960
|
+
ct_bad() { # <name> <json> <ere>
|
|
1961
|
+
local r; r="$(mk_cfg_repo "$1" "$2")"
|
|
1962
|
+
reset_fakes; run_gate "$r" gate
|
|
1963
|
+
want_rc 4 "T13: $1 refused"
|
|
1964
|
+
want_out "T13: $1 names the cause" "$3"
|
|
1965
|
+
}
|
|
1966
|
+
ct_bad ct13-nopaths '{"content_trigger_pattern":"x/"}' 'bad-config key=content_trigger_paths'
|
|
1967
|
+
ct_bad ct13-nocmd '{"content_trigger_pattern":"x/","content_trigger_paths":["tests/*"]}' 'bad-config key=content_trigger_command'
|
|
1968
|
+
ct_bad ct13-nopattern '{"content_trigger_paths":["tests/*"],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_pattern'
|
|
1969
|
+
ct_bad ct13-emptypaths '{"content_trigger_pattern":"x/","content_trigger_paths":[],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_paths'
|
|
1970
|
+
ct_bad ct13-all '{"content_trigger_pattern":"x/","content_trigger_paths":["*"],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_paths'
|
|
1971
|
+
ct_bad ct13-deepall '{"content_trigger_pattern":"x/","content_trigger_paths":["**/*"],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_paths'
|
|
1972
|
+
ct_bad ct13-vacuous '{"content_trigger_pattern":"x/","content_trigger_paths":["tests/*"],"content_trigger_command":"true"}' 'bad-config key=content_trigger_command'
|
|
1973
|
+
ct_bad ct13-emptypat '{"content_trigger_pattern":"","content_trigger_paths":["tests/*"],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_pattern'
|
|
1974
|
+
ct_bad ct13-nlpat '{"content_trigger_pattern":"a\nb","content_trigger_paths":["tests/*"],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_pattern'
|
|
1975
|
+
ct_bad ct13-numpat '{"content_trigger_pattern":3,"content_trigger_paths":["tests/*"],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_pattern'
|
|
1976
|
+
ct_bad ct13-strpaths '{"content_trigger_pattern":"x/","content_trigger_paths":"tests/*","content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_paths'
|
|
1977
|
+
ct_bad ct13-dotslash '{"content_trigger_pattern":"x/","content_trigger_paths":["./tests/*"],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_paths'
|
|
1978
|
+
ct_bad ct13-abs '{"content_trigger_pattern":"x/","content_trigger_paths":["/tests/*"],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_paths'
|
|
1979
|
+
ct_bad ct13-trailslash '{"content_trigger_pattern":"x/","content_trigger_paths":["tests/"],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_paths'
|
|
1980
|
+
ct_bad ct13-secondall '{"content_trigger_pattern":"x/","content_trigger_paths":["tests/*","*"],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_paths'
|
|
1981
|
+
ct_bad ct13-emptyglob '{"content_trigger_pattern":"x/","content_trigger_paths":["tests/*",""],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_paths'
|
|
1982
|
+
ct_bad ct13-arrcmd '{"content_trigger_pattern":"x/","content_trigger_paths":["tests/*"],"content_trigger_command":["bash"]}' 'bad-config key=content_trigger_command'
|
|
1983
|
+
|
|
1984
|
+
# T14: a path with a space and a non-ASCII character, under a repo whose diff config
|
|
1985
|
+
# strips or rewrites prefixes, fires; the hook honours --base while defaulting to
|
|
1986
|
+
# origin/main.
|
|
1987
|
+
R_T14="$(mk_ct_repo ct14 '["tests/*"]')"
|
|
1988
|
+
assert_fixture_dir "$R_T14"; git -C "$R_T14" config diff.noprefix true
|
|
1989
|
+
assert_fixture_dir "$R_T14"; git -C "$R_T14" config diff.mnemonicPrefix true
|
|
1990
|
+
_b0="$(git -C "$R_T14" rev-parse origin/main)"
|
|
1991
|
+
commit_chg "$R_T14" 'tests/dir with space/é.test.sh' "$CT_PAT"
|
|
1992
|
+
reset_fakes; run_gate "$R_T14" gate
|
|
1993
|
+
want_call "T14: a spaced, non-ASCII path fires despite diff.noprefix/mnemonicPrefix" '^ctcmd '
|
|
1994
|
+
assert_fixture_dir "$R_T14"; git -C "$R_T14" update-ref refs/remotes/origin/main HEAD
|
|
1995
|
+
reset_fakes; run_gate "$R_T14" gate
|
|
1996
|
+
want_no_call "T14: with origin/main at HEAD nothing is pending" '^ctcmd '
|
|
1997
|
+
reset_fakes; run_gate "$R_T14" gate --base "$_b0"
|
|
1998
|
+
want_call "T14: --base steers the scan" '^ctcmd '
|
|
1999
|
+
unset _b0
|
|
2000
|
+
|
|
2001
|
+
# T15: the inert path. A docs-only diff that nonetheless names the pattern runs the
|
|
2002
|
+
# command and no longer claims "docs-only"; without the pattern it still does.
|
|
2003
|
+
mk_inert_ct_repo() { # <name>
|
|
2004
|
+
local r; r="$(mk_repo "$1")"; seed_js "$r"; write_ct_cmd "$r"
|
|
2005
|
+
write_config "$r" "$(ct_cfg '["docs/*"]')"
|
|
2006
|
+
[[ "${CT_WITH_CI:-0}" == 1 ]] && seed_ci "$r"
|
|
2007
|
+
seal_base "$r"; printf '%s' "$r"
|
|
2008
|
+
}
|
|
2009
|
+
R_T15="$(mk_inert_ct_repo ct15)"
|
|
2010
|
+
commit_chg "$R_T15" docs/note.md "$CT_PAT"
|
|
2011
|
+
reset_fakes; run_gate "$R_T15" gate
|
|
2012
|
+
want_rc 0 "T15: an inert diff that fires the trigger passes"
|
|
2013
|
+
want_call "T15: the command ran on the inert path" '^ctcmd '
|
|
2014
|
+
want_no_out "T15: no 'docs-only change' claim after the command ran" 'docs-only change'
|
|
2015
|
+
want_marker "T15: whole marker line" "AFFECTED_GATE ran=- of=- skipped=- mode=selected reason=inert-content-trigger stack=- ci=none content_trigger=ran"
|
|
2016
|
+
R_T15B="$(mk_inert_ct_repo ct15b)"
|
|
2017
|
+
commit_chg "$R_T15B" docs/note.md 'plain prose'
|
|
2018
|
+
reset_fakes; run_gate "$R_T15B" gate
|
|
2019
|
+
want_out "T15: a clean inert diff keeps the docs-only claim" 'docs-only change'
|
|
2020
|
+
want_no_call "T15: and runs nothing" '^ctcmd '
|
|
2021
|
+
want_out "T15: and the marker says clear" 'reason=inert stack=- ci=none content_trigger=clear$'
|
|
2022
|
+
|
|
2023
|
+
# T16: the committed repo config arms the trigger on a real checkout.
|
|
2024
|
+
run_gate "$REPO_ROOT" explain --explain
|
|
2025
|
+
want_rc 0 "T16: the live repo's gate config validates"
|
|
2026
|
+
want_out "T16: the live repo's trigger is armed" '^CONTENT_TRIGGER armed=1 state='
|
|
2027
|
+
_ct_cfg_cmd="$(python3 -I -c 'import json,sys; print(json.load(open(sys.argv[1])).get("content_trigger_command",""))' "$REPO_ROOT/.soleur-test-gate.json" 2>/dev/null || true)"
|
|
2028
|
+
_ct_cfg_pat="$(python3 -I -c 'import json,sys; print(json.load(open(sys.argv[1])).get("content_trigger_pattern",""))' "$REPO_ROOT/.soleur-test-gate.json" 2>/dev/null || true)"
|
|
2029
|
+
if [[ "$_ct_cfg_cmd" == "bash scripts/test-affected-kb-consumers.test.sh" && "$_ct_cfg_pat" == "knowledge""-base/" ]]; then
|
|
2030
|
+
pass "T16: the committed trigger runs the dropped-consumer ratchet on the kb path"
|
|
2031
|
+
else
|
|
2032
|
+
fail "T16: the committed trigger is '$_ct_cfg_pat' -> '$_ct_cfg_cmd'"
|
|
2033
|
+
fi
|
|
2034
|
+
unset _ct_cfg_cmd _ct_cfg_pat
|
|
2035
|
+
|
|
2036
|
+
|
|
2037
|
+
# ---- adapter arm, scan legs, glob/config edge cases, marker honesty ----
|
|
2038
|
+
|
|
2039
|
+
# E1: --explain on an INERT diff reports and runs nothing (the inert exit is a third
|
|
2040
|
+
# explain-capable exit; the flag that arms the hook must not make it run the command).
|
|
2041
|
+
R_CTE1="$(mk_inert_ct_repo cte1)"
|
|
2042
|
+
commit_chg "$R_CTE1" docs/note.md "$CT_PAT"
|
|
2043
|
+
reset_fakes; run_gate "$R_CTE1" explain --explain
|
|
2044
|
+
want_no_call "CTE1: --explain on an inert diff never runs the command" '^ctcmd '
|
|
2045
|
+
want_out "CTE1: and reports the scan state" '^CONTENT_TRIGGER armed=1 state=fired paths=1$'
|
|
2046
|
+
|
|
2047
|
+
# A: the ADAPTER arm (a repo with no capability-positive runner).
|
|
2048
|
+
mk_adapter_ct() { # <name> — vitest stack, trigger armed on src/*
|
|
2049
|
+
local r; r="$(mk_repo "$1")"; seed_js "$r"; write_ct_cmd "$r"
|
|
2050
|
+
write_config "$r" "$(ct_cfg '["src/*"]')"; seal_base "$r"; printf '%s' "$r"
|
|
2051
|
+
}
|
|
2052
|
+
R_A1="$(mk_adapter_ct cta1)"
|
|
2053
|
+
commit_chg "$R_A1" src/fx.test.ts "import x; // $CT_PAT"
|
|
2054
|
+
reset_fakes; run_gate "$R_A1" gate
|
|
2055
|
+
want_rc 0 "A1: an adapter-arm selected run passes"
|
|
2056
|
+
want_call "A1: and ran the command" '^ctcmd '
|
|
2057
|
+
want_field "A1: marker field" content_trigger 'ran'
|
|
2058
|
+
want_field "A1: mode is selected" mode 'selected'
|
|
2059
|
+
reset_fakes; run_gate "$R_A1" gate --full
|
|
2060
|
+
want_no_call "A2: an operator's --full never runs the command (adapter arm)" '^ctcmd '
|
|
2061
|
+
want_no_out "A2: and the marker carries no field" 'content_trigger='
|
|
2062
|
+
reset_fakes; run_gate "$R_A1" explain --explain --full
|
|
2063
|
+
want_no_out "A3: the adapter-arm --explain under an operator --full prints no CONTENT_TRIGGER line" 'CONTENT_TRIGGER'
|
|
2064
|
+
want_no_call "A3: and runs nothing" '^ctcmd '
|
|
2065
|
+
reset_fakes; run_gate "$R_A1" explain --explain
|
|
2066
|
+
want_no_call "A3: --explain on the adapter arm runs nothing" '^ctcmd '
|
|
2067
|
+
want_out "A3: and reports the armed trigger" '^CONTENT_TRIGGER armed=1 state=fired paths=1$'
|
|
2068
|
+
# A4: a gate-side escalation to full (a global-paths hit) still runs the command: the
|
|
2069
|
+
# stack adapter's full run never runs the repo-declared command.
|
|
2070
|
+
R_A4="$(mk_adapter_ct cta4)"
|
|
2071
|
+
commit_chg "$R_A4" src/fx.test.ts "import x; // $CT_PAT"
|
|
2072
|
+
commit_chg "$R_A4" package.json '{"name":"fixture-js","private":true,"scripts":{"test":"vitest run"},"devDependencies":{"vitest":"^4.0.0"},"x":1}'
|
|
2073
|
+
reset_fakes; run_gate "$R_A4" gate
|
|
2074
|
+
want_field "A4: the diff escalated to full (global paths)" reason 'global-paths'
|
|
2075
|
+
want_field "A4: mode=full" mode 'full'
|
|
2076
|
+
want_call "A4: the command ran although the gate escalated to full" '^ctcmd '
|
|
2077
|
+
want_field "A4: marker field" content_trigger 'ran'
|
|
2078
|
+
|
|
2079
|
+
# S: every scan leg that cannot decide runs the command (fail toward coverage).
|
|
2080
|
+
for _leg in diff merge-base; do
|
|
2081
|
+
R_S="$(mk_ct_repo cts-$_leg '["tests/*"]')"
|
|
2082
|
+
commit_chg "$R_S" tests/new.test.sh 'no pattern here'
|
|
2083
|
+
reset_fakes; export FAKE_GIT_FAIL_VERB="$_leg"
|
|
2084
|
+
run_gate_path "$GITFAILBIN:$BASEPATH" "$R_S" gate
|
|
2085
|
+
want_call "S: a failing git $_leg still runs the command" '^ctcmd '
|
|
2086
|
+
want_field "S: git $_leg failure is a scan-error" content_trigger 'scan-error'
|
|
2087
|
+
case "$_leg" in diff) _want='leg=diff' ;; *) _want='leg=no-merge-base' ;; esac
|
|
2088
|
+
want_out "S: git $_leg failure names its own leg" "$_want"
|
|
2089
|
+
done
|
|
2090
|
+
unset _want
|
|
2091
|
+
R_S="$(mk_ct_repo cts-ls '["tests/*"]')"
|
|
2092
|
+
commit_chg "$R_S" tests/new.test.sh 'no pattern here'
|
|
2093
|
+
reset_fakes; export FAKE_GIT_FAIL_VERB=ls-files
|
|
2094
|
+
run_gate_path "$GITFAILBIN:$BASEPATH" "$R_S" gate
|
|
2095
|
+
want_call "S: a failing git ls-files still runs the command" '^ctcmd '
|
|
2096
|
+
want_out "S: and names the leg" 'leg=ls-files'
|
|
2097
|
+
# A --base that looks like an option is never handed to git as one.
|
|
2098
|
+
reset_fakes; run_gate "$R_S" gate --base --all
|
|
2099
|
+
want_call "S: an option-shaped --base is a scan-error that runs the command" '^ctcmd '
|
|
2100
|
+
want_out "S: and names the leg" 'leg=bad-base'
|
|
2101
|
+
unset _leg R_S
|
|
2102
|
+
|
|
2103
|
+
# W: what the tracked/untracked legs read.
|
|
2104
|
+
R_W1="$(mk_ct_repo ctw1 '["tests/*"]')"
|
|
2105
|
+
printf 'l1\n%s present\nl3\nunstaged %s\n' "$CT_PAT" "$CT_PAT" > "$R_W1/tests/base.test.sh"
|
|
2106
|
+
reset_fakes; run_gate "$R_W1" gate
|
|
2107
|
+
want_call "W1: an UNSTAGED edit of a tracked file fires" '^ctcmd '
|
|
2108
|
+
R_W2="$(mk_ct_repo ctw2 '["tests/*"]')"
|
|
2109
|
+
printf 'l1\n%s present\nl3\nstaged %s\n' "$CT_PAT" "$CT_PAT" > "$R_W2/tests/base.test.sh"
|
|
2110
|
+
assert_fixture_dir "$R_W2"; git -C "$R_W2" add tests/base.test.sh
|
|
2111
|
+
reset_fakes; run_gate "$R_W2" gate
|
|
2112
|
+
want_call "W2: a STAGED edit of a tracked file fires" '^ctcmd '
|
|
2113
|
+
R_W3="$(mk_ct_repo ctw3 '["docs/*","tests/*"]')"
|
|
2114
|
+
commit_chg "$R_W3" tests/new.test.sh "$CT_PAT"
|
|
2115
|
+
reset_fakes; run_gate "$R_W3" gate
|
|
2116
|
+
want_call "W3: a hit under the LAST of two globs fires" '^ctcmd '
|
|
2117
|
+
reset_fakes; run_gate "$R_W3" explain --explain
|
|
2118
|
+
want_out "W3: --explain counts both globs" '^CONTENT_TRIGGER armed=1 state=fired paths=2$'
|
|
2119
|
+
R_W4="$(mk_ct_repo ctw4 '["tests/*","docs/*"]')"
|
|
2120
|
+
commit_chg "$R_W4" docs/new.txt "$CT_PAT"
|
|
2121
|
+
reset_fakes; run_gate "$R_W4" gate
|
|
2122
|
+
want_call "W4: a hit under the SECOND of two globs fires" '^ctcmd '
|
|
2123
|
+
R_W5="$(mk_ct_repo ctw5 '["tests/*"]')"
|
|
2124
|
+
chg "$R_W5" src/outside.sh "$CT_PAT"
|
|
2125
|
+
reset_fakes; run_gate "$R_W5" gate
|
|
2126
|
+
want_no_call "W5: an UNTRACKED file outside the globs does not fire" '^ctcmd '
|
|
2127
|
+
want_field "W5: marker says clear" content_trigger 'clear'
|
|
2128
|
+
R_W6="$(mk_ct_repo ctw6 '["tests/*"]')"
|
|
2129
|
+
commit_chg "$R_W6" .gitignore 'tests/ignored.test.sh'
|
|
2130
|
+
chg "$R_W6" tests/ignored.test.sh "$CT_PAT"
|
|
2131
|
+
reset_fakes; run_gate "$R_W6" gate
|
|
2132
|
+
want_no_call "W6: a gitignored untracked file does not fire" '^ctcmd '
|
|
2133
|
+
want_field "W6: and the scan answered clear" content_trigger 'clear'
|
|
2134
|
+
R_W7="$(mk_ct_repo ctw7 '["tests/*"]')"
|
|
2135
|
+
printf 'a\0%s\n' "$CT_PAT" > "$R_W7/tests/blob.test.sh"
|
|
2136
|
+
reset_fakes; run_gate "$R_W7" gate
|
|
2137
|
+
want_call "W7: an untracked file with a NUL byte fires (as the tracked --text leg does)" '^ctcmd '
|
|
2138
|
+
R_W8="$(mk_ct_repo ctw8 '["tests/*"]')"
|
|
2139
|
+
commit_chg "$R_W8" .gitattributes 'tests/attr.test.sh -diff'
|
|
2140
|
+
commit_chg "$R_W8" tests/attr.test.sh "x $CT_PAT"
|
|
2141
|
+
reset_fakes; run_gate "$R_W8" gate
|
|
2142
|
+
want_field "W8: a tracked file marked -diff is still read (--text)" content_trigger 'ran'
|
|
2143
|
+
R_W9="$(mk_ct_repo ctw9 '["tests/*"]')"
|
|
2144
|
+
printf 'outside %s\n' "$CT_PAT" > "$TESTROOT/outside-target.txt"
|
|
2145
|
+
ln -s "$TESTROOT/outside-target.txt" "$R_W9/tests/link.test.sh"
|
|
2146
|
+
reset_fakes; run_gate "$R_W9" gate
|
|
2147
|
+
want_no_call "W9: an untracked symlink is not read" '^ctcmd '
|
|
2148
|
+
want_field "W9: and the scan answered clear" content_trigger 'clear'
|
|
2149
|
+
R_W10="$(mk_ct_repo ctw10 '["tests/*"]')"
|
|
2150
|
+
commit_chg "$R_W10" 'tests/q"uote.test.sh' "$CT_PAT"
|
|
2151
|
+
reset_fakes; run_gate "$R_W10" gate
|
|
2152
|
+
want_call "W10: a tracked file whose name git C-quotes still runs the command" '^ctcmd '
|
|
2153
|
+
want_out "W10: scan-error, leg quoted-path" 'leg=quoted-path'
|
|
2154
|
+
R_W11="$(mk_ct_repo ctw11 '["tests/*"]')"
|
|
2155
|
+
chg "$R_W11" 'tests/q"u.test.sh' 'nothing'
|
|
2156
|
+
reset_fakes; run_gate "$R_W11" gate
|
|
2157
|
+
want_call "W11: an untracked C-quoted name runs the command" '^ctcmd '
|
|
2158
|
+
want_out "W11: scan-error, leg quoted-path" 'leg=quoted-path'
|
|
2159
|
+
R_W12="$(mk_ct_repo ctw12 '["tests/*"]')"
|
|
2160
|
+
for _i in $(seq 1 501); do printf 'x\n' > "$R_W12/tests/gen$_i.txt"; done
|
|
2161
|
+
reset_fakes; run_gate "$R_W12" gate
|
|
2162
|
+
want_call "W12: an untracked tree past the read cap runs the command" '^ctcmd '
|
|
2163
|
+
want_out "W12: scan-error, leg untracked-cap" 'leg=untracked-cap'
|
|
2164
|
+
unset _i
|
|
2165
|
+
R_W13="$(mk_ct_repo ctw13 '["tests/*"]' 'a.b/')"
|
|
2166
|
+
commit_chg "$R_W13" tests/new.test.sh 'only axb/ here'
|
|
2167
|
+
reset_fakes; run_gate "$R_W13" gate
|
|
2168
|
+
want_no_call "W13: the pattern is a FIXED string ('.' is not a wildcard)" '^ctcmd '
|
|
2169
|
+
want_field "W13: and the scan answered clear" content_trigger 'clear'
|
|
2170
|
+
commit_chg "$R_W13" tests/other.test.sh 'literal a.b/ here'
|
|
2171
|
+
reset_fakes; run_gate "$R_W13" gate
|
|
2172
|
+
want_call "W13: and the literal form fires" '^ctcmd '
|
|
2173
|
+
R_W14="$(CT_BRANCH=master mk_ct_repo ctw14 '["tests/*"]')"
|
|
2174
|
+
commit_chg "$R_W14" tests/new.test.sh "$CT_PAT"
|
|
2175
|
+
reset_fakes; run_gate "$R_W14" gate
|
|
2176
|
+
want_field "W14: origin/master is the fallback base" content_trigger 'ran'
|
|
2177
|
+
R_W15="$(mk_ct_repo ctw15 '["tests/*.test.sh"]')"
|
|
2178
|
+
assert_fixture_dir "$R_W15"; git -C "$R_W15" config diff.renames false
|
|
2179
|
+
commit_chg "$R_W15" 'tests/dir with space/é.test.sh' "$CT_PAT"
|
|
2180
|
+
reset_fakes; run_gate "$R_W15" gate
|
|
2181
|
+
want_field "W15: a spaced path under a SUFFIX glob fires (the TAB git appends is stripped)" content_trigger 'ran'
|
|
2182
|
+
|
|
2183
|
+
# P: a primary that is refused owns the verdict.
|
|
2184
|
+
R_P1="$(mk_ct_repo ctp1 '["tests/*"]')"
|
|
2185
|
+
commit_chg "$R_P1" tests/new.test.sh "$CT_PAT"
|
|
2186
|
+
reset_fakes; export FAKE_RUNNER_RC=4; run_gate "$R_P1" gate
|
|
2187
|
+
want_no_call "P1: a refused (rc 4) primary does not run the command" '^ctcmd '
|
|
2188
|
+
want_marker "P1: marker says skipped" "AFFECTED_GATE ran=- of=- skipped=- mode=selected reason=runner-refused stack=runner ci=none content_trigger=skipped"
|
|
2189
|
+
|
|
2190
|
+
# I: an inert diff whose command fails keeps the marker honest.
|
|
2191
|
+
R_I1="$(mk_inert_ct_repo cti1)"
|
|
2192
|
+
commit_chg "$R_I1" docs/note.md "$CT_PAT"
|
|
2193
|
+
reset_fakes; export FAKE_CT_RC=1; run_gate "$R_I1" gate
|
|
2194
|
+
want_rc 1 "I1: an inert diff whose command fails fails the gate"
|
|
2195
|
+
want_marker "I1: marker is not the inert counts under mode=none" "AFFECTED_GATE ran=- of=- skipped=- mode=selected reason=content-trigger-failed stack=- ci=none content_trigger=failed"
|
|
2196
|
+
# I2: the inert exit precedes the generic budget arming, so it arms its own: a command
|
|
2197
|
+
# killed (137) on an inert diff with a detected CI workflow defers to CI like any other run.
|
|
2198
|
+
R_I2="$(CT_WITH_CI=1 mk_inert_ct_repo cti2)"
|
|
2199
|
+
commit_chg "$R_I2" docs/note.md "$CT_PAT"
|
|
2200
|
+
reset_fakes; export FAKE_CT_RC=137; run_gate "$R_I2" gate
|
|
2201
|
+
want_rc 6 "I2: an inert diff with CI and a killed command defers (the budget is armed on the inert exit)"
|
|
2202
|
+
want_field "I2: field is deferred" content_trigger 'deferred'
|
|
2203
|
+
|
|
2204
|
+
# ---- second batch: escalated full, deferred primary, 137, bounds, fixed strings, dead globs ----
|
|
2205
|
+
|
|
2206
|
+
# A5: a degraded census (git ls-files --others fails) escalates the adapter to full; the
|
|
2207
|
+
# trigger must still run. (ARG_FULL is set by the escalation, ARG_FULL_REQUESTED is not.)
|
|
2208
|
+
R_A5="$(mk_adapter_ct cta5)"
|
|
2209
|
+
commit_chg "$R_A5" src/fx.test.ts "import x; // $CT_PAT"
|
|
2210
|
+
printf 'import { test } from "vitest";\ntest("n", () => {});\n' > "$R_A5/src/new.test.ts"
|
|
2211
|
+
reset_fakes; export FAKE_GIT_FAIL_OTHERS=1
|
|
2212
|
+
run_gate_path "$GITFAILBIN:$BASEPATH" "$R_A5" gate
|
|
2213
|
+
want_field "A5: the census degraded to full" reason 'census-degraded'
|
|
2214
|
+
want_call "A5: the command ran although the gate escalated to full" '^ctcmd '
|
|
2215
|
+
|
|
2216
|
+
# P2: a delegated primary that defers (rc 6 via budget) owns the verdict: command skipped.
|
|
2217
|
+
R_P2="$(CT_WITH_CI=1 mk_ct_repo ctp2 '["tests/*"]' "$CT_PAT" 'bash scripts/ct-cmd.sh' ',"budget_seconds":60')"
|
|
2218
|
+
commit_chg "$R_P2" tests/new.test.sh "$CT_PAT"
|
|
2219
|
+
reset_fakes; export FAKE_RUNNER_RC=124; run_gate "$R_P2" gate
|
|
2220
|
+
want_rc 6 "P2: a runner expiry defers (CI detected)"
|
|
2221
|
+
want_no_call "P2: and the command does not run behind a deferred primary" '^ctcmd '
|
|
2222
|
+
want_field "P2: marker says skipped" content_trigger 'skipped'
|
|
2223
|
+
|
|
2224
|
+
# D137: the command itself exiting 137 under an active budget with CI defers like 124.
|
|
2225
|
+
R_D1="$(CT_WITH_CI=1 mk_ct_repo ctd1 '["tests/*"]' "$CT_PAT" 'bash scripts/ct-cmd.sh' ',"budget_seconds":60')"
|
|
2226
|
+
commit_chg "$R_D1" tests/new.test.sh "$CT_PAT"
|
|
2227
|
+
reset_fakes; export FAKE_CT_RC=137; run_gate "$R_D1" gate
|
|
2228
|
+
want_rc 6 "D137: a command exit of 137 under an active budget defers"
|
|
2229
|
+
want_field "D137: field is deferred" content_trigger 'deferred'
|
|
2230
|
+
want_out "D137: the SIGKILL note is printed" 'exited 137'
|
|
2231
|
+
want_out "D137: and the human line says only the command is owed" 'only the command is owed to CI'
|
|
2232
|
+
|
|
2233
|
+
# U: untracked-leg bounds and guards.
|
|
2234
|
+
R_U1="$(mk_ct_repo ctu1 '["tests/*"]' 'a.b/')"
|
|
2235
|
+
printf 'axb/ only\n' > "$R_U1/tests/untracked.test.sh"
|
|
2236
|
+
reset_fakes; run_gate "$R_U1" gate
|
|
2237
|
+
want_no_call "U1: the UNTRACKED leg also matches a fixed string ('.' is not a wildcard)" '^ctcmd '
|
|
2238
|
+
want_field "U1: and answered clear" content_trigger 'clear'
|
|
2239
|
+
printf 'a.b/ here\n' > "$R_U1/tests/untracked2.test.sh"
|
|
2240
|
+
reset_fakes; run_gate "$R_U1" gate
|
|
2241
|
+
want_call "U1: the literal form fires" '^ctcmd '
|
|
2242
|
+
R_U2="$(mk_ct_repo ctu2 '["tests/*"]')"
|
|
2243
|
+
for _i in $(seq 1 500); do printf 'x\n' > "$R_U2/tests/gen$_i.txt"; done
|
|
2244
|
+
reset_fakes; run_gate "$R_U2" gate
|
|
2245
|
+
want_field "U2: exactly 500 candidate files is within the read cap" content_trigger 'clear'
|
|
2246
|
+
unset _i
|
|
2247
|
+
R_U3="$(mk_ct_repo ctu3 '["tests/*"]')"
|
|
2248
|
+
mkdir -p "$R_U3/gen"; ( cd "$R_U3/gen" && seq 1 20001 | sed 's/^/f/' | xargs touch )
|
|
2249
|
+
reset_fakes; run_gate "$R_U3" gate
|
|
2250
|
+
want_out "U3: an untracked listing past 20000 entries declines (cap, outside the globs)" 'leg=untracked-cap'
|
|
2251
|
+
want_call "U3: and runs the command" '^ctcmd '
|
|
2252
|
+
if [[ "$(id -u)" != "0" ]]; then
|
|
2253
|
+
R_U4="$(mk_ct_repo ctu4 '["tests/*"]')"
|
|
2254
|
+
printf 'x\n' > "$R_U4/tests/locked.test.sh"; chmod 000 "$R_U4/tests/locked.test.sh"
|
|
2255
|
+
reset_fakes; run_gate "$R_U4" gate
|
|
2256
|
+
want_out "U4: an unreadable untracked file (grep error) declines" 'leg=grep'
|
|
2257
|
+
chmod 600 "$R_U4/tests/locked.test.sh"
|
|
2258
|
+
fi
|
|
2259
|
+
|
|
2260
|
+
# X: pattern shapes the scan must treat literally.
|
|
2261
|
+
R_X1="$(mk_ct_repo ctx1 '["tests/*"]' '-xq/')"
|
|
2262
|
+
commit_chg "$R_X1" tests/new.test.sh 'a -xq/ b'
|
|
2263
|
+
reset_fakes; run_gate "$R_X1" gate
|
|
2264
|
+
want_field "X1: a leading-dash pattern is a pattern, not an option" content_trigger 'ran'
|
|
2265
|
+
R_X1U="$(mk_ct_repo ctx1u '["tests/*"]' '-xq/')"
|
|
2266
|
+
chg "$R_X1U" tests/untracked.test.sh 'c -xq/ d'
|
|
2267
|
+
reset_fakes; run_gate "$R_X1U" gate
|
|
2268
|
+
want_field "X1: (untracked leg alone: nothing committed to mask it)" content_trigger 'ran'
|
|
2269
|
+
R_X2="$(mk_ct_repo ctx2 '["tests/*"]' 'a\\b/')"
|
|
2270
|
+
printf '%s\n' 'x a\b/ y' > "$R_X2/tests/new.test.sh" # commit_chg's printf %b would eat the backslash
|
|
2271
|
+
assert_fixture_dir "$R_X2"; git -C "$R_X2" add -A; git -C "$R_X2" commit -q -m "backslash"
|
|
2272
|
+
reset_fakes; run_gate "$R_X2" gate
|
|
2273
|
+
want_field "X2: a backslash in the pattern reaches awk verbatim (ENVIRON, not -v)" content_trigger 'ran'
|
|
2274
|
+
|
|
2275
|
+
# B: base preference.
|
|
2276
|
+
R_B1="$(mk_ct_repo ctb1 '["tests/*"]')"
|
|
2277
|
+
commit_chg "$R_B1" tests/new.test.sh "$CT_PAT"
|
|
2278
|
+
assert_fixture_dir "$R_B1"; git -C "$R_B1" update-ref refs/remotes/origin/master HEAD
|
|
2279
|
+
reset_fakes; run_gate "$R_B1" gate
|
|
2280
|
+
want_field "B1: origin/main is preferred over origin/master (a stale master at HEAD must not hide the fixture)" content_trigger 'ran'
|
|
2281
|
+
|
|
2282
|
+
# R: renames.
|
|
2283
|
+
R_R1="$(mk_ct_repo ctr1 '["tests/*"]')"
|
|
2284
|
+
mkdir -p "$R_R1/docs"; printf 'moves in %s\n' "$CT_PAT" > "$R_R1/docs/fx.sh"
|
|
2285
|
+
assert_fixture_dir "$R_R1"; git -C "$R_R1" add -A; git -C "$R_R1" commit -q -m "docs fx"
|
|
2286
|
+
git -C "$R_R1" update-ref refs/remotes/origin/main HEAD
|
|
2287
|
+
assert_fixture_dir "$R_R1"; git -C "$R_R1" mv docs/fx.sh tests/fx.sh
|
|
2288
|
+
printf 'unrelated edit\n' >> "$R_R1/tests/fx.sh"
|
|
2289
|
+
reset_fakes; run_gate "$R_R1" gate
|
|
2290
|
+
want_field "R1: moving a file that names the string INTO the globs, with an edit, fires" content_trigger 'ran'
|
|
2291
|
+
|
|
2292
|
+
# V: explain under an operator --full is silent (a real --full would not run the command).
|
|
2293
|
+
R_V1="$(mk_ct_repo ctv1 '["tests/*"]')"
|
|
2294
|
+
commit_chg "$R_V1" tests/new.test.sh "$CT_PAT"
|
|
2295
|
+
reset_fakes; run_gate "$R_V1" explain --explain --full
|
|
2296
|
+
want_no_out "V1: --explain --full prints no CONTENT_TRIGGER line" 'CONTENT_TRIGGER'
|
|
2297
|
+
want_no_call "V1: and runs nothing" '^ctcmd '
|
|
2298
|
+
|
|
2299
|
+
# G: config globs that can never match, or match too much.
|
|
2300
|
+
ct_bad ct13-brace '{"content_trigger_pattern":"x/","content_trigger_paths":["{a,b}/x"],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_paths'
|
|
2301
|
+
ct_bad ct13-dslash '{"content_trigger_pattern":"x/","content_trigger_paths":["tests//x"],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_paths'
|
|
2302
|
+
ct_bad ct13-dotseg '{"content_trigger_pattern":"x/","content_trigger_paths":["tests/./x"],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_paths'
|
|
2303
|
+
ct_bad ct13-dotdot '{"content_trigger_pattern":"x/","content_trigger_paths":["../tests/*"],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_paths'
|
|
2304
|
+
ct_bad ct13-space '{"content_trigger_pattern":"x/","content_trigger_paths":["tests/* "],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_paths'
|
|
2305
|
+
ct_bad ct13-bang '{"content_trigger_pattern":"x/","content_trigger_paths":["!tests/*"],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_paths'
|
|
2306
|
+
ct_bad ct13-notp '{"content_trigger_pattern":"x/","content_trigger_paths":["[!p]*"],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_paths'
|
|
2307
|
+
ct_bad ct13-dot '{"content_trigger_pattern":"x/","content_trigger_paths":["."],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_paths'
|
|
2308
|
+
ct_bad ct13-trailingdot '{"content_trigger_pattern":"x/","content_trigger_paths":["tests/."],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_paths'
|
|
2309
|
+
ct_bad ct13-hiddenonly '{"content_trigger_pattern":"x/","content_trigger_paths":[".h*"],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_paths'
|
|
2310
|
+
ct_bad ct13-dotted '{"content_trigger_pattern":"x/","content_trigger_paths":["x/*.z"],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_paths'
|
|
2311
|
+
ct_bad ct13-capq '{"content_trigger_pattern":"x/","content_trigger_paths":["Q*"],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_paths'
|
|
2312
|
+
ct_bad ct13-newlineglob '{"content_trigger_pattern":"x/","content_trigger_paths":["tests/*\nfoo"],"content_trigger_command":"bash scripts/ct-cmd.sh"}' 'bad-config key=content_trigger_paths'
|
|
2313
|
+
|
|
2314
|
+
# H1: the ledger is the discriminator. With the stub's ledger write removed the gate
|
|
2315
|
+
# still REPORTS the command ran — so a row asserting the ledger would be RED.
|
|
2316
|
+
R_H1="$(mk_ct_repo cth1 '["tests/*"]')"
|
|
2317
|
+
commit_chg "$R_H1" tests/new.test.sh "$CT_PAT"
|
|
2318
|
+
reset_fakes; export FAKE_CT_NOLEDGER=1; run_gate "$R_H1" gate
|
|
2319
|
+
want_out "H1: the marker still claims the run" 'content_trigger=ran$'
|
|
2320
|
+
if grep -q '^ctcmd ' "$CALLS"; then fail "H1: the ledger was written despite the stub write being removed"
|
|
2321
|
+
else pass "H1: no ledger line without the stub write — every ledger row would go RED"; fi
|
|
2322
|
+
|
|
2323
|
+
# H2: different pattern, globs and command still fire — nothing is hard-coded.
|
|
2324
|
+
R_H2="$(mk_ct_repo cth2 '["src/*"]' 'qq-other/' 'bash scripts/other-cmd.sh')"
|
|
2325
|
+
commit_chg "$R_H2" src/new.sh 'uses qq-other/ here'
|
|
2326
|
+
reset_fakes; run_gate "$R_H2" gate
|
|
2327
|
+
want_call "H2: a different pattern/glob/command fires" '^otherctcmd'
|
|
2328
|
+
want_no_call "H2: and the default command stays dark" '^ctcmd '
|
|
2329
|
+
|
|
2330
|
+
# H3: an UNARMED gate prints the pre-change marker line, byte for byte.
|
|
2331
|
+
R_H3="$(mk_repo cth3)"; write_runner_capable "$R_H3"; seal_base "$R_H3"
|
|
2332
|
+
commit_chg "$R_H3" tests/new.test.sh "$CT_PAT"
|
|
2333
|
+
reset_fakes; run_gate "$R_H3" gate
|
|
2334
|
+
want_marker "H3: unarmed marker is unchanged" "$CT_RUN"
|
|
2335
|
+
unset R_CTE1 R_A1 R_A4 R_A5 R_P1 R_P2 R_D1 R_I1 R_I2 R_U1 R_U2 R_U3 R_U4 R_X1 R_X1U R_X2 R_B1 R_R1 R_V1 R_W1 R_W2 R_W3 R_W4 R_W5 R_W6 R_W7 R_W8 R_W9 R_W10 R_W11 R_W12 R_W13 R_W14 R_W15 R_T12C R_T1 R_T2 R_T3 R_T4 R_T5 R_T6 R_T7 R_T8 R_T9 R_T10A R_T10B R_T10C R_T11 R_T11B R_T12 R_T12B R_T14 R_T15 R_T15B R_H1 R_H2 R_H3
|
|
2336
|
+
|
|
1760
2337
|
# ============================ cross-run contract ===============================
|
|
1761
2338
|
# G1-10: every run path emits the marker — a second exit site that fires before the
|
|
1762
2339
|
# emit leaves a run with no AFFECTED_GATE line, and these loops catch it.
|
|
@@ -1792,6 +2369,8 @@ else
|
|
|
1792
2369
|
fi
|
|
1793
2370
|
unset _kind _rc _of _xfail _badword
|
|
1794
2371
|
|
|
1795
|
-
|
|
2372
|
+
# Floor = the full count less a little slack for the rows that
|
|
2373
|
+
# depend on a host binary (jq): it is a floor, so a deleted block of rows reddens it.
|
|
2374
|
+
print_results "${AFFECTED_TESTS_MIN_ASSERTIONS:-467}"
|
|
1796
2375
|
|
|
1797
2376
|
|