checkwright 0.38.0 → 0.39.0
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 +2 -2
- package/payload/artifact/aarch64-apple-darwin/checkwright-gates +0 -0
- package/payload/artifact/aarch64-apple-darwin/checkwright-gates.sha256 +1 -1
- package/payload/artifact/aarch64-pc-windows-msvc/checkwright-gates.exe +0 -0
- package/payload/artifact/aarch64-pc-windows-msvc/checkwright-gates.exe.sha256 +1 -1
- package/payload/artifact/aarch64-unknown-linux-gnu/checkwright-gates +0 -0
- package/payload/artifact/aarch64-unknown-linux-gnu/checkwright-gates.sha256 +1 -1
- package/payload/artifact/aarch64-unknown-linux-musl/checkwright-gates +0 -0
- package/payload/artifact/aarch64-unknown-linux-musl/checkwright-gates.sha256 +1 -1
- package/payload/artifact/x86_64-apple-darwin/checkwright-gates +0 -0
- package/payload/artifact/x86_64-apple-darwin/checkwright-gates.sha256 +1 -1
- package/payload/artifact/x86_64-pc-windows-msvc/checkwright-gates.exe +0 -0
- package/payload/artifact/x86_64-pc-windows-msvc/checkwright-gates.exe.sha256 +1 -1
- package/payload/artifact/x86_64-unknown-linux-gnu/checkwright-gates +0 -0
- package/payload/artifact/x86_64-unknown-linux-gnu/checkwright-gates.sha256 +1 -1
- package/payload/artifact/x86_64-unknown-linux-musl/checkwright-gates +0 -0
- package/payload/artifact/x86_64-unknown-linux-musl/checkwright-gates.sha256 +1 -1
- package/payload/canon-kit/gate-tests/check-amendment-queue.test.sh +3 -3
- package/payload/canon-kit/gate-tests/check-amendment-update-target.test.sh +3 -3
- package/payload/canon-kit/gate-tests/check-deprecation-task.test.sh +2 -2
- package/payload/canon-kit/gate-tests/check-measured-claim.test.sh +3 -3
- package/payload/canon-kit/gate-tests/check-prose-bounds.test.sh +1 -1
- package/payload/canon-kit/gate-tests/check-prose-enum.test.sh +2 -2
- package/payload/canon-kit/gate-tests/check-provenance-seam/good/TASK-QUEUE.md +4 -0
- package/payload/canon-kit/gate-tests/check-provenance-seam/good/widget-toolkit/SPEC.md +1 -1
- package/payload/canon-kit/gate-tests/check-todo-task-liveness.test.sh +1 -1
- package/payload/canon-kit/gate-tests/check-unmarked-claim.test.sh +7 -7
- package/payload/context-kit/gate-tests/check-surface-ratchet.test.sh +7 -6
- package/payload/delegation-kit/README.md +1 -1
- package/payload/doctrine-kit/gate-tests/check-doctrine-registration.test.sh +2 -2
- package/payload/evidence-kit/gate-tests/check-battery-roster.test.sh +2 -2
- package/payload/evidence-kit/gate-tests/pre-hook.test.sh +5 -5
- package/payload/evidence-kit/gate-tests/producer-lock.test.sh +7 -7
- package/payload/evidence-kit/gate-tests/statement-store.test.sh +5 -5
- package/payload/evidence-kit/gate-tests/verify-gate-run-strict.test.sh +5 -4
- package/payload/gate-sdk/README.md +7 -0
- package/payload/gate-sdk/bin/build-native.sh +5 -4
- package/payload/gate-sdk/bin/run-gates.ps1 +8 -7
- package/payload/gate-sdk/bin/run-gates.sh +10 -8
- package/payload/gate-sdk/checks/check-binary-strings.gate +4 -0
- package/payload/gate-sdk/checks/check-exec-write.gate +4 -0
- package/payload/gate-sdk/checks/check-migration-guard.gate +4 -0
- package/payload/gate-sdk/checks/check-path-names.gate +4 -0
- package/payload/gate-sdk/checks/check-pipefail-readers.gate +4 -0
- package/payload/gate-sdk/checks/check-script-preflight.gate +4 -0
- package/payload/gate-sdk/checks/check-site-count.gate +4 -0
- package/payload/gate-sdk/checks/check-tree-terms.gate +1 -1
- package/payload/gate-sdk/gate-tests/binary-only-recipe.test.sh +2 -2
- package/payload/gate-sdk/gate-tests/check-action-run-shell.test.sh +11 -11
- package/payload/gate-sdk/gate-tests/check-binary-strings/bad/expect.txt +4 -0
- package/payload/gate-sdk/gate-tests/check-binary-strings/bad/out/app.elf +0 -0
- package/payload/gate-sdk/gate-tests/check-binary-strings/bad/out/notes.bin +0 -0
- package/payload/gate-sdk/gate-tests/check-binary-strings/bad/scripts/gate-sdk-config.knobs +3 -0
- package/payload/gate-sdk/gate-tests/check-binary-strings/bad/shapes.list +2 -0
- package/payload/gate-sdk/gate-tests/check-binary-strings/bad/terms.list +2 -0
- package/payload/gate-sdk/gate-tests/check-binary-strings/good/expect.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-binary-strings/good/out/app.elf +0 -0
- package/payload/gate-sdk/gate-tests/check-binary-strings/good/scripts/gate-sdk-config.knobs +3 -0
- package/payload/gate-sdk/gate-tests/check-binary-strings/good/shapes.list +2 -0
- package/payload/gate-sdk/gate-tests/check-binary-strings/good/terms.list +4 -0
- package/payload/gate-sdk/gate-tests/check-binary-strings.test.sh +74 -0
- package/payload/gate-sdk/gate-tests/check-exec-write/bad/expect.txt +13 -0
- package/payload/gate-sdk/gate-tests/check-exec-write/bad/scripts/gate-sdk-config.knobs +2 -0
- package/payload/gate-sdk/gate-tests/check-exec-write/bad/src/caller.rs +5 -0
- package/payload/gate-sdk/gate-tests/check-exec-write/bad/src/helper.rs +5 -0
- package/payload/gate-sdk/gate-tests/check-exec-write/bad/src/sites.rs +19 -0
- package/payload/gate-sdk/gate-tests/check-exec-write/good/expect.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-exec-write/good/scripts/gate-sdk-config.knobs +2 -0
- package/payload/gate-sdk/gate-tests/check-exec-write/good/src/helper.rs +5 -0
- package/payload/gate-sdk/gate-tests/check-exec-write/good/src/main.rs +15 -0
- package/payload/gate-sdk/gate-tests/check-exec-write.test.sh +69 -0
- package/payload/gate-sdk/gate-tests/check-identity.test.sh +2 -2
- package/payload/gate-sdk/gate-tests/check-migration-guard/bad/args +2 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/bad/base/0001_init.sql +1 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/bad/base/0002_orders.sql +1 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/bad/base/0003_audit.sql +1 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/bad/destructive.list +4 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/bad/expect.txt +7 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/bad/migrations/0001_init.sql +1 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/bad/migrations/0002_late.sql +1 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/bad/migrations/0003_audit_log.sql +1 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/bad/migrations/0004_prune.sql +3 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/bad/scripts/gate-sdk-config.knobs +2 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/good/args +2 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/good/base/0001_init.sql +1 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/good/base/0002_legacy.sql +1 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/good/destructive.list +4 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/good/expect.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/good/migrations/0001_init.sql +1 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/good/migrations/0002_legacy.sql +1 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/good/migrations/0003_retire_legacy.sql +6 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/good/scripts/gate-sdk-config.knobs +2 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard.test.sh +136 -0
- package/payload/gate-sdk/gate-tests/check-path-names/bad/expect.txt +6 -0
- package/payload/gate-sdk/gate-tests/check-path-names/bad/scripts/gate-sdk-config.knobs +1 -0
- package/payload/gate-sdk/gate-tests/check-path-names/bad/terms.list +3 -0
- package/payload/gate-sdk/gate-tests/check-path-names/bad/tree/ZePhYr.md +1 -0
- package/payload/gate-sdk/gate-tests/check-path-names/bad/tree/foo/a.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-path-names/bad/tree/foo/zephyr.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-path-names/bad/tree/foo-cli.sh +1 -0
- package/payload/gate-sdk/gate-tests/check-path-names/bad/tree/foo.rs +1 -0
- package/payload/gate-sdk/gate-tests/check-path-names/bad/tree/foo_x.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-path-names/good/expect.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-path-names/good/scripts/gate-sdk-config.knobs +1 -0
- package/payload/gate-sdk/gate-tests/check-path-names/good/terms.list +1 -0
- package/payload/gate-sdk/gate-tests/check-path-names/good/tree/foobar.rs +1 -0
- package/payload/gate-sdk/gate-tests/check-path-names/good/tree/food/a.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-path-names/good/tree/xfoo.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-path-names.test.sh +66 -0
- package/payload/gate-sdk/gate-tests/check-pipefail-readers/bad/baseline.tsv +4 -0
- package/payload/gate-sdk/gate-tests/check-pipefail-readers/bad/expect.txt +17 -0
- package/payload/gate-sdk/gate-tests/check-pipefail-readers/bad/scripts/gate-sdk-config.knobs +2 -0
- package/payload/gate-sdk/gate-tests/check-pipefail-readers/bad/tree/over.sh +5 -0
- package/payload/gate-sdk/gate-tests/check-pipefail-readers/bad/tree/readers.sh +16 -0
- package/payload/gate-sdk/gate-tests/check-pipefail-readers/bad/tree/shared-lib.sh +3 -0
- package/payload/gate-sdk/gate-tests/check-pipefail-readers/bad/tree/stale.sh +4 -0
- package/payload/gate-sdk/gate-tests/check-pipefail-readers/good/baseline.tsv +2 -0
- package/payload/gate-sdk/gate-tests/check-pipefail-readers/good/expect.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-pipefail-readers/good/scripts/gate-sdk-config.knobs +2 -0
- package/payload/gate-sdk/gate-tests/check-pipefail-readers/good/tree/clean.sh +17 -0
- package/payload/gate-sdk/gate-tests/check-pipefail-readers/good/tree/lib/baselined-lib.sh +4 -0
- package/payload/gate-sdk/gate-tests/check-pipefail-readers/good/tree/no-pipefail.sh +4 -0
- package/payload/gate-sdk/gate-tests/check-pipefail-readers.test.sh +114 -0
- package/payload/gate-sdk/gate-tests/check-portability-floor.test.sh +1 -1
- package/payload/gate-sdk/gate-tests/check-script-preflight/bad/expect.txt +10 -0
- package/payload/gate-sdk/gate-tests/check-script-preflight/bad/rules.list +23 -0
- package/payload/gate-sdk/gate-tests/check-script-preflight/bad/scripts/gate-sdk-config.knobs +2 -0
- package/payload/gate-sdk/gate-tests/check-script-preflight/bad/tree/submit-job.sh +13 -0
- package/payload/gate-sdk/gate-tests/check-script-preflight/good/expect.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-script-preflight/good/rules.list +23 -0
- package/payload/gate-sdk/gate-tests/check-script-preflight/good/scripts/gate-sdk-config.knobs +2 -0
- package/payload/gate-sdk/gate-tests/check-script-preflight/good/tree/submit-job.sh +17 -0
- package/payload/gate-sdk/gate-tests/check-script-preflight.test.sh +110 -0
- package/payload/gate-sdk/gate-tests/check-site-count/bad/expect.txt +4 -0
- package/payload/gate-sdk/gate-tests/check-site-count/bad/rules.list +5 -0
- package/payload/gate-sdk/gate-tests/check-site-count/bad/scripts/gate-sdk-config.knobs +1 -0
- package/payload/gate-sdk/gate-tests/check-site-count/bad/sites.tsv +3 -0
- package/payload/gate-sdk/gate-tests/check-site-count/bad/tree/new.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-site-count/bad/tree/over.txt +3 -0
- package/payload/gate-sdk/gate-tests/check-site-count/bad/tree/under.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-site-count/good/expect.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-site-count/good/rules.list +5 -0
- package/payload/gate-sdk/gate-tests/check-site-count/good/scripts/gate-sdk-config.knobs +1 -0
- package/payload/gate-sdk/gate-tests/check-site-count/good/sites.tsv +2 -0
- package/payload/gate-sdk/gate-tests/check-site-count/good/tree/blob.bin +0 -0
- package/payload/gate-sdk/gate-tests/check-site-count/good/tree/pinned.txt +2 -0
- package/payload/gate-sdk/gate-tests/check-site-count/good/tree/plain.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-site-count/good/tree/tests/helper.txt +2 -0
- package/payload/gate-sdk/gate-tests/check-site-count.test.sh +90 -0
- package/payload/gate-sdk/gate-tests/check-tree-terms/bad/expect.txt +11 -8
- package/payload/gate-sdk/gate-tests/check-tree-terms/bad/patterns.list +4 -1
- package/payload/gate-sdk/gate-tests/check-tree-terms/bad/scripts/gate-sdk-config.knobs +1 -0
- package/payload/gate-sdk/gate-tests/check-tree-terms/bad/terms.list +4 -0
- package/payload/gate-sdk/gate-tests/check-tree-terms/bad/tree/terms.txt +2 -0
- package/payload/gate-sdk/gate-tests/check-tree-terms/good/expect.txt +1 -1
- package/payload/gate-sdk/gate-tests/check-tree-terms/good/scripts/gate-sdk-config.knobs +1 -0
- package/payload/gate-sdk/gate-tests/check-tree-terms/good/tree/rosters/terms.list +2 -0
- package/payload/gate-sdk/gate-tests/check-tree-terms/good/tree/words.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-tree-terms.test.sh +36 -16
- package/payload/gate-sdk/gate-tests/enforcement-map.test.sh +5 -6
- package/payload/gate-sdk/gate-tests/lib-gate.test.sh +8 -8
- package/payload/gate-sdk/gate-tests/native-git-hooks.test.sh +7 -7
- package/payload/gate-sdk/gate-tests/run-dispatch-streams.test.sh +4 -4
- package/payload/gate-sdk/gate-tests/run-for-path.test.sh +3 -3
- package/payload/gate-sdk/gate-tests/run-gates-linked-worktree.test.sh +6 -6
- package/payload/gate-sdk/gate-tests/run-json.test.sh +52 -0
- package/payload/gate-sdk/gate-tests/verdict-store.test.sh +99 -0
- package/payload/gate-sdk/lib/gate.sh +12 -9
- package/payload/gate-sdk/lib/test-hermetic.sh +2 -2
- package/payload/gate-sdk/templates/check-skeleton.sh +2 -1
- package/payload/gate-sdk/templates/migration-destructive.list +10 -0
- package/payload/gate-sdk/templates/script-rules.list +39 -0
- package/payload/gate-sdk/templates/strings-shapes.list +15 -0
- package/payload/guard-kit/gate-tests/consumer-rules.test.sh +5 -5
- package/payload/guard-kit/gate-tests/door-binding-corpus.test.sh +2 -2
- package/payload/lifecycle-kit/gate-tests/boundary-worktree-refusal.test.sh +1 -1
- package/payload/lifecycle-kit/gate-tests/check-dispatch-entry.test.sh +1 -1
- package/payload/lifecycle-kit/gate-tests/check-lesson-disposition.test.sh +3 -3
- package/payload/lifecycle-kit/gate-tests/check-lifecycle-registration.test.sh +1 -1
- package/payload/lifecycle-kit/gate-tests/check-survey-record.test.sh +2 -2
- package/payload/lifecycle-kit/gate-tests/lead-journal-open.test.sh +18 -2
- package/payload/lifecycle-kit/gate-tests/peer-channel.test.sh +35 -6
- package/payload/lifecycle-kit/gate-tests/preflight-valve.test.sh +4 -4
- package/payload/lifecycle-kit/templates/consult.md +1 -1
- package/payload/lifecycle-kit/templates/stages/scope.md +1 -1
- package/payload/queue-kit/README.md +1 -1
- package/payload/queue-kit/gate-tests/check-queue-slug-liveness.test.sh +2 -2
- package/payload/queue-kit/gate-tests/check-task-conservation.test.sh +4 -4
- package/payload/site-kit/gate-tests/check-docs-liquid-parse-parser.test.sh +4 -4
- package/payload/site-kit/gate-tests/check-docs-render-fidelity-batch.test.sh +9 -9
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Behavioral test of check-script-preflight over what the good/+bad/ pair cannot reach: an
|
|
3
|
+
# empty configuration, operands, the rules file's exit-2 and exit-3 classes, an unparseable
|
|
4
|
+
# script, and the prune set over the tracked tree.
|
|
5
|
+
#
|
|
6
|
+
# Run by the --run-gate-tests arm (any <tests-dir>/*.test.sh; must exit 0).
|
|
7
|
+
set -uo pipefail
|
|
8
|
+
source "$(dirname "${BASH_SOURCE[0]}")/../../gate-sdk/lib/test-hermetic.sh"
|
|
9
|
+
|
|
10
|
+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # gate-sdk/
|
|
11
|
+
CHECKS="$DIR/checks"
|
|
12
|
+
CASES="$DIR/gate-tests/check-script-preflight"
|
|
13
|
+
SANDBOX="$(mktemp -d)"
|
|
14
|
+
trap 'rm -rf "$SANDBOX"' EXIT
|
|
15
|
+
|
|
16
|
+
fails=0
|
|
17
|
+
cases=0
|
|
18
|
+
|
|
19
|
+
expect() { # expect <label> <want-rc> <substring> <got-rc> <output>
|
|
20
|
+
cases=$((cases + 1))
|
|
21
|
+
if [[ "$4" -ne "$2" ]]; then
|
|
22
|
+
echo " FAIL [$1]: want exit $2, got $4 -- $5"; fails=$((fails + 1))
|
|
23
|
+
elif ! grep -qF -- "$3" <<<"$5"; then
|
|
24
|
+
echo " FAIL [$1]: exit $2 but output lacks '$3': $5"; fails=$((fails + 1))
|
|
25
|
+
fi
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
refute() { # refute <label> <substring> <output>
|
|
29
|
+
if grep -qF -- "$2" <<<"$3"; then
|
|
30
|
+
echo " FAIL [$1]: output holds '$2': $3"; fails=$((fails + 1))
|
|
31
|
+
fi
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
# --- no script configured: clean, not applicable, and no rules file read.
|
|
35
|
+
mkdir -p "$SANDBOX/empty"
|
|
36
|
+
out="$( cd "$SANDBOX/empty" && gate_run check-script-preflight "$CHECKS" 2>&1 )"; rc=$?
|
|
37
|
+
expect not-applicable 0 'not applicable: no script configured' "$rc" "$out"
|
|
38
|
+
|
|
39
|
+
# --- an operand naming nothing on disk is refused at 2.
|
|
40
|
+
out="$( cd "$SANDBOX/empty" && gate_run check-script-preflight "$CHECKS" gone.sh 2>&1 )"; rc=$?
|
|
41
|
+
expect absent-operand 2 'no script at gone.sh' "$rc" "$out"
|
|
42
|
+
|
|
43
|
+
# --- an operand is read tracked or not, and narrows the corpus to itself.
|
|
44
|
+
mkdir -p "$SANDBOX/operand"
|
|
45
|
+
cp "$CASES/bad/rules.list" "$SANDBOX/operand/"
|
|
46
|
+
printf '#!/usr/bin/env bash\npkill -f job\n' > "$SANDBOX/operand/one.sh"
|
|
47
|
+
out="$( cd "$SANDBOX/operand" && gate_env GATE_SDK_SCRIPT_RULES=rules.list \
|
|
48
|
+
&& gate_run check-script-preflight "$CHECKS" one.sh 2>&1 )"; rc=$?
|
|
49
|
+
expect operand 1 'one.sh:2: [KILL-BROAD] pkill' "$rc" "$out"
|
|
50
|
+
|
|
51
|
+
# --- the rules file: absent while a corpus is configured is refused at 2, unreadable is 3, and a
|
|
52
|
+
# malformed one is 2 naming its file and line.
|
|
53
|
+
out="$( cd "$SANDBOX/operand" && gate_env GATE_SDK_SCRIPT_RULES=missing.list \
|
|
54
|
+
&& gate_run check-script-preflight "$CHECKS" one.sh 2>&1 )"; rc=$?
|
|
55
|
+
expect rules-absent 2 'missing.list' "$rc" "$out"
|
|
56
|
+
printf 'rule KILL command\n cmd pkill\n\xff\n' > "$SANDBOX/operand/binary.list"
|
|
57
|
+
out="$( cd "$SANDBOX/operand" && gate_env GATE_SDK_SCRIPT_RULES=binary.list \
|
|
58
|
+
&& gate_run check-script-preflight "$CHECKS" one.sh 2>&1 )"; rc=$?
|
|
59
|
+
expect rules-unreadable 3 'binary.list' "$rc" "$out"
|
|
60
|
+
printf 'waiver-min 2\nrule KILL command\n cmd pkill\n allow (\n' > "$SANDBOX/operand/ere.list"
|
|
61
|
+
out="$( cd "$SANDBOX/operand" && gate_env GATE_SDK_SCRIPT_RULES=ere.list \
|
|
62
|
+
&& gate_run check-script-preflight "$CHECKS" one.sh 2>&1 )"; rc=$?
|
|
63
|
+
expect rules-ere 2 'ere.list:4: allow:' "$rc" "$out"
|
|
64
|
+
printf 'rule kill command\n cmd pkill\n' > "$SANDBOX/operand/id.list"
|
|
65
|
+
out="$( cd "$SANDBOX/operand" && gate_env GATE_SDK_SCRIPT_RULES=id.list \
|
|
66
|
+
&& gate_run check-script-preflight "$CHECKS" one.sh 2>&1 )"; rc=$?
|
|
67
|
+
expect rules-id 2 'id.list:1: rule id' "$rc" "$out"
|
|
68
|
+
printf 'rule KILL command\n allow x\n' > "$SANDBOX/operand/missing-key.list"
|
|
69
|
+
out="$( cd "$SANDBOX/operand" && gate_env GATE_SDK_SCRIPT_RULES=missing-key.list \
|
|
70
|
+
&& gate_run check-script-preflight "$CHECKS" one.sh 2>&1 )"; rc=$?
|
|
71
|
+
expect rules-missing-key 2 "missing-key.list:1: rule KILL lacks its 'cmd' key" "$rc" "$out"
|
|
72
|
+
|
|
73
|
+
# --- a span the reader cannot read is LINT-PARSE at 3; a script not UTF-8 is 3.
|
|
74
|
+
printf '#!/usr/bin/env bash\necho "open\n' > "$SANDBOX/operand/broken.sh"
|
|
75
|
+
out="$( cd "$SANDBOX/operand" && gate_env GATE_SDK_SCRIPT_RULES=rules.list \
|
|
76
|
+
&& gate_run check-script-preflight "$CHECKS" broken.sh 2>&1 )"; rc=$?
|
|
77
|
+
expect lint-parse 3 'broken.sh:2: [LINT-PARSE] unparseable span' "$rc" "$out"
|
|
78
|
+
printf 'echo \xff\n' > "$SANDBOX/operand/bytes.sh"
|
|
79
|
+
out="$( cd "$SANDBOX/operand" && gate_env GATE_SDK_SCRIPT_RULES=rules.list \
|
|
80
|
+
&& gate_run check-script-preflight "$CHECKS" bytes.sh 2>&1 )"; rc=$?
|
|
81
|
+
expect not-utf8 3 'bytes.sh' "$rc" "$out"
|
|
82
|
+
|
|
83
|
+
# --- the knob's pathspecs select tracked files only, and the prune set is never read.
|
|
84
|
+
mkdir -p "$SANDBOX/tree/target" "$SANDBOX/tree/lib"
|
|
85
|
+
cp "$CASES/bad/rules.list" "$SANDBOX/tree/"
|
|
86
|
+
printf 'pkill -P "$pid"\n' > "$SANDBOX/tree/lib/ok.sh"
|
|
87
|
+
printf 'pkill -f job\n' > "$SANDBOX/tree/target/built.sh"
|
|
88
|
+
printf 'pkill -f job\n' > "$SANDBOX/tree/untracked.sh"
|
|
89
|
+
git -C "$SANDBOX/tree" init -q
|
|
90
|
+
git -C "$SANDBOX/tree" add lib/ok.sh target/built.sh
|
|
91
|
+
out="$( cd "$SANDBOX/tree" && gate_env 'GATE_SDK_SCRIPT_FILES=*.sh' GATE_SDK_SCRIPT_RULES=rules.list \
|
|
92
|
+
&& gate_run check-script-preflight "$CHECKS" 2>&1 )"; rc=$?
|
|
93
|
+
expect tracked-pruned 0 'clean (1 script(s) read against 4 rule(s)' "$rc" "$out"
|
|
94
|
+
refute tracked-only 'untracked.sh' "$out"
|
|
95
|
+
|
|
96
|
+
# --- outside a work tree the tracked listing fails, and the gate reads that as exit 3, never clean.
|
|
97
|
+
out="$( cd "$SANDBOX/empty" && gate_env 'GATE_SDK_SCRIPT_FILES=*.sh' GATE_SDK_SCRIPT_RULES=rules.list \
|
|
98
|
+
&& gate_run check-script-preflight "$CHECKS" 2>&1 )"; rc=$?
|
|
99
|
+
expect no-work-tree 3 'check-script-preflight' "$rc" "$out"
|
|
100
|
+
|
|
101
|
+
# --- an option the gate does not take is a usage error.
|
|
102
|
+
out="$( cd "$SANDBOX/empty" && gate_run check-script-preflight "$CHECKS" --all 2>&1 )"; rc=$?
|
|
103
|
+
expect usage 2 'unknown option --all' "$rc" "$out"
|
|
104
|
+
|
|
105
|
+
if [[ "$fails" -gt 0 ]]; then
|
|
106
|
+
echo "check-script-preflight.test.sh: $fails case(s) failed"
|
|
107
|
+
exit 1
|
|
108
|
+
fi
|
|
109
|
+
echo "check-script-preflight.test.sh: clean (configuration, operands, the rules file's exit classes, LINT-PARSE and the tracked corpus — $cases cases)"
|
|
110
|
+
exit 0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
GATE_SDK_SITE_RULES = rules.list
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
tool push
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
tool fetch --account pinned
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
SITE-COUNT: clean (2 file(s) read against 1 rule(s) in rules.list)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
GATE_SDK_SITE_RULES = rules.list
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
a file with no site and no row
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Behavioral test of check-site-count over what the good/+bad/ pair cannot reach: an empty
|
|
3
|
+
# configuration, the baseline's exit-2 and exit-3 classes, a malformed rules file, the test-code
|
|
4
|
+
# classifier's knob and its Rust test module, and a tree with no git listing.
|
|
5
|
+
#
|
|
6
|
+
# Run by the --run-gate-tests arm (any <tests-dir>/*.test.sh; must exit 0).
|
|
7
|
+
set -uo pipefail
|
|
8
|
+
source "$(dirname "${BASH_SOURCE[0]}")/../../gate-sdk/lib/test-hermetic.sh"
|
|
9
|
+
|
|
10
|
+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # gate-sdk/
|
|
11
|
+
CHECKS="$DIR/checks"
|
|
12
|
+
SANDBOX="$(mktemp -d)"
|
|
13
|
+
trap 'rm -rf "$SANDBOX"' EXIT
|
|
14
|
+
|
|
15
|
+
fails=0
|
|
16
|
+
cases=0
|
|
17
|
+
|
|
18
|
+
expect() { # expect <label> <want-rc> <substring> <got-rc> <output>
|
|
19
|
+
cases=$((cases + 1))
|
|
20
|
+
if [[ "$4" -ne "$2" ]]; then
|
|
21
|
+
echo " FAIL [$1]: want exit $2, got $4 -- $5"; fails=$((fails + 1))
|
|
22
|
+
elif ! grep -qF -- "$3" <<<"$5"; then
|
|
23
|
+
echo " FAIL [$1]: exit $2 but output lacks '$3': $5"; fails=$((fails + 1))
|
|
24
|
+
fi
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# --- no rules file, or one holding no block: clean, not applicable.
|
|
28
|
+
mkdir -p "$SANDBOX/empty"
|
|
29
|
+
out="$( cd "$SANDBOX/empty" && gate_run check-site-count "$CHECKS" 2>&1 )"; rc=$?
|
|
30
|
+
expect not-applicable 0 'not applicable: no site rule configured' "$rc" "$out"
|
|
31
|
+
printf '# no rule yet\n' > "$SANDBOX/empty/rules.list"
|
|
32
|
+
out="$( cd "$SANDBOX/empty" && gate_env GATE_SDK_SITE_RULES=rules.list \
|
|
33
|
+
&& gate_run check-site-count "$CHECKS" 2>&1 )"; rc=$?
|
|
34
|
+
expect no-block 0 'not applicable: no site rule configured' "$rc" "$out"
|
|
35
|
+
|
|
36
|
+
# --- a rules file the gate cannot read is 3; a malformed one is 2 naming its line.
|
|
37
|
+
printf 'rule A site-count\n\xff\n' > "$SANDBOX/empty/bytes.list"
|
|
38
|
+
out="$( cd "$SANDBOX/empty" && gate_env GATE_SDK_SITE_RULES=bytes.list \
|
|
39
|
+
&& gate_run check-site-count "$CHECKS" 2>&1 )"; rc=$?
|
|
40
|
+
expect rules-unreadable 3 'bytes.list' "$rc" "$out"
|
|
41
|
+
printf 'rule A site-count\n site x\n' > "$SANDBOX/empty/no-baseline.list"
|
|
42
|
+
out="$( cd "$SANDBOX/empty" && gate_env GATE_SDK_SITE_RULES=no-baseline.list \
|
|
43
|
+
&& gate_run check-site-count "$CHECKS" 2>&1 )"; rc=$?
|
|
44
|
+
expect rules-missing-key 2 "no-baseline.list:1: rule A lacks its 'baseline' key" "$rc" "$out"
|
|
45
|
+
|
|
46
|
+
# --- outside a work tree there is no tracked listing, which is refused, never clean.
|
|
47
|
+
printf 'rule A site-count\n site x\n baseline sites.tsv\n' > "$SANDBOX/empty/rules.list"
|
|
48
|
+
out="$( cd "$SANDBOX/empty" && gate_env GATE_SDK_SITE_RULES=rules.list \
|
|
49
|
+
&& gate_run check-site-count "$CHECKS" 2>&1 )"; rc=$?
|
|
50
|
+
expect no-work-tree 2 'not a git repository' "$rc" "$out"
|
|
51
|
+
|
|
52
|
+
# --- a tracked tree: the baseline's classes, then the test-code classifier.
|
|
53
|
+
mkdir -p "$SANDBOX/tree/src" "$SANDBOX/tree/tests"
|
|
54
|
+
printf 'rule CLI site-count\n site ^tool \n baseline sites.tsv\n paths src tests\n' > "$SANDBOX/tree/rules.list"
|
|
55
|
+
printf 'tool a\n#[cfg(test)]\ntool b\n' > "$SANDBOX/tree/src/lib.rs"
|
|
56
|
+
printf 'tool c\n' > "$SANDBOX/tree/tests/run.sh"
|
|
57
|
+
git -C "$SANDBOX/tree" init -q
|
|
58
|
+
git -C "$SANDBOX/tree" add src/lib.rs tests/run.sh
|
|
59
|
+
run_tree() {
|
|
60
|
+
( cd "$SANDBOX/tree" && gate_env GATE_SDK_SITE_RULES=rules.list "$@" \
|
|
61
|
+
&& gate_run check-site-count "$CHECKS" 2>&1 )
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
out="$(run_tree)"; rc=$?
|
|
65
|
+
expect baseline-absent 2 'sites.tsv' "$rc" "$out"
|
|
66
|
+
printf '1 src/lib.rs\n' > "$SANDBOX/tree/sites.tsv"
|
|
67
|
+
out="$(run_tree)"; rc=$?
|
|
68
|
+
expect baseline-no-tab 3 'sites.tsv:1:' "$rc" "$out"
|
|
69
|
+
printf '1\tsrc/lib.rs\n1\tsrc/lib.rs\n' > "$SANDBOX/tree/sites.tsv"
|
|
70
|
+
out="$(run_tree)"; rc=$?
|
|
71
|
+
expect baseline-duplicate 3 'sites.tsv:2: src/lib.rs is given a second row' "$rc" "$out"
|
|
72
|
+
|
|
73
|
+
# The Rust test module and the tests/ directory are test code under the default globs.
|
|
74
|
+
printf '1\tsrc/lib.rs\n' > "$SANDBOX/tree/sites.tsv"
|
|
75
|
+
out="$(run_tree)"; rc=$?
|
|
76
|
+
expect test-code-skipped 0 'clean (1 file(s) read against 1 rule(s) in rules.list)' "$rc" "$out"
|
|
77
|
+
# An emptied knob names no test path, so the tests/ file is read; the Rust module is still cut.
|
|
78
|
+
out="$(run_tree GATE_SDK_TEST_GLOBS=)"; rc=$?
|
|
79
|
+
expect test-globs-empty 1 'tests/run.sh: [CLI] 1/0' "$rc" "$out"
|
|
80
|
+
|
|
81
|
+
# --- an argument is a usage error.
|
|
82
|
+
out="$( cd "$SANDBOX/empty" && gate_run check-site-count "$CHECKS" extra 2>&1 )"; rc=$?
|
|
83
|
+
expect usage 2 'takes no arguments' "$rc" "$out"
|
|
84
|
+
|
|
85
|
+
if [[ "$fails" -gt 0 ]]; then
|
|
86
|
+
echo "check-site-count.test.sh: $fails case(s) failed"
|
|
87
|
+
exit 1
|
|
88
|
+
fi
|
|
89
|
+
echo "check-site-count.test.sh: clean (configuration, the rules file and baseline exit classes, and the test-code classifier — $cases cases)"
|
|
90
|
+
exit 0
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
match a banned pattern
|
|
2
|
-
tree/leak.txt:1:
|
|
3
|
-
tree/multi.txt:1:
|
|
4
|
-
tree/multi.txt:3:
|
|
5
|
-
tree/multi.txt:4:
|
|
6
|
-
tree/second-leak.txt:2:
|
|
7
|
-
tree/accounts.txt:1:
|
|
8
|
-
tree/msg-patterns.old.list:1:
|
|
1
|
+
match a banned pattern or deny term
|
|
2
|
+
tree/leak.txt:1: [HOME-PATH]
|
|
3
|
+
tree/multi.txt:1: [HOME-PATH]
|
|
4
|
+
tree/multi.txt:3: [HOME-PATH]
|
|
5
|
+
tree/multi.txt:4: [HOME-PATH]
|
|
6
|
+
tree/second-leak.txt:2: [TEXT-DENIED]
|
|
7
|
+
tree/accounts.txt:1: [TEXT-DENIED]
|
|
8
|
+
tree/msg-patterns.old.list:1: [HOME-PATH]
|
|
9
|
+
tree/terms.txt:1: [CODENAME]
|
|
10
|
+
tree/terms.txt:1: [HOME-PATH]
|
|
11
|
+
tree/terms.txt:2: [TEXT-DENIED]
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# banned-pattern fixture (grep -E, one per line; '#' + blank ignored)
|
|
2
|
-
/(home|Users)/[A-Za-z0-9._-]+
|
|
3
2
|
claude\.com/claude-code
|
|
4
3
|
|
|
5
4
|
# Account-identification class — a handle-shaped backticked token near an
|
|
6
5
|
# account noun. Cite the role, never the account; a CLI name is not a handle.
|
|
7
6
|
(^|[^A-Za-z])(accounts?|logins?|usernames?|handles?)[^A-Za-z`-][^`]{0,6}`([a-z]*[0-9A-Z][A-Za-z0-9_.-]*|[a-z]+[_.-][A-Za-z0-9_.-]*|[_.-]+[A-Za-z0-9][A-Za-z0-9_.-]*|[a-z]{6,})`|`([a-z]*[0-9A-Z][A-Za-z0-9_.-]*|[a-z]+[_.-][A-Za-z0-9_.-]*|[_.-]+[A-Za-z0-9][A-Za-z0-9_.-]*|[a-z]{6,})`[^A-Za-z`][^`]{0,6}(accounts?|logins?|usernames?|handles?)([^A-Za-z-]|$)
|
|
7
|
+
|
|
8
|
+
# A rule id names every pattern after it; the ones above take the default id.
|
|
9
|
+
# rule: HOME-PATH
|
|
10
|
+
/(home|Users)/[A-Za-z0-9._-]+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
GATE_SDK_DENY_TERMS = terms.list
|
|
@@ -1 +1 @@
|
|
|
1
|
-
TREE-TERMS: clean (
|
|
1
|
+
TREE-TERMS: clean (4 tracked file(s) scanned under tree; none match the 5 banned pattern(s) or 1 deny term(s))
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
The terms2 table and the determined reader hold it only inside longer words.
|
|
@@ -58,7 +58,7 @@ printf '# only a comment\n\n' > "$SANDBOX/repo/empty.list"
|
|
|
58
58
|
out="$( cd "$SANDBOX/repo" \
|
|
59
59
|
&& gate_env GATE_SDK_MSG_PATTERN_FILES="$SANDBOX/repo/empty.list" \
|
|
60
60
|
&& gate_run check-tree-terms "$CHECKS" . 2>&1 )"; rc=$?
|
|
61
|
-
expect empty-pattern-set 0 '0 banned pattern(s) configured; tree unchecked' "$rc" "$out"
|
|
61
|
+
expect empty-pattern-set 0 '0 banned pattern(s) and 0 deny term(s) configured; tree unchecked' "$rc" "$out"
|
|
62
62
|
|
|
63
63
|
# --- a banned shape inside a tracked binary: a path-only record, and still red.
|
|
64
64
|
# Dead on this tree (no tracked binaries) and live in a consumer's, which is why
|
|
@@ -70,7 +70,7 @@ printf 'PNG\x00\x01 clone into /%s/bob/x and more\x00bytes\n' home > "$SANDBOX/r
|
|
|
70
70
|
printf '/(home|Users)/[A-Za-z0-9._-]+\n' > "$SANDBOX/repo/banned.list"
|
|
71
71
|
git -C "$SANDBOX/repo" add blob.bin
|
|
72
72
|
out="$( cd "$SANDBOX/repo" && gate_run check-tree-terms "$CHECKS" . banned.list 2>&1 )"; rc=$?
|
|
73
|
-
expect binary-record 1 'blob.bin' "$rc" "$out"
|
|
73
|
+
expect binary-record 1 'blob.bin: [TEXT-DENIED]' "$rc" "$out"
|
|
74
74
|
if grep -qE '^blob\.bin:[0-9]+:' <<<"$out"; then
|
|
75
75
|
echo " FAIL [binary-record]: a binary match must not carry :lineno:line -- $out"
|
|
76
76
|
fails=$((fails + 1))
|
|
@@ -101,23 +101,43 @@ else
|
|
|
101
101
|
echo " SKIP [dangling-symlink]: ln -s failed — creating a symlink needs a privilege this account may not hold; the arm's precondition is a platform capability, so it declares the skip rather than reporting a failure."
|
|
102
102
|
fi
|
|
103
103
|
|
|
104
|
+
# --- a '# rule:' line whose id fails the class grammar is refused at 2, naming the
|
|
105
|
+
# file and line; a deny-term list that is there and is no regular file is input at 3.
|
|
106
|
+
printf 'a-pattern\n# rule: not-upper\nb-pattern\n' > "$SANDBOX/repo/badrule.list"
|
|
107
|
+
out="$( cd "$SANDBOX/repo" && gate_run check-tree-terms "$CHECKS" . badrule.list 2>&1 )"; rc=$?
|
|
108
|
+
expect malformed-rule-id 2 'badrule.list:2:' "$rc" "$out"
|
|
109
|
+
if grep -qF 'not-upper' <<<"$out"; then
|
|
110
|
+
echo " FAIL [malformed-rule-id]: the refusal must not print the id -- $out"; fails=$((fails + 1))
|
|
111
|
+
fi
|
|
112
|
+
mkdir -p "$SANDBOX/repo/terms-dir.list"
|
|
113
|
+
out="$( cd "$SANDBOX/repo" \
|
|
114
|
+
&& gate_env GATE_SDK_DENY_TERMS="$SANDBOX/repo/terms-dir.list" \
|
|
115
|
+
&& gate_run check-tree-terms "$CHECKS" . empty.list 2>&1 )"; rc=$?
|
|
116
|
+
expect unreadable-term-list 3 'not a regular file' "$rc" "$out"
|
|
117
|
+
|
|
104
118
|
# --- multi-record order over the tracked bad/ case: path order, then line order,
|
|
105
|
-
# one record per matching *line*
|
|
106
|
-
# two identical lines. Read off the
|
|
107
|
-
|
|
119
|
+
# then id order, one record per matching *line* per distinct id however many
|
|
120
|
+
# patterns or terms hit it, and no dedup of two identical lines. Read off the
|
|
121
|
+
# pair so the corpus has one home; the knob files are pinned away here, so the
|
|
122
|
+
# case's term list is handed over by the environment.
|
|
123
|
+
out="$( cd "$CASES/bad" && gate_env GATE_SDK_DENY_TERMS=terms.list \
|
|
124
|
+
&& gate_run check-tree-terms "$CHECKS" tree patterns.list 2>&1 )"; rc=$?
|
|
108
125
|
got="$(grep -E '^tree/' <<<"$out")"
|
|
109
126
|
want="$(printf '%s\n' \
|
|
110
|
-
'tree/accounts.txt:1:' \
|
|
111
|
-
'tree/leak.txt:1:' \
|
|
112
|
-
'tree/msg-patterns.old.list:1:' \
|
|
113
|
-
'tree/multi.txt:1:' \
|
|
114
|
-
'tree/multi.txt:3:' \
|
|
115
|
-
'tree/multi.txt:4:' \
|
|
116
|
-
'tree/second-leak.txt:2:'
|
|
127
|
+
'tree/accounts.txt:1: [TEXT-DENIED]' \
|
|
128
|
+
'tree/leak.txt:1: [HOME-PATH]' \
|
|
129
|
+
'tree/msg-patterns.old.list:1: [HOME-PATH]' \
|
|
130
|
+
'tree/multi.txt:1: [HOME-PATH]' \
|
|
131
|
+
'tree/multi.txt:3: [HOME-PATH]' \
|
|
132
|
+
'tree/multi.txt:4: [HOME-PATH]' \
|
|
133
|
+
'tree/second-leak.txt:2: [TEXT-DENIED]' \
|
|
134
|
+
'tree/terms.txt:1: [CODENAME]' \
|
|
135
|
+
'tree/terms.txt:1: [HOME-PATH]' \
|
|
136
|
+
'tree/terms.txt:2: [TEXT-DENIED]')"
|
|
117
137
|
if [[ "$rc" -ne 1 ]]; then
|
|
118
138
|
echo " FAIL [record-order]: want exit 1, got $rc -- $out"; fails=$((fails + 1))
|
|
119
|
-
elif [[ "$
|
|
120
|
-
echo " FAIL [record-order]: record sequence is not path-then-line order:"
|
|
139
|
+
elif [[ "$got" != "$want" ]]; then
|
|
140
|
+
echo " FAIL [record-order]: record sequence is not path-then-line-then-id order:"
|
|
121
141
|
printf ' %s\n' "$got"
|
|
122
142
|
fails=$((fails + 1))
|
|
123
143
|
fi
|
|
@@ -127,8 +147,8 @@ if [[ "$fails" -gt 0 ]]; then
|
|
|
127
147
|
exit 1
|
|
128
148
|
fi
|
|
129
149
|
if [[ "$link_arm" == run ]]; then
|
|
130
|
-
echo "check-tree-terms.test.sh: clean (the arms a case dir cannot reach or may not ship: a non-repository cwd, the env-knob resolution path through a missing required pattern file, an empty pattern set leaving the tree unchecked, a banned shape inside a tracked binary yielding a path-only record, a tracked dangling symlink skipped rather than scanned, and the bad pair's record order —
|
|
150
|
+
echo "check-tree-terms.test.sh: clean (the arms a case dir cannot reach or may not ship: a non-repository cwd, the env-knob resolution path through a missing required pattern file, an empty pattern set leaving the tree unchecked, a banned shape inside a tracked binary yielding a path-only record, a tracked dangling symlink skipped rather than scanned, a malformed rule id refused without printing it, a deny-term list that is no regular file, and the bad pair's record order — 11 assertions over 8 cases)"
|
|
131
151
|
else
|
|
132
|
-
echo "check-tree-terms.test.sh: clean (the arms a case dir cannot reach: a non-repository cwd, the env-knob resolution path through a missing required pattern file, an empty pattern set leaving the tree unchecked, a banned shape inside a tracked binary yielding a path-only record, and the bad pair's record order —
|
|
152
|
+
echo "check-tree-terms.test.sh: clean (the arms a case dir cannot reach: a non-repository cwd, the env-knob resolution path through a missing required pattern file, an empty pattern set leaving the tree unchecked, a banned shape inside a tracked binary yielding a path-only record, a malformed rule id refused without printing it, a deny-term list that is no regular file, and the bad pair's record order — 9 assertions over 7 cases; the dangling-symlink arm declared a skip above, this host refusing ln -s)"
|
|
133
153
|
fi
|
|
134
154
|
exit 0
|
|
@@ -26,13 +26,12 @@ done
|
|
|
26
26
|
|
|
27
27
|
# spec: gate-sdk/SPEC.md §enforcement-map — adopted-but-broken refuses: a knob
|
|
28
28
|
# explicitly set to a missing path exits 2 before the first stdout byte, the
|
|
29
|
-
# stderr line naming the knob;
|
|
30
|
-
# cannot parse.
|
|
29
|
+
# stderr line naming the knob; a set settings file it cannot parse exits 3.
|
|
31
30
|
errfile="$scratch/stderr"
|
|
32
|
-
assert_strict() { # $1=case $2=knob-name $3=knob-value
|
|
33
|
-
local out rc
|
|
31
|
+
assert_strict() { # $1=case $2=knob-name $3=knob-value [$4=want status, default 2]
|
|
32
|
+
local out rc want="${4:-2}"
|
|
34
33
|
out="$(env "$2=$3" bash "${EMIT[@]}" 2>"$errfile")"; rc=$?
|
|
35
|
-
[[ "$rc" -eq
|
|
34
|
+
[[ "$rc" -eq "$want" ]] || { echo "FAIL [$1]: expected exit $want, got $rc"; fails=$((fails + 1)); }
|
|
36
35
|
[[ -z "$out" ]] || { echo "FAIL [$1]: expected empty stdout"; fails=$((fails + 1)); }
|
|
37
36
|
grep -qF -- "$2" "$errfile" || { echo "FAIL [$1]: stderr does not name $2"; fails=$((fails + 1)); }
|
|
38
37
|
}
|
|
@@ -41,7 +40,7 @@ assert_strict strict-settings CONTEXT_KIT_SETTINGS_FILE /nonexistent/settings.j
|
|
|
41
40
|
assert_strict strict-evidence EVIDENCE_KIT_KNOB_FILE /nonexistent/evidence-config.knobs
|
|
42
41
|
assert_strict strict-scandir GATE_SDK_ENFORCE_SCAN_DIR /nonexistent/scandir
|
|
43
42
|
printf '{ not json\n' > "$scratch/bad-settings.json"
|
|
44
|
-
assert_strict strict-settings-unparseable CONTEXT_KIT_SETTINGS_FILE "$scratch/bad-settings.json"
|
|
43
|
+
assert_strict strict-settings-unparseable CONTEXT_KIT_SETTINGS_FILE "$scratch/bad-settings.json" 3
|
|
45
44
|
|
|
46
45
|
# spec: gate-sdk/SPEC.md §enforcement-map — not-adopted degrades: an unset knob
|
|
47
46
|
# whose default path is absent drops exactly its own section. A scratch
|
|
@@ -25,10 +25,10 @@ fail_closed 0 check-x awk
|
|
|
25
25
|
reached=yes
|
|
26
26
|
[[ "$reached" == yes ]] || { echo " FAIL: fail_closed 0 aborted the caller"; fails=$((fails + 1)); }
|
|
27
27
|
|
|
28
|
-
# Branch 2: non-zero status -> exit
|
|
28
|
+
# Branch 2: non-zero status -> exit 3 + diagnostic on stderr (run in a subshell
|
|
29
29
|
# so the exit doesn't abort this test).
|
|
30
30
|
out="$( ( fail_closed 2 check-x awk ) 2>&1 )"; rc=$?
|
|
31
|
-
[[ "$rc" -eq
|
|
31
|
+
[[ "$rc" -eq 3 ]] || { echo " FAIL: fail_closed 2 should exit 3, exited $rc"; fails=$((fails + 1)); }
|
|
32
32
|
grep -qF 'the check could not run' <<<"$out" \
|
|
33
33
|
|| { echo " FAIL: fail_closed 2 missing 'the check could not run': $out"; fails=$((fails + 1)); }
|
|
34
34
|
|
|
@@ -154,16 +154,16 @@ got="$(gate_command check-rs "$sandbox/a" | paste -sd' ' -)"
|
|
|
154
154
|
[[ "$?" -eq 2 ]] \
|
|
155
155
|
|| { echo " FAIL: gate_command did not exit 2 on the arm's refusal"; fails=$((fails + 1)); }
|
|
156
156
|
|
|
157
|
-
# fail-closed: an absent binary is exit
|
|
157
|
+
# fail-closed: an absent binary is exit 3, never a skip and never a pass
|
|
158
158
|
( GATE_SDK_NATIVE_BIN="$sandbox/nope" gate_command check-ported "$sandbox/a" "$sandbox/b" >/dev/null 2>&1 )
|
|
159
|
-
[[ "$?" -eq
|
|
160
|
-
|| { echo " FAIL: gate_command did not exit
|
|
159
|
+
[[ "$?" -eq 3 ]] \
|
|
160
|
+
|| { echo " FAIL: gate_command did not exit 3 on an absent native binary"; fails=$((fails + 1)); }
|
|
161
161
|
|
|
162
|
-
# fail-closed: present but non-executable is the same
|
|
162
|
+
# fail-closed: present but non-executable is the same tool error
|
|
163
163
|
: >"$sandbox/notexec"; chmod -x "$sandbox/notexec"
|
|
164
164
|
( GATE_SDK_NATIVE_BIN="$sandbox/notexec" gate_command check-ported "$sandbox/a" "$sandbox/b" >/dev/null 2>&1 )
|
|
165
|
-
[[ "$?" -eq
|
|
166
|
-
|| { echo " FAIL: gate_command did not exit
|
|
165
|
+
[[ "$?" -eq 3 ]] \
|
|
166
|
+
|| { echo " FAIL: gate_command did not exit 3 on a non-executable native binary"; fails=$((fails + 1)); }
|
|
167
167
|
|
|
168
168
|
if [[ "$fails" -gt 0 ]]; then
|
|
169
169
|
echo "lib-gate.test: $fails assertion(s) failed"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# spec: gate-sdk/SPEC.md §git-hook — the binary under a served hook's name is that hook's launcher: git starts it with no interpreter, a clean commit lands on the summary line, a red member refuses the commit by gate name, a registry with no commit-msg member leaves that hook silent, a binary that cannot be started refuses naming the path and both remedies, a knob naming a hook's own name is refused at 2, a knob-file line naming any other knob is skipped unread while one setting the launcher's own knob as no scalar is refused at 2, a registered member whose declaration resolves and cannot be read refuses either hook at 2, and beside the chain record a placed hook runs the prior hook of its name first, a failing one ending the hook with the gates unrun, while a forwarding hook runs the prior hook of its own name
|
|
3
|
-
# spec: gate-sdk/SPEC.md §install-hooks — the arm places both hooks untracked in gate-hooks under the common git directory with an absolute core.hooksPath, so a linked worktree runs them; a re-run replaces both; an absent binary refuses at
|
|
3
|
+
# spec: gate-sdk/SPEC.md §install-hooks — the arm places both hooks untracked in gate-hooks under the common git directory with an absolute core.hooksPath, so a linked worktree runs them; a re-run replaces both; an absent binary refuses at 3 and places nothing; a failed core.hooksPath write refuses at 3 ahead of the receipt; a failed blame.ignoreRevsFile write is reported with the status unmoved; a hook left behind by a replaced binary starts the binary now installed; --refresh re-places both hooks of an opted-in clone from a replaced binary with no config write, and places nothing off the work-tree top or in a clone not opted in; a clone already running hooks is chained, its live prior hooks named on stdout
|
|
4
4
|
set -uo pipefail
|
|
5
5
|
source "$(dirname "${BASH_SOURCE[0]}")/../../gate-sdk/lib/test-hermetic.sh"
|
|
6
6
|
|
|
@@ -45,7 +45,7 @@ hooks="$repo/.git/gate-hooks"
|
|
|
45
45
|
# 1. an absent binary refuses the opt-in at 2 and places nothing
|
|
46
46
|
mv "$repo/$bin_rel" "$SANDBOX/held"
|
|
47
47
|
out="$( cd "$repo" && "$SANDBOX/held" --install-hooks 2>&1 )"; rc=$?
|
|
48
|
-
[[ "$rc" -eq
|
|
48
|
+
[[ "$rc" -eq 3 ]] || note absent-install-status "want exit 3 with no binary at the knob's path, got $rc -- $out"
|
|
49
49
|
grep -qF "no gate binary at $bin_rel" <<<"$out" || note absent-install-text "the refusal does not name the path: $out"
|
|
50
50
|
[[ -e "$hooks" ]] && note absent-install-wrote "a refused opt-in left a hooks directory"
|
|
51
51
|
[[ -z "$(git -C "$repo" config --get core.hooksPath)" ]] || note absent-install-config "a refused opt-in set core.hooksPath"
|
|
@@ -158,7 +158,7 @@ done
|
|
|
158
158
|
: >"$repo/.git/config.lock"
|
|
159
159
|
out="$( cd "$repo" && "./$bin_rel" --install-hooks 2>&1 )"; rc=$?
|
|
160
160
|
rm -f "$repo/.git/config.lock"
|
|
161
|
-
[[ "$rc" -eq
|
|
161
|
+
[[ "$rc" -eq 3 ]] || note unwired-status "want exit 3 when core.hooksPath cannot be written, got $rc -- $out"
|
|
162
162
|
grep -qF 'could not set core.hooksPath' <<<"$out" || note unwired-text "the refusal does not name the key: $out"
|
|
163
163
|
grep -qF 'Active hooks:' <<<"$out" && note unwired-receipt "a refused opt-in printed its receipt: $out"
|
|
164
164
|
|
|
@@ -186,7 +186,7 @@ for pair in "commit-msg:check-probe-msg" "pre-commit:check-probe-word"; do
|
|
|
186
186
|
else
|
|
187
187
|
out="$( cd "$repo" && "./$bin_rel" --git-hook pre-commit 2>&1 )"; rc=$?
|
|
188
188
|
fi
|
|
189
|
-
[[ "$rc" -eq
|
|
189
|
+
[[ "$rc" -eq 3 ]] || note "unreadable-$hook-status" "want exit 3 over an unreadable resolved member, got $rc -- $out"
|
|
190
190
|
grep -qF "$hook: cannot read the declaration scripts/${pair##*:}.sh" <<<"$out" || note "unreadable-$hook-text" "the refusal does not name the declaration: $out"
|
|
191
191
|
fi
|
|
192
192
|
chmod 755 "$member"
|
|
@@ -222,7 +222,7 @@ EOF
|
|
|
222
222
|
export GATE_SDK_LOCAL_KNOB_FILE="$overlay_pin"
|
|
223
223
|
fi
|
|
224
224
|
|
|
225
|
-
# 15. --refresh re-places both hooks from a replaced binary and does nothing else; off the work-tree top it places nothing, and an absent binary refuses at
|
|
225
|
+
# 15. --refresh re-places both hooks from a replaced binary and does nothing else; off the work-tree top it places nothing, and an absent binary refuses at 3
|
|
226
226
|
digest() { git hash-object --no-filters -- "$1"; }
|
|
227
227
|
stale_hooks() { for h in pre-commit commit-msg; do rm -f "$hooks/$h$sfx"; printf 'stale\n' >"$hooks/$h$sfx"; done; }
|
|
228
228
|
stale_hooks
|
|
@@ -233,7 +233,7 @@ out="$( cd "$repo/scripts" && "../$bin_rel" --install-hooks --refresh 2>&1 )"; r
|
|
|
233
233
|
[[ "$(cat "$hooks/pre-commit$sfx")" == stale ]] || note refresh-subdir-placed "a refresh off the work-tree top re-placed a hook"
|
|
234
234
|
mv "$repo/$bin_rel" "$SANDBOX/held"
|
|
235
235
|
out="$( cd "$repo" && "$SANDBOX/held" --install-hooks --refresh 2>&1 )"; rc=$?
|
|
236
|
-
[[ "$rc" -eq
|
|
236
|
+
[[ "$rc" -eq 3 ]] || note refresh-absent-status "want exit 3 from a refresh with no binary at the knob's path, got $rc -- $out"
|
|
237
237
|
grep -qF "no gate binary at $bin_rel" <<<"$out" || note refresh-absent-text "the refusal does not name the path: $out"
|
|
238
238
|
mv "$SANDBOX/held" "$repo/$bin_rel"
|
|
239
239
|
before="$(git -C "$repo" config --list --local)"
|
|
@@ -290,5 +290,5 @@ if [[ -z "$sfx" ]]; then
|
|
|
290
290
|
fi
|
|
291
291
|
|
|
292
292
|
[[ "$fails" -eq 0 ]] || { echo "native-git-hooks.test: $fails assertion(s) failed"; exit 1; }
|
|
293
|
-
echo "native-git-hooks.test: clean (--install-hooks places both hooks untracked under the common git directory, absolute in core.hooksPath, refusing with nothing placed when the binary is absent; git starts the placed binary as each hook with no interpreter: a clean commit lands on the summary line, a red member refuses by gate name from the main checkout and from a linked worktree, the commit-msg hook is silent until a member registers at its tier and reaches one with no re-install; a hook outliving a replaced binary starts the installed one, an unstartable binary refuses naming the path and both remedies, a knob naming a hook is refused at 2, a re-run replaces both, a knob-file line naming a knob the launcher does not know is left to the installed build, --refresh re-places an opted-in clone's hooks and nothing else, a failed core.hooksPath write refuses at
|
|
293
|
+
echo "native-git-hooks.test: clean (--install-hooks places both hooks untracked under the common git directory, absolute in core.hooksPath, refusing with nothing placed when the binary is absent; git starts the placed binary as each hook with no interpreter: a clean commit lands on the summary line, a red member refuses by gate name from the main checkout and from a linked worktree, the commit-msg hook is silent until a member registers at its tier and reaches one with no re-install; a hook outliving a replaced binary starts the installed one, an unstartable binary refuses naming the path and both remedies, a knob naming a hook is refused at 2, a re-run replaces both, a knob-file line naming a knob the launcher does not know is left to the installed build, --refresh re-places an opted-in clone's hooks and nothing else, a failed core.hooksPath write refuses at 3 with no receipt, a failed blame.ignoreRevsFile write is reported at exit 0, an unreadable resolved member refuses either hook at 3, and a clone already running hooks keeps them, a prior pre-commit ahead of the gates and a prior post-commit through its forwarding hook, a failing prior hook refusing the commit with the gates unrun)"
|
|
294
294
|
exit 0
|
|
@@ -50,13 +50,13 @@ err="$(<"$scratch/err.txt")"
|
|
|
50
50
|
[[ -z "$err" ]] || { echo "FAIL [stdout-argv]: stderr was '$err'"; fails=$((fails + 1)); }
|
|
51
51
|
[[ "$rc" -eq 0 ]] || { echo "FAIL [stdout-argv]: expected exit 0, got $rc"; fails=$((fails + 1)); }
|
|
52
52
|
|
|
53
|
-
# Arm 2 — the stderr the split must not discard: an absent binary is gate_command's exit
|
|
53
|
+
# Arm 2 — the stderr the split must not discard: an absent binary is gate_command's exit 3, whose
|
|
54
54
|
# diagnostic body is stderr. Deleting the capture rather than splitting it would empty this report.
|
|
55
55
|
gate_command_argv "$scratch/absent-bin" >/dev/null; rc=$?
|
|
56
56
|
err="$(<"$scratch/err.txt")"
|
|
57
57
|
assert_has dispatch-err 'absent or not executable' "$err"
|
|
58
58
|
assert_has dispatch-err 'build-native.sh' "$err"
|
|
59
|
-
[[ "$rc" -eq
|
|
59
|
+
[[ "$rc" -eq 3 ]] || { echo "FAIL [dispatch-err]: expected exit 3, got $rc"; fails=$((fails + 1)); }
|
|
60
60
|
|
|
61
61
|
# Arm 3 — the arm's own tails over a hermetic registry, run through the real binary: a shell member
|
|
62
62
|
# that passes earns the exact green phrase, and a `.gate` naming a subcommand the binary does not
|
|
@@ -87,10 +87,10 @@ mkdir -p "$red"
|
|
|
87
87
|
printf 'check-noisy\n' > "$red/gates.list"
|
|
88
88
|
cp "$scratch/check-noisy.gate" "$red/check-noisy.gate"
|
|
89
89
|
out="$(run_battery "$red")"; rc=$?
|
|
90
|
-
assert_has arm-red ' FAIL: check-noisy (dispatch harness error, exit
|
|
90
|
+
assert_has arm-red ' FAIL: check-noisy (dispatch harness error, exit 3)' "$out"
|
|
91
91
|
assert_has arm-red 'no such gate subcommand' "$out"
|
|
92
92
|
assert_has arm-red '1 of 1 gates FAILED: check-noisy' "$out"
|
|
93
|
-
[[ "$rc" -eq
|
|
93
|
+
[[ "$rc" -eq 3 ]] || { echo "FAIL [arm-red]: expected exit 3 (an errored member alone is the error verdict), got $rc"; fails=$((fails + 1)); }
|
|
94
94
|
|
|
95
95
|
[[ "$fails" -eq 0 ]] || { echo "run-dispatch-streams.test: $fails assertion(s) failed"; exit 1; }
|
|
96
96
|
echo "run-dispatch-streams.test: clean (argv taken from stdout alone as the two-element binary form; the exit-2 diagnostic body still reaches the caller; the arm's green phrase and dispatch-harness-error tail hold over a hermetic registry)"
|
|
@@ -87,16 +87,16 @@ GATE_SDK_GATES_DIR="$scratch" GATE_SDK_KIT_DIRS="$scratch" \
|
|
|
87
87
|
GATE_SDK_TMP_DIR="$scratch/.tmp" bash "$RUN" --for >/dev/null 2>&1
|
|
88
88
|
[[ $? -eq 2 ]] || { echo "FAIL [usage]: --for with no path should exit 2"; fails=$((fails + 1)); }
|
|
89
89
|
|
|
90
|
-
# A member that resolves and cannot be read
|
|
90
|
+
# A member that resolves and cannot be read fails the selection at exit 3, never a
|
|
91
91
|
# narrower one; a host that reads through the mode cannot build the case.
|
|
92
92
|
chmod 000 "$scratch/g_glob.sh"
|
|
93
93
|
if ! head -c 1 "$scratch/g_glob.sh" >/dev/null 2>&1; then
|
|
94
94
|
out="$(run_for alpha/foo.txt)"; rc=$?
|
|
95
|
-
[[ "$rc" -eq
|
|
95
|
+
[[ "$rc" -eq 3 ]] || { echo "FAIL [unreadable]: expected exit 3, got $rc -- $out"; fails=$((fails + 1)); }
|
|
96
96
|
assert_has unreadable "run-gates: --for cannot read the declaration" "$out"
|
|
97
97
|
fi
|
|
98
98
|
chmod 755 "$scratch/g_glob.sh"
|
|
99
99
|
|
|
100
100
|
[[ "$fails" -eq 0 ]] || { echo "run-for-path.test: $fails assertion(s) failed"; exit 1; }
|
|
101
|
-
echo "run-for-path.test: clean (--for selects by shared matcher; trigger='*' universal, mode=staged pathspec passes args, ungoverned path noted and its empty selection logged or its bad result selection refused, an unreadable resolved member
|
|
101
|
+
echo "run-for-path.test: clean (--for selects by shared matcher; trigger='*' universal, mode=staged pathspec passes args, ungoverned path noted and its empty selection logged or its bad result selection refused, an unreadable resolved member failing at 3)"
|
|
102
102
|
exit 0
|