checkwright 0.37.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 +8 -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 +9 -4
- 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 +42 -0
- 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 +5 -2
- package/payload/delegation-kit/checks/check-brief-authority.gate +4 -0
- package/payload/delegation-kit/gate-tests/check-brief-authority/bad/args +1 -0
- package/payload/delegation-kit/gate-tests/check-brief-authority/bad/expect.txt +3 -0
- package/payload/delegation-kit/gate-tests/check-brief-authority/bad/grant.md +4 -0
- package/payload/delegation-kit/gate-tests/check-brief-authority/bad/rules.list +5 -0
- package/payload/delegation-kit/gate-tests/check-brief-authority/bad/scripts/delegation-config.knobs +2 -0
- package/payload/delegation-kit/gate-tests/check-brief-authority/bad/unquoted.md +2 -0
- package/payload/delegation-kit/gate-tests/check-brief-authority/good/args +1 -0
- package/payload/delegation-kit/gate-tests/check-brief-authority/good/brief.md +5 -0
- package/payload/delegation-kit/gate-tests/check-brief-authority/good/expect.txt +1 -0
- package/payload/delegation-kit/gate-tests/check-brief-authority/good/rules.list +5 -0
- package/payload/delegation-kit/gate-tests/check-brief-authority/good/scripts/delegation-config.knobs +2 -0
- package/payload/delegation-kit/gate-tests/check-gate-tamper.test.sh +90 -6
- package/payload/delegation-kit/templates/agent-execution.md +1 -1
- package/payload/delegation-kit/templates/brief-rules.list +20 -0
- package/payload/delegation-kit/templates/delegation-config.knobs +3 -0
- package/payload/doctrine-kit/gate-tests/check-doctrine-registration.test.sh +2 -2
- package/payload/drift-kit/README.md +1 -1
- 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-hook-knobs-fresh/good/args +1 -1
- package/payload/gate-sdk/gate-tests/check-hook-knobs-fresh/good/expect.txt +1 -1
- package/payload/gate-sdk/gate-tests/check-hook-knobs-fresh/good/hooks/agent-budget-guard.md +20 -0
- package/payload/gate-sdk/gate-tests/check-hook-knobs-fresh/good/hooks/agent-dispatch-guard.md +14 -0
- package/payload/gate-sdk/gate-tests/check-hook-knobs-fresh/good/hooks/escalation-guard.md +7 -0
- package/payload/gate-sdk/gate-tests/check-hook-knobs-fresh/good/hooks/wakeup-guard.md +9 -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,74 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Behavioral test of check-binary-strings over the arms the good/+bad/ pair cannot
|
|
3
|
+
# reach: a case names its outputs in its knob file and both of its outputs read,
|
|
4
|
+
# so a named output that is absent, an ELF header cut short, a GNU escape in a
|
|
5
|
+
# shape list and the record order across files live here. Each expect.txt line is
|
|
6
|
+
# an independent substring assertion, so record *order* is assertable only here.
|
|
7
|
+
#
|
|
8
|
+
# Run by the --run-gate-tests arm (any <tests-dir>/*.test.sh; must exit 0).
|
|
9
|
+
set -uo pipefail
|
|
10
|
+
source "$(dirname "${BASH_SOURCE[0]}")/../../gate-sdk/lib/test-hermetic.sh"
|
|
11
|
+
|
|
12
|
+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # gate-sdk/
|
|
13
|
+
CHECKS="$DIR/checks"
|
|
14
|
+
CASES="$DIR/gate-tests/check-binary-strings"
|
|
15
|
+
SANDBOX="$(mktemp -d)"
|
|
16
|
+
trap 'rm -rf "$SANDBOX"' EXIT
|
|
17
|
+
|
|
18
|
+
fails=0
|
|
19
|
+
|
|
20
|
+
expect() { # expect <label> <want-rc> <substring> <got-rc> <output>
|
|
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
|
+
mkdir -p "$SANDBOX/repo"
|
|
29
|
+
git -C "$SANDBOX/repo" init -q
|
|
30
|
+
|
|
31
|
+
# --- a named output that is not there refuses at 2: the knob names it exactly, so
|
|
32
|
+
# its absence is a layout the consumer must fix, never an output with no strings.
|
|
33
|
+
out="$( cd "$SANDBOX/repo" && gate_env GATE_SDK_STRINGS_FILES=absent.bin \
|
|
34
|
+
&& gate_run check-binary-strings "$CHECKS" 2>&1 )"; rc=$?
|
|
35
|
+
expect absent-output 2 'no build output at absent.bin' "$rc" "$out"
|
|
36
|
+
|
|
37
|
+
# --- an ELF64 little-endian file whose header is cut short is unparseable input at 3.
|
|
38
|
+
printf '\177ELF\002\001 cut short' > "$SANDBOX/repo/short.elf"
|
|
39
|
+
out="$( cd "$SANDBOX/repo" && gate_env GATE_SDK_STRINGS_FILES=short.elf \
|
|
40
|
+
&& gate_run check-binary-strings "$CHECKS" 2>&1 )"; rc=$?
|
|
41
|
+
expect truncated-elf 3 'ELF header truncated' "$rc" "$out"
|
|
42
|
+
|
|
43
|
+
# --- a GNU escape in a shape list is refused at 2, never read as a clean output.
|
|
44
|
+
printf 'plain bytes here\n' > "$SANDBOX/repo/plain.bin"
|
|
45
|
+
printf '\\bplain\\b\n' > "$SANDBOX/repo/gnu.list"
|
|
46
|
+
out="$( cd "$SANDBOX/repo" && gate_env GATE_SDK_STRINGS_FILES=plain.bin GATE_SDK_STRINGS_SHAPES=gnu.list \
|
|
47
|
+
&& gate_run check-binary-strings "$CHECKS" 2>&1 )"; rc=$?
|
|
48
|
+
expect gnu-escape 2 'shape-compile' "$rc" "$out"
|
|
49
|
+
|
|
50
|
+
# --- record order over the bad pair's outputs, named in reverse of their path order:
|
|
51
|
+
# files in knob order, then offset within a file, whichever list the hit came from.
|
|
52
|
+
out="$( cd "$CASES/bad" \
|
|
53
|
+
&& gate_env GATE_SDK_STRINGS_FILES='out/notes.bin out/app.elf' GATE_SDK_STRINGS_SHAPES=shapes.list \
|
|
54
|
+
GATE_SDK_DENY_TERMS=terms.list \
|
|
55
|
+
&& gate_run check-binary-strings "$CHECKS" 2>&1 )"; rc=$?
|
|
56
|
+
got="$(grep -E '^out/' <<<"$out")"
|
|
57
|
+
want="$(printf '%s\n' \
|
|
58
|
+
'out/notes.bin@11: [CODENAME] term 1' \
|
|
59
|
+
'out/app.elf@83: [HOME-PATH] shape 1' \
|
|
60
|
+
'out/app.elf@115: [CODENAME] term 1')"
|
|
61
|
+
if [[ "$rc" -ne 1 ]]; then
|
|
62
|
+
echo " FAIL [record-order]: want exit 1, got $rc -- $out"; fails=$((fails + 1))
|
|
63
|
+
elif [[ "$got" != "$want" ]]; then
|
|
64
|
+
echo " FAIL [record-order]: record sequence is not knob-then-offset order:"
|
|
65
|
+
printf ' %s\n' "$got"
|
|
66
|
+
fails=$((fails + 1))
|
|
67
|
+
fi
|
|
68
|
+
|
|
69
|
+
if [[ "$fails" -gt 0 ]]; then
|
|
70
|
+
echo "check-binary-strings.test.sh: $fails case(s) failed"
|
|
71
|
+
exit 1
|
|
72
|
+
fi
|
|
73
|
+
echo "check-binary-strings.test.sh: clean (the arms a case dir cannot reach: an absent named output, a truncated ELF header, a GNU escape in a shape list, and the record order across outputs — 4 cases)"
|
|
74
|
+
exit 0
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
src/caller.rs:4: [EXEC-WRITE] set_mode
|
|
2
|
+
src/sites.rs:6: [EXEC-WRITE] from_mode
|
|
3
|
+
src/sites.rs:7: [EXEC-WRITE] from_raw_mode
|
|
4
|
+
src/sites.rs:8: [EXEC-WRITE] mode
|
|
5
|
+
src/sites.rs:10: [EXEC-WRITE] set_mode
|
|
6
|
+
src/sites.rs:11: [EXEC-WRITE] set_permissions
|
|
7
|
+
src/sites.rs:12: [EXEC-WRITE] chmod
|
|
8
|
+
src/sites.rs:13: [EXEC-WRITE] fchmodat
|
|
9
|
+
src/sites.rs:14: [EXEC-WRITE] open
|
|
10
|
+
src/sites.rs:15: [EXEC-WRITE] creat
|
|
11
|
+
src/sites.rs:16: [EXEC-WRITE] copy
|
|
12
|
+
src/sites.rs:17: [EXEC-WRITE] chmod
|
|
13
|
+
src/sites.rs:18: [EXEC-WRITE] S_IXUSR
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
use std::fs;
|
|
2
|
+
use std::os::unix::fs::{OpenOptionsExt, PermissionsExt};
|
|
3
|
+
use std::process::Command;
|
|
4
|
+
|
|
5
|
+
pub fn every_site(p: &str, fd: i32, mode: u32) {
|
|
6
|
+
let _ = fs::Permissions::from_mode(0o755);
|
|
7
|
+
let _ = fs::Permissions::from_raw_mode(0o700);
|
|
8
|
+
let _ = fs::OpenOptions::new().mode(0o711);
|
|
9
|
+
let mut perms = fs::metadata(p).unwrap().permissions();
|
|
10
|
+
perms.set_mode(mode);
|
|
11
|
+
let _ = fs::set_permissions(p, perms);
|
|
12
|
+
unsafe { libc::chmod(p.as_ptr().cast(), 0o755) };
|
|
13
|
+
unsafe { libc::fchmodat(fd, p.as_ptr().cast(), 0o755, 0) };
|
|
14
|
+
unsafe { libc::open(p.as_ptr().cast(), libc::O_CREAT, 0o777) };
|
|
15
|
+
unsafe { libc::creat(p.as_ptr().cast(), 0o755) };
|
|
16
|
+
let _ = fs::copy(p, "out");
|
|
17
|
+
let _ = Command::new("chmod").arg("+x").arg(p);
|
|
18
|
+
let _ = libc::S_IXUSR;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
EXEC-WRITE: clean (1 Rust file(s) read, 1 helper(s) exempt)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
use std::fs;
|
|
2
|
+
use std::os::unix::fs::{OpenOptionsExt, PermissionsExt};
|
|
3
|
+
|
|
4
|
+
mod helper;
|
|
5
|
+
|
|
6
|
+
pub fn quiet(p: &str) {
|
|
7
|
+
let _ = fs::set_permissions(p, fs::Permissions::from_mode(0o644));
|
|
8
|
+
let _ = fs::OpenOptions::new().create(true).mode(0o600);
|
|
9
|
+
let note = "fs::copy(a, b) and Command::new(\"chmod\") and S_IXUSR";
|
|
10
|
+
let raw = r#"libc::chmod(p, 0o755); Permissions::from_mode(0o755)"#;
|
|
11
|
+
// fs::copy(p, q) then libc::S_IRWXU through Permissions::from_mode(0o777)
|
|
12
|
+
let _ = (note, raw);
|
|
13
|
+
let mut perms = fs::metadata(p).unwrap().permissions();
|
|
14
|
+
helper::make_runnable(&mut perms);
|
|
15
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Behavioral test of check-exec-write's refusals and unparseable spans, which a good/+bad/ pair
|
|
3
|
+
# cannot hold: a pair case exits 0 or 1. Each case runs in a sandbox repository.
|
|
4
|
+
#
|
|
5
|
+
# Run by the --run-gate-tests arm (any <tests-dir>/*.test.sh; must exit 0).
|
|
6
|
+
set -uo pipefail
|
|
7
|
+
source "$(dirname "${BASH_SOURCE[0]}")/../../gate-sdk/lib/test-hermetic.sh"
|
|
8
|
+
|
|
9
|
+
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # gate-sdk/
|
|
10
|
+
CHECKS="$DIR/checks"
|
|
11
|
+
SANDBOX="$(mktemp -d)"
|
|
12
|
+
trap 'rm -rf "$SANDBOX"' EXIT
|
|
13
|
+
|
|
14
|
+
fails=0
|
|
15
|
+
cases=0
|
|
16
|
+
|
|
17
|
+
expect() { # expect <label> <want-rc> <substring> <got-rc> <output>
|
|
18
|
+
cases=$((cases + 1))
|
|
19
|
+
if [[ "$4" -ne "$2" ]]; then
|
|
20
|
+
echo " FAIL [$1]: want exit $2, got $4 -- $5"; fails=$((fails + 1))
|
|
21
|
+
elif ! grep -qF -- "$3" <<<"$5"; then
|
|
22
|
+
echo " FAIL [$1]: exit $2 but output lacks '$3': $5"; fails=$((fails + 1))
|
|
23
|
+
fi
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
repo="$SANDBOX/repo"
|
|
27
|
+
mkdir -p "$repo/src"
|
|
28
|
+
git -C "$repo" init -q
|
|
29
|
+
printf 'pub fn f() {}\n' > "$repo/src/lib.rs"
|
|
30
|
+
printf 'pub fn h() {}\n' > "$repo/src/helper.rs"
|
|
31
|
+
git -C "$repo" add src
|
|
32
|
+
|
|
33
|
+
guard() { # guard <helpers> [gate args…] — the gate in the sandbox over src
|
|
34
|
+
local helpers="$1"
|
|
35
|
+
shift
|
|
36
|
+
( cd "$repo" && gate_env GATE_SDK_EXEC_WRITE_PATHS=src GATE_SDK_EXEC_WRITE_HELPERS="$helpers" \
|
|
37
|
+
&& gate_run check-exec-write "$CHECKS" "$@" 2>&1 )
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
# --- the paths knob empty: clean, not applicable.
|
|
41
|
+
out="$( cd "$repo" && gate_run check-exec-write "$CHECKS" 2>&1 )"; rc=$?
|
|
42
|
+
expect not-applicable 0 'not applicable: no Rust path configured' "$rc" "$out"
|
|
43
|
+
out="$(guard src/helper.rs)"; rc=$?
|
|
44
|
+
expect clean 0 'clean (1 Rust file(s) read, 1 helper(s) exempt)' "$rc" "$out"
|
|
45
|
+
|
|
46
|
+
# --- a helper outside the tree, absent, or absolute, and an operand, are refused at 2.
|
|
47
|
+
out="$(guard ../src/helper.rs)"; rc=$?
|
|
48
|
+
expect helper-dotdot 2 "helper '../src/helper.rs' holds '..'" "$rc" "$out"
|
|
49
|
+
out="$(guard src/absent.rs)"; rc=$?
|
|
50
|
+
expect helper-absent 2 "helper 'src/absent.rs' names no file" "$rc" "$out"
|
|
51
|
+
out="$(guard "$repo/src/helper.rs")"; rc=$?
|
|
52
|
+
expect helper-absolute 2 'is absolute' "$rc" "$out"
|
|
53
|
+
out="$(guard src/helper.rs src/lib.rs)"; rc=$?
|
|
54
|
+
expect usage 2 'takes no arguments' "$rc" "$out"
|
|
55
|
+
|
|
56
|
+
# --- an unterminated raw string and an unbalanced call are unparseable spans at 3.
|
|
57
|
+
printf 'pub fn f() {\n let s = r#"open";\n}\n' > "$repo/src/lib.rs"
|
|
58
|
+
out="$(guard src/helper.rs)"; rc=$?
|
|
59
|
+
expect raw-unterminated 3 'src/lib.rs:2: [LINT-PARSE] unparseable span' "$rc" "$out"
|
|
60
|
+
printf 'pub fn f() {\n g(a,\n}\n' > "$repo/src/lib.rs"
|
|
61
|
+
out="$(guard src/helper.rs)"; rc=$?
|
|
62
|
+
expect call-unbalanced 3 'src/lib.rs:3: [LINT-PARSE] unparseable span' "$rc" "$out"
|
|
63
|
+
|
|
64
|
+
if [[ "$fails" -gt 0 ]]; then
|
|
65
|
+
echo "check-exec-write.test.sh: $fails case(s) failed"
|
|
66
|
+
exit 1
|
|
67
|
+
fi
|
|
68
|
+
echo "check-exec-write.test.sh: clean (the helper refusals and the unparseable spans — $cases cases)"
|
|
69
|
+
exit 0
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
# A fresh block on
|
|
1
|
+
# A fresh block on every tree-free member; prose outside the markers is never read.
|
|
2
2
|
hooks
|
|
@@ -1 +1 @@
|
|
|
1
|
-
HOOK-KNOBS-FRESH: clean (
|
|
1
|
+
HOOK-KNOBS-FRESH: clean (5 page(s) under hooks carry the tables their members' knobs derive)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Agent budget guard
|
|
2
|
+
|
|
3
|
+
<!-- hook-knobs:begin -->
|
|
4
|
+
|
|
5
|
+
| Knob | Kit | Shape | Default |
|
|
6
|
+
| --- | --- | --- | --- |
|
|
7
|
+
| `DELEGATION_KIT_USAGE_FILE` | delegation-kit | scalar | (empty) |
|
|
8
|
+
| `DELEGATION_KIT_CRED_FILE` | delegation-kit | scalar | (empty) |
|
|
9
|
+
| `DELEGATION_KIT_ACCOUNT_CONFIG` | delegation-kit | scalar | (empty) |
|
|
10
|
+
| `DELEGATION_KIT_PAUSE_PCT` | delegation-kit | scalar | `80` |
|
|
11
|
+
| `DELEGATION_KIT_PAUSE_PCT_7D` | delegation-kit | scalar | `95` |
|
|
12
|
+
| `DELEGATION_KIT_STALE_AGE` | delegation-kit | scalar | `600` |
|
|
13
|
+
| `DELEGATION_KIT_LOGIN_WINDOW` | delegation-kit | scalar | `600` |
|
|
14
|
+
| `DELEGATION_KIT_LOGIN_SETTLE` | delegation-kit | scalar | `90` |
|
|
15
|
+
| `DELEGATION_KIT_REFRESH_CMD` | delegation-kit | indexed | (empty) |
|
|
16
|
+
| `DELEGATION_KIT_REFRESH_MIN_AGE` | delegation-kit | scalar | `60` |
|
|
17
|
+
| `DELEGATION_KIT_USAGE_HISTORY` | delegation-kit | scalar | (empty) |
|
|
18
|
+
| `DELEGATION_KIT_FAN_WIDTH` | delegation-kit | scalar | `2` |
|
|
19
|
+
|
|
20
|
+
<!-- hook-knobs:end -->
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# Agent dispatch guard
|
|
2
|
+
|
|
3
|
+
<!-- hook-knobs:begin -->
|
|
4
|
+
|
|
5
|
+
| Knob | Kit | Shape | Default |
|
|
6
|
+
| --- | --- | --- | --- |
|
|
7
|
+
| `DELEGATION_KIT_READONLY_TYPES` | delegation-kit | indexed | (empty) |
|
|
8
|
+
| `DELEGATION_KIT_MUTATING_TYPES` | delegation-kit | indexed | (empty) |
|
|
9
|
+
| `DELEGATION_KIT_REQUIRE_TIER` | delegation-kit | scalar | `off` |
|
|
10
|
+
| `DELEGATION_KIT_AGENT_DIR` | delegation-kit | scalar | `.claude/agents` |
|
|
11
|
+
| `DELEGATION_KIT_TIER_MODEL` | delegation-kit | indexed | (empty) |
|
|
12
|
+
| `GATE_SDK_NATIVE_BIN` | gate-sdk | scalar | `native/target/release/checkwright-gates` |
|
|
13
|
+
|
|
14
|
+
<!-- hook-knobs:end -->
|
|
@@ -62,7 +62,7 @@ check_case "absent-count-excludes-unverified" 0 "2 expectation(s) match" \
|
|
|
62
62
|
# present and unreadable whatever uid runs the battery, where a chmod-000 file
|
|
63
63
|
# is readable by root and would make this case pass vacuously in a container.
|
|
64
64
|
mkdir -p "$SANDBOX/hosts-is-a-dir"
|
|
65
|
-
check_case "unreadable-fail-closed"
|
|
65
|
+
check_case "unreadable-fail-closed" 3 "not readable" "$SANDBOX/hosts-is-a-dir" "$MANIFEST"
|
|
66
66
|
|
|
67
67
|
# Posture 3 — present, no block for the configured host: a violation. The
|
|
68
68
|
# manifest says the account should be one thing and this machine is not logged
|
|
@@ -80,7 +80,7 @@ cat >"$SANDBOX/no-user-key.yml" <<'EOF'
|
|
|
80
80
|
host.example:
|
|
81
81
|
git_protocol: ssh
|
|
82
82
|
EOF
|
|
83
|
-
check_case "unrecognized-shape-fail-closed"
|
|
83
|
+
check_case "unrecognized-shape-fail-closed" 3 "no active-account key" \
|
|
84
84
|
"$SANDBOX/no-user-key.yml" "$MANIFEST"
|
|
85
85
|
|
|
86
86
|
# The collision the parse is ruled over: `users` is the map of accounts available
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
CREATE TABLE accounts (id INTEGER PRIMARY KEY, name TEXT NOT NULL);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
CREATE TABLE orders (id INTEGER PRIMARY KEY, account INTEGER);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
CREATE TABLE audit (id INTEGER PRIMARY KEY, note TEXT);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
migrations/0001_init.sql: [MIGRATION-EDITED]
|
|
2
|
+
migrations/0002_orders.sql: [MIGRATION-EDITED]
|
|
3
|
+
migrations/0003_audit.sql: [MIGRATION-EDITED]
|
|
4
|
+
migrations/0003_audit_log.sql: [MIGRATION-ORDER] 0003 <= 0003
|
|
5
|
+
migrations/0002_late.sql: [MIGRATION-ORDER] 0002 <= 0003
|
|
6
|
+
migrations/0004_prune.sql:1: [MIGRATION-DESTRUCTIVE] matches 'DROP (TABLE|INDEX|VIEW|TRIGGER)'
|
|
7
|
+
migrations/0004_prune.sql:2: [MIGRATION-DESTRUCTIVE] matches 'ALTER TABLE .* DROP', its waiver reason empty
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
CREATE TABLE accounts (id INTEGER PRIMARY KEY, name TEXT NOT NULL, email TEXT);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
CREATE INDEX orders_account ON orders (account);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
CREATE TABLE audit (id INTEGER PRIMARY KEY, note TEXT);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
CREATE TABLE accounts (id INTEGER PRIMARY KEY, name TEXT NOT NULL);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
CREATE TABLE legacy_sessions (id INTEGER PRIMARY KEY);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
MIGRATION-GUARD: clean (3 migration(s), 1 added, against base)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
CREATE TABLE accounts (id INTEGER PRIMARY KEY, name TEXT NOT NULL);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
CREATE TABLE legacy_sessions (id INTEGER PRIMARY KEY);
|
package/payload/gate-sdk/gate-tests/check-migration-guard/good/migrations/0003_retire_legacy.sql
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
-- An addition numbered above the highest: a declared destructive statement, and
|
|
2
|
+
-- destructive text only inside a comment and a string.
|
|
3
|
+
DROP TABLE legacy_sessions; -- migration-ok: replaced by accounts in 0001
|
|
4
|
+
/* DROP TABLE accounts; would lose every account */
|
|
5
|
+
INSERT INTO accounts (name) VALUES ('DROP TABLE accounts');
|
|
6
|
+
ALTER TABLE accounts ADD COLUMN email TEXT;
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Behavioral test of check-migration-guard's git arm, which the good/+bad/ pair cannot reach: the
|
|
3
|
+
# pair stands a directory in for the merge base, since a committed fixture is identical to HEAD.
|
|
4
|
+
# Each case runs in a sandbox repository whose history the case builds.
|
|
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
|
+
LIST="$SANDBOX/destructive.list"
|
|
28
|
+
printf '# the template floor\nDROP (TABLE|INDEX|VIEW|TRIGGER)\nALTER TABLE .* DROP\nALTER TABLE .* RENAME\n' > "$LIST"
|
|
29
|
+
|
|
30
|
+
# --- the knob empty: clean, not applicable, before any repository is needed.
|
|
31
|
+
mkdir -p "$SANDBOX/plain"
|
|
32
|
+
out="$( cd "$SANDBOX/plain" && gate_run check-migration-guard "$CHECKS" 2>&1 )"; rc=$?
|
|
33
|
+
expect not-applicable 0 'not applicable: no migration directory configured' "$rc" "$out"
|
|
34
|
+
|
|
35
|
+
# A fresh repository on main with two merged migrations, a topic branch checked out over it.
|
|
36
|
+
fresh() { # fresh <name> — prints the repository path
|
|
37
|
+
local r="$SANDBOX/$1"
|
|
38
|
+
mkdir -p "$r/db/migrations"
|
|
39
|
+
git -C "$r" init -q -b main
|
|
40
|
+
printf 'CREATE TABLE a (id INTEGER);\n' > "$r/db/migrations/0001_a.sql"
|
|
41
|
+
printf 'CREATE TABLE b (id INTEGER);\n' > "$r/db/migrations/0002_b.sql"
|
|
42
|
+
git -C "$r" add db
|
|
43
|
+
git -C "$r" -c user.name=t -c user.email=t@e.invalid commit -qm base
|
|
44
|
+
git -C "$r" checkout -qb topic
|
|
45
|
+
printf '%s' "$r"
|
|
46
|
+
}
|
|
47
|
+
guard() { # guard <repo> [gate args…] — the gate in <repo> over db/migrations
|
|
48
|
+
local r="$1"
|
|
49
|
+
shift
|
|
50
|
+
( cd "$r" && gate_env GATE_SDK_MIGRATION_DIR=db/migrations GATE_SDK_MIGRATION_DESTRUCTIVE="$LIST" \
|
|
51
|
+
&& gate_run check-migration-guard "$CHECKS" "$@" 2>&1 )
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
# --- a tree whose base is its own HEAD, then an uncommitted addition counted from a subdirectory.
|
|
55
|
+
r="$(fresh own-head)"
|
|
56
|
+
out="$(guard "$r" --base HEAD)"; rc=$?
|
|
57
|
+
expect own-head 0 'clean (2 migration(s), 0 added, against merge base' "$rc" "$out"
|
|
58
|
+
printf 'CREATE TABLE c (id INTEGER);\n' > "$r/db/migrations/0003_c.sql"
|
|
59
|
+
out="$(guard "$r")"; rc=$?
|
|
60
|
+
expect untracked-addition 0 'clean (3 migration(s), 1 added, against merge base' "$rc" "$out"
|
|
61
|
+
out="$( cd "$r/db" && gate_env GATE_SDK_MIGRATION_DIR=migrations GATE_SDK_MIGRATION_DESTRUCTIVE="$LIST" \
|
|
62
|
+
&& gate_run check-migration-guard "$CHECKS" 2>&1 )"; rc=$?
|
|
63
|
+
expect from-subdirectory 0 'clean (3 migration(s), 1 added, against merge base' "$rc" "$out"
|
|
64
|
+
|
|
65
|
+
# --- an edit, uncommitted and then committed on the branch.
|
|
66
|
+
r="$(fresh edit)"
|
|
67
|
+
printf 'CREATE TABLE a (id INTEGER, x TEXT);\n' > "$r/db/migrations/0001_a.sql"
|
|
68
|
+
out="$(guard "$r")"; rc=$?
|
|
69
|
+
expect edit-uncommitted 1 'db/migrations/0001_a.sql: [MIGRATION-EDITED]' "$rc" "$out"
|
|
70
|
+
git -C "$r" -c user.name=t -c user.email=t@e.invalid commit -qam edit
|
|
71
|
+
out="$(guard "$r")"; rc=$?
|
|
72
|
+
expect edit-committed 1 'db/migrations/0001_a.sql: [MIGRATION-EDITED]' "$rc" "$out"
|
|
73
|
+
|
|
74
|
+
# --- a delete and a rename.
|
|
75
|
+
r="$(fresh delete)"
|
|
76
|
+
git -C "$r" rm -q db/migrations/0002_b.sql
|
|
77
|
+
out="$(guard "$r")"; rc=$?
|
|
78
|
+
expect delete 1 'db/migrations/0002_b.sql: [MIGRATION-EDITED]' "$rc" "$out"
|
|
79
|
+
r="$(fresh rename)"
|
|
80
|
+
git -C "$r" mv db/migrations/0002_b.sql db/migrations/0002_bee.sql
|
|
81
|
+
out="$(guard "$r")"; rc=$?
|
|
82
|
+
expect rename-gone 1 'db/migrations/0002_b.sql: [MIGRATION-EDITED]' "$rc" "$out"
|
|
83
|
+
expect rename-order 1 'db/migrations/0002_bee.sql: [MIGRATION-ORDER] 0002 <= 0002' "$rc" "$out"
|
|
84
|
+
|
|
85
|
+
# --- a misnumbered addition.
|
|
86
|
+
r="$(fresh order)"
|
|
87
|
+
printf 'CREATE TABLE z (id INTEGER);\n' > "$r/db/migrations/0001_z.sql"
|
|
88
|
+
out="$(guard "$r")"; rc=$?
|
|
89
|
+
expect misnumbered 1 'db/migrations/0001_z.sql: [MIGRATION-ORDER] 0001 <= 0002' "$rc" "$out"
|
|
90
|
+
|
|
91
|
+
# --- a destructive addition without a reason, then with one; the list absent turns it off.
|
|
92
|
+
r="$(fresh destructive)"
|
|
93
|
+
printf 'drop table a;\n' > "$r/db/migrations/0003_drop.sql"
|
|
94
|
+
out="$(guard "$r")"; rc=$?
|
|
95
|
+
expect destructive 1 "db/migrations/0003_drop.sql:1: [MIGRATION-DESTRUCTIVE] matches 'DROP (TABLE|INDEX|VIEW|TRIGGER)'" "$rc" "$out"
|
|
96
|
+
printf 'drop table a; -- migration-ok: a is folded into b\n' > "$r/db/migrations/0003_drop.sql"
|
|
97
|
+
out="$(guard "$r")"; rc=$?
|
|
98
|
+
expect declared 0 'clean (3 migration(s), 1 added, against merge base' "$rc" "$out"
|
|
99
|
+
printf 'drop table a; -- migration-ok:\n' > "$r/db/migrations/0003_drop.sql"
|
|
100
|
+
out="$(guard "$r")"; rc=$?
|
|
101
|
+
expect empty-reason 1 'its waiver reason empty' "$rc" "$out"
|
|
102
|
+
out="$( cd "$r" && gate_env GATE_SDK_MIGRATION_DIR=db/migrations GATE_SDK_MIGRATION_DESTRUCTIVE=absent.list \
|
|
103
|
+
&& gate_run check-migration-guard "$CHECKS" 2>&1 )"; rc=$?
|
|
104
|
+
expect list-absent 0 'destructive check off: no list at absent.list' "$rc" "$out"
|
|
105
|
+
|
|
106
|
+
# --- a stray file is 3; an unresolved base, a malformed list and a bad argument are 2.
|
|
107
|
+
r="$(fresh refusals)"
|
|
108
|
+
printf 'notes\n' > "$r/db/migrations/README.md"
|
|
109
|
+
out="$(guard "$r")"; rc=$?
|
|
110
|
+
expect stray 3 'db/migrations/README.md: not a migration file' "$rc" "$out"
|
|
111
|
+
rm "$r/db/migrations/README.md"
|
|
112
|
+
out="$(guard "$r" --base nope)"; rc=$?
|
|
113
|
+
expect base-unresolved 2 "base 'nope' names no commit" "$rc" "$out"
|
|
114
|
+
out="$( cd "$r" && gate_env GATE_SDK_MIGRATION_DIR=db/migrations GATE_SDK_BASE_REF=trunk \
|
|
115
|
+
GATE_SDK_MIGRATION_DESTRUCTIVE="$LIST" && gate_run check-migration-guard "$CHECKS" 2>&1 )"; rc=$?
|
|
116
|
+
expect base-knob 2 "base 'trunk' names no commit" "$rc" "$out"
|
|
117
|
+
printf 'DROP (TABLE\n' > "$SANDBOX/bad.list"
|
|
118
|
+
out="$( cd "$r" && gate_env GATE_SDK_MIGRATION_DIR=db/migrations GATE_SDK_MIGRATION_DESTRUCTIVE="$SANDBOX/bad.list" \
|
|
119
|
+
&& gate_run check-migration-guard "$CHECKS" 2>&1 )"; rc=$?
|
|
120
|
+
expect list-malformed 2 'bad.list:1:' "$rc" "$out"
|
|
121
|
+
out="$(guard "$r" --base main --base-dir db)"; rc=$?
|
|
122
|
+
expect base-and-dir 2 'takes no --base' "$rc" "$out"
|
|
123
|
+
out="$(guard "$r" --since main)"; rc=$?
|
|
124
|
+
expect usage 2 "unknown argument '--since'" "$rc" "$out"
|
|
125
|
+
|
|
126
|
+
# --- outside a work tree there is no corpus, which is refused, never clean.
|
|
127
|
+
out="$( cd "$SANDBOX/plain" && gate_env GATE_SDK_MIGRATION_DIR=db/migrations \
|
|
128
|
+
&& gate_run check-migration-guard "$CHECKS" 2>&1 )"; rc=$?
|
|
129
|
+
expect no-work-tree 2 'not a git repository' "$rc" "$out"
|
|
130
|
+
|
|
131
|
+
if [[ "$fails" -gt 0 ]]; then
|
|
132
|
+
echo "check-migration-guard.test.sh: $fails case(s) failed"
|
|
133
|
+
exit 1
|
|
134
|
+
fi
|
|
135
|
+
echo "check-migration-guard.test.sh: clean (the git arm's edit, delete, rename, order and destructive cases, and its exit classes — $cases cases)"
|
|
136
|
+
exit 0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
GATE_SDK_DENY_TERMS = terms.list
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
f
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
a
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
b
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
c
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
e
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
d
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
PATH-NAMES: clean (5 tracked path(s) read; no component carries one of the 1 deny term(s) as its stem)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
GATE_SDK_DENY_TERMS = terms.list
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
foo
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
b
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
a
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
c
|