checkwright 0.39.0 → 0.41.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/README.md +2 -0
- 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/gate-sdk/gate-tests/binary-only-recipe.test.sh +16 -1
- package/payload/gate-sdk/gate-tests/check-binary-strings/bad/expect.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-binary-strings/bad/out/short.bin +0 -0
- package/payload/gate-sdk/gate-tests/check-binary-strings/bad/scripts/gate-sdk-config.knobs +1 -1
- 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 -1
- 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/shapes.list +2 -0
- package/payload/gate-sdk/gate-tests/check-binary-strings/good/terms.list +1 -1
- package/payload/gate-sdk/gate-tests/check-exec-write/bad/expect.txt +3 -0
- package/payload/gate-sdk/gate-tests/check-exec-write/bad/src/sites.rs +4 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/bad/expect.txt +1 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/bad/migrations/0005_accounts.sql +2 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/bad/migrations/0005_users.sql +2 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard/good/expect.txt +1 -1
- package/payload/gate-sdk/gate-tests/check-migration-guard/good/migrations/0004_index_accounts.sql +2 -0
- package/payload/gate-sdk/gate-tests/check-migration-guard.test.sh +176 -1
- package/payload/gate-sdk/gate-tests/check-pipefail-readers.test.sh +14 -1
- package/payload/gate-sdk/gate-tests/child-locale.test.sh +94 -0
- package/payload/gate-sdk/gate-tests/lib-test-hermetic.test.sh +40 -1
- package/payload/gate-sdk/gate-tests/verdict-store.test.sh +23 -2
- package/payload/gate-sdk/lib/test-hermetic.sh +24 -6
package/README.md
CHANGED
|
@@ -20,6 +20,8 @@ From your repository's root, in a new project or an existing one with every chan
|
|
|
20
20
|
|
|
21
21
|
With Node already present the same install is one command, `npx checkwright init` — same payload, same `init`, same `checkwright.lock`; only the fetch differs, and on Windows the [`PATH` block](https://checkwright.dev/install.html#windows) runs first. `npx checkwright init --profile prose` picks a profile ([Choosing a profile](#choosing-a-profile) below), and `npx checkwright demo` shows the adoption arc in a scratch repository first, without touching yours ([what it runs](https://checkwright.dev/install.html#install)).
|
|
22
22
|
|
|
23
|
+
The kits, their `.gate` descriptors and a `gates.list` ship only in this package and the Release tarball that carries the same payload. A Release's per-target archive, `checkwright-gates-<version>-<target>.tar.gz`, holds the gate binary and its sidecar alone, so on its own it runs one compiled-in gate and has no set to `--run`. A CI job holding only the binary runs one gate directly, or a set through a registry it builds from the tarball's descriptors ([Binary-only CI](https://checkwright.dev/binary-only.html)).
|
|
24
|
+
|
|
23
25
|
`init` vendors the selected profile's kit directories, writes a `gates.list` seeded with each kit's starting gates alongside the config seam those kits need and a CI workflow, and makes **one commit** naming the install and the version. That commit runs the clone's own hooks, and if one refuses it the files stay staged and the setup commands still print. It ends by printing the commands that finish the setup, each with its reason — deliberately not copied here, because what `init` prints is `init`'s to say ([`installer/SPEC.md` §init](SPEC.md#init)).
|
|
24
26
|
|
|
25
27
|
Re-running is idempotent and non-destructive. `init` reads the per-file hash `checkwright.lock` recorded: a file still at its recorded hash is rewritten, and one you have changed since is **reported rather than overwritten** unless you pass `--force`. `--dry-run` prints the file plan and the manifest and writes nothing.
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"checkwright-pwsh": "bin/checkwright.ps1"
|
|
5
5
|
},
|
|
6
6
|
"checkwright": {
|
|
7
|
-
"commit": "
|
|
7
|
+
"commit": "4e99e11216c6846944814d866805a81a3c6d932c",
|
|
8
8
|
"spec_base_url": "https://checkwright.dev"
|
|
9
9
|
},
|
|
10
10
|
"description": "Reproducible checks that catch unsupported claims in coding-agent delivery before merge: a task marked done with no recorded test run, a skipped lifecycle stage, a spec naming a file the tree lacks. They prove the evidence a claim rests on exists, not that the code is correct.",
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"type": "git",
|
|
31
31
|
"url": "git+https://github.com/checkwright/checkwright.git"
|
|
32
32
|
},
|
|
33
|
-
"version": "0.
|
|
33
|
+
"version": "0.41.0"
|
|
34
34
|
}
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
9fb7a984f3338dfe2a08fee0d57fc03ec65b19e5dcf45e2c980f5b0806bcfb09 checkwright-gates
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
7d80ecc39574412e25cfefa55605598e5344dbdd4756db293b138e8ef2741673 *checkwright-gates.exe
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
bcb700e180e2cf8b6d06d1e159c90a0dc3340b94f6b9cd6605d5adbcc2697d0d checkwright-gates
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
53714a450f2231a8457e311c0deb3f30ac90a1cc152f9f2c9786b8239f0093e8 checkwright-gates
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
81d9a049c8d8e1c7d068fbdc95528f8cac3ba2452a0c168d8c46428375b325c3 checkwright-gates
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
8a1df97ebe0409a05925f59677ad99eb75c640208e94ef81fbf1d9623abe581f *checkwright-gates.exe
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
93eec7aa851e35860944c3c1e80c93a38f230cee2011466c23ff35c3588e5833 checkwright-gates
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
524cc8930b75f942d1aef500a0882968a8e70ba963e647887f988416c61fd5d9 checkwright-gates
|
|
@@ -95,6 +95,21 @@ assert_rc "run" "$rc" 0 "$out"
|
|
|
95
95
|
[[ -s "$sarif" ]] || { echo "FAIL [run]: no SARIF log at $sarif"; fails=$((fails + 1)); }
|
|
96
96
|
assert_clean run
|
|
97
97
|
|
|
98
|
+
# spec: gate-sdk/SPEC.md §run-gates — one usage spelling, the bare dir kept as its alias
|
|
99
|
+
out="$(cd "$repo" && container GATE_SDK_TMP_DIR="$scratch/run" "$BIN" --run "$gates" 2>&1)"; rc=$?
|
|
100
|
+
assert_rc "run, bare dir alias" "$rc" 0 "$out"
|
|
101
|
+
out="$(container "$BIN" --run --help 2>&1)"; rc=$?
|
|
102
|
+
assert_rc "run, help" "$rc" 0 "$out"
|
|
103
|
+
head -n1 <<<"$out" | grep -qF -- '--run [--json] [--gates-dir <dir>]' \
|
|
104
|
+
|| { echo "FAIL [run, help]: the usage line does not spell --gates-dir <dir>"; head -n1 <<<"$out"; fails=$((fails + 1)); }
|
|
105
|
+
|
|
106
|
+
# spec: gate-sdk/SPEC.md §Output contract — outside a git repository the run is refused at 2, its
|
|
107
|
+
# document the error one, rather than a pass carrying no tree
|
|
108
|
+
out="$(cd "$scratch/nogit" && container GATE_SDK_TMP_DIR="$scratch/run" "$BIN" --run --json --gates-dir "$gates" 2>&1)"; rc=$?
|
|
109
|
+
assert_rc "run, no worktree" "$rc" 2 "$out"
|
|
110
|
+
grep -qF 'run-gates: not inside a git repository' <<<"$out" && grep -qF '"refused"' <<<"$out" \
|
|
111
|
+
|| { echo "FAIL [run, no worktree]: no refusal line and refused error document"; printf '%s\n' "$out"; fails=$((fails + 1)); }
|
|
112
|
+
|
|
98
113
|
# spec: gate-sdk/SPEC.md §The install disposition — a registered member scans from the tree's root, so
|
|
99
114
|
# an action gate is scoped inside the battery by a member of the adopter's own calling the direct form
|
|
100
115
|
printf 'check-action-pinning\n' > "$gates/gates.list"
|
|
@@ -121,5 +136,5 @@ grep -qF '(unresolved)' <<<"$out" || { echo "FAIL [run, no descriptor]: no membe
|
|
|
121
136
|
assert_clean "run, no descriptor"
|
|
122
137
|
|
|
123
138
|
[[ "$fails" -eq 0 ]] || { echo "binary-only-recipe.test: $fails assertion(s) failed"; exit 1; }
|
|
124
|
-
echo "binary-only-recipe.test: clean (the direct form's four kit-free gates green on a read-only checkout, a finding at exit 1, a missing knob file and a worktree-less tree at exit 2, the root positional narrowing an action gate's scan to the owned directory, a knob file outside the checkout read, a top-level checks/ directory scanned once GATE_SDK_KIT_DIRS names the kit set, and --run over an out-of-tree registry writing its SARIF log outside a checkout left clean, an action gate scoped there by a member of the adopter's own, its members unresolved once its descriptors are gone)"
|
|
139
|
+
echo "binary-only-recipe.test: clean (the direct form's four kit-free gates green on a read-only checkout, a finding at exit 1, a missing knob file and a worktree-less tree at exit 2, the root positional narrowing an action gate's scan to the owned directory, a knob file outside the checkout read, a top-level checks/ directory scanned once GATE_SDK_KIT_DIRS names the kit set, and --run over an out-of-tree registry writing its SARIF log outside a checkout left clean, the bare dir its alias, its usage spelling --gates-dir <dir>, refused at exit 2 outside a worktree, an action gate scoped there by a member of the adopter's own, its members unresolved once its descriptors are gone)"
|
|
125
140
|
exit 0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
BINARY-STRINGS: clean (1 build output(s) scanned; none carry the 2 deny term(s) or
|
|
1
|
+
BINARY-STRINGS: clean (1 build output(s) scanned; none carry the 2 deny term(s) or 2 shape(s))
|
|
Binary file
|
|
@@ -11,3 +11,6 @@ src/sites.rs:15: [EXEC-WRITE] creat
|
|
|
11
11
|
src/sites.rs:16: [EXEC-WRITE] copy
|
|
12
12
|
src/sites.rs:17: [EXEC-WRITE] chmod
|
|
13
13
|
src/sites.rs:18: [EXEC-WRITE] S_IXUSR
|
|
14
|
+
src/sites.rs:19: [EXEC-WRITE] copy
|
|
15
|
+
src/sites.rs:21: [EXEC-WRITE] copy
|
|
16
|
+
src/sites.rs:22: [EXEC-WRITE] copy
|
|
@@ -16,4 +16,8 @@ pub fn every_site(p: &str, fd: i32, mode: u32) {
|
|
|
16
16
|
let _ = fs::copy(p, "out");
|
|
17
17
|
let _ = Command::new("chmod").arg("+x").arg(p);
|
|
18
18
|
let _ = libc::S_IXUSR;
|
|
19
|
+
let _ = std::fs ::
|
|
20
|
+
copy(p, "spaced");
|
|
21
|
+
let _ = std::fs::copy:: <&str, &str>(p, "after");
|
|
22
|
+
let _ = std::fs::copy ::<&str, &str>(p, "before");
|
|
19
23
|
}
|
|
@@ -3,5 +3,6 @@ migrations/0002_orders.sql: [MIGRATION-EDITED]
|
|
|
3
3
|
migrations/0003_audit.sql: [MIGRATION-EDITED]
|
|
4
4
|
migrations/0003_audit_log.sql: [MIGRATION-ORDER] 0003 <= 0003
|
|
5
5
|
migrations/0002_late.sql: [MIGRATION-ORDER] 0002 <= 0003
|
|
6
|
+
migrations/0005_users.sql: [MIGRATION-DUP] 0005 also 0005_accounts.sql
|
|
6
7
|
migrations/0004_prune.sql:1: [MIGRATION-DESTRUCTIVE] matches 'DROP (TABLE|INDEX|VIEW|TRIGGER)'
|
|
7
8
|
migrations/0004_prune.sql:2: [MIGRATION-DESTRUCTIVE] matches 'ALTER TABLE .* DROP', its waiver reason empty
|
|
@@ -1 +1 @@
|
|
|
1
|
-
MIGRATION-GUARD: clean (
|
|
1
|
+
MIGRATION-GUARD: clean (4 migration(s), 2 added, against base; clash check off: no base ref under --base-dir)
|
|
@@ -24,6 +24,12 @@ expect() { # expect <label> <want-rc> <substring> <got-rc> <output>
|
|
|
24
24
|
fi
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
refute() { # refute <label> <substring> <output>
|
|
28
|
+
if grep -qF -- "$2" <<<"$3"; then
|
|
29
|
+
echo " FAIL [$1]: output holds '$2': $3"; fails=$((fails + 1))
|
|
30
|
+
fi
|
|
31
|
+
}
|
|
32
|
+
|
|
27
33
|
LIST="$SANDBOX/destructive.list"
|
|
28
34
|
printf '# the template floor\nDROP (TABLE|INDEX|VIEW|TRIGGER)\nALTER TABLE .* DROP\nALTER TABLE .* RENAME\n' > "$LIST"
|
|
29
35
|
|
|
@@ -71,6 +77,42 @@ git -C "$r" -c user.name=t -c user.email=t@e.invalid commit -qam edit
|
|
|
71
77
|
out="$(guard "$r")"; rc=$?
|
|
72
78
|
expect edit-committed 1 'db/migrations/0001_a.sql: [MIGRATION-EDITED]' "$rc" "$out"
|
|
73
79
|
|
|
80
|
+
# --- the checkout form: a clean filter hiding an edit from git diff reds, an untouched file in an
|
|
81
|
+
# autocrlf or an LF clone is clean, and an edit in the autocrlf clone reds.
|
|
82
|
+
r="$(fresh filtered)"
|
|
83
|
+
git -C "$r" config filter.strip.clean "tr -d '#'"
|
|
84
|
+
git -C "$r" config filter.strip.smudge cat
|
|
85
|
+
printf '*.sql filter=strip\n' > "$r/.git/info/attributes"
|
|
86
|
+
printf 'CREATE TABLE a (id INTEGER);#\n' > "$r/db/migrations/0001_a.sql"
|
|
87
|
+
out="$(guard "$r")"; rc=$?
|
|
88
|
+
expect filter-hidden-edit 1 'db/migrations/0001_a.sql: [MIGRATION-EDITED]' "$rc" "$out"
|
|
89
|
+
refute filter-untouched 'db/migrations/0002_b.sql: [MIGRATION-EDITED]' "$out"
|
|
90
|
+
o="$(fresh clone-src)"
|
|
91
|
+
git -C "$o" checkout -q main
|
|
92
|
+
r="$SANDBOX/crlf"
|
|
93
|
+
git clone -q -c core.autocrlf=true "$o" "$r" && git -C "$r" checkout -qb topic
|
|
94
|
+
out="$(guard "$r")"; rc=$?
|
|
95
|
+
expect autocrlf-untouched 0 'clean (2 migration(s), 0 added, against merge base' "$rc" "$out"
|
|
96
|
+
printf 'CREATE TABLE b (id INTEGER, y TEXT);\r\n' > "$r/db/migrations/0002_b.sql"
|
|
97
|
+
out="$(guard "$r")"; rc=$?
|
|
98
|
+
expect autocrlf-edit 1 'db/migrations/0002_b.sql: [MIGRATION-EDITED]' "$rc" "$out"
|
|
99
|
+
r="$SANDBOX/lf"
|
|
100
|
+
git clone -q "$o" "$r" && git -C "$r" checkout -qb topic
|
|
101
|
+
out="$(guard "$r")"; rc=$?
|
|
102
|
+
expect lf-untouched 0 'clean (2 migration(s), 0 added, against merge base' "$rc" "$out"
|
|
103
|
+
|
|
104
|
+
# --- a conversion attribute changed since the merge base reds; a filter naming no configured
|
|
105
|
+
# driver cannot be read in its checkout form, which is 3, never a pass.
|
|
106
|
+
r="$(fresh attr-drift)"
|
|
107
|
+
printf 'db/migrations/*.sql eol=lf\n' > "$r/.gitattributes"
|
|
108
|
+
out="$(guard "$r")"; rc=$?
|
|
109
|
+
expect attr-drift 1 'db/migrations/0001_a.sql: [MIGRATION-ATTR] eol unspecified -> lf' "$rc" "$out"
|
|
110
|
+
refute attr-drift-edit 'MIGRATION-EDITED' "$out"
|
|
111
|
+
r="$(fresh no-driver)"
|
|
112
|
+
printf '*.sql filter=nodriver\n' > "$r/.git/info/attributes"
|
|
113
|
+
out="$(guard "$r")"; rc=$?
|
|
114
|
+
expect no-driver 3 "its filter attribute names driver 'nodriver'" "$rc" "$out"
|
|
115
|
+
|
|
74
116
|
# --- a delete and a rename.
|
|
75
117
|
r="$(fresh delete)"
|
|
76
118
|
git -C "$r" rm -q db/migrations/0002_b.sql
|
|
@@ -103,6 +145,139 @@ out="$( cd "$r" && gate_env GATE_SDK_MIGRATION_DIR=db/migrations GATE_SDK_MIGRAT
|
|
|
103
145
|
&& gate_run check-migration-guard "$CHECKS" 2>&1 )"; rc=$?
|
|
104
146
|
expect list-absent 0 'destructive check off: no list at absent.list' "$rc" "$out"
|
|
105
147
|
|
|
148
|
+
# --- the width is the directory's own: a five-digit history takes a five-digit addition, and a
|
|
149
|
+
# four-digit history refuses a five-digit one at 3, naming it.
|
|
150
|
+
r="$SANDBOX/wide"
|
|
151
|
+
mkdir -p "$r/db/migrations"
|
|
152
|
+
git -C "$r" init -q -b main
|
|
153
|
+
printf 'CREATE TABLE a (id INTEGER);\n' > "$r/db/migrations/00001_a.sql"
|
|
154
|
+
git -C "$r" add db
|
|
155
|
+
git -C "$r" -c user.name=t -c user.email=t@e.invalid commit -qm base
|
|
156
|
+
git -C "$r" checkout -qb topic
|
|
157
|
+
printf 'CREATE TABLE b (id INTEGER);\n' > "$r/db/migrations/00002_b.sql"
|
|
158
|
+
out="$(guard "$r")"; rc=$?
|
|
159
|
+
expect five-digit-history 0 'clean (2 migration(s), 1 added, against merge base' "$rc" "$out"
|
|
160
|
+
r="$(fresh widened)"
|
|
161
|
+
printf 'CREATE TABLE c (id INTEGER);\n' > "$r/db/migrations/10003_c.sql"
|
|
162
|
+
out="$(guard "$r")"; rc=$?
|
|
163
|
+
expect width-mixed 3 'db/migrations/10003_c.sql: its number is 5 digit(s) wide' "$rc" "$out"
|
|
164
|
+
|
|
165
|
+
# A commit on <branch> adding one migration, the topic branch checked out again after it.
|
|
166
|
+
on() { # on <repo> <branch> <file> <content> — branch made from main when absent
|
|
167
|
+
local r="$1"
|
|
168
|
+
git -C "$r" checkout -q "$2" 2>/dev/null || git -C "$r" checkout -qb "$2" main
|
|
169
|
+
printf '%s\n' "$4" > "$r/db/migrations/$3"
|
|
170
|
+
git -C "$r" add db
|
|
171
|
+
git -C "$r" -c user.name=t -c user.email=t@e.invalid commit -qm "$3"
|
|
172
|
+
git -C "$r" checkout -q topic
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
# --- a clash with an unmerged sibling, and none for one adding the same name with other content.
|
|
176
|
+
r="$(fresh clash)"
|
|
177
|
+
on "$r" sib 0003_theirs.sql 'CREATE TABLE t (id INTEGER);'
|
|
178
|
+
printf 'CREATE TABLE m (id INTEGER);\n' > "$r/db/migrations/0003_mine.sql"
|
|
179
|
+
out="$(guard "$r")"; rc=$?
|
|
180
|
+
expect clash 1 'db/migrations/0003_mine.sql: [MIGRATION-CLASH] 0003 refs/heads/sib 0003_theirs.sql' "$rc" "$out"
|
|
181
|
+
r="$(fresh same-name)"
|
|
182
|
+
on "$r" sib 0003_c.sql 'CREATE TABLE theirs (id INTEGER);'
|
|
183
|
+
printf 'CREATE TABLE mine (id INTEGER);\n' > "$r/db/migrations/0003_c.sql"
|
|
184
|
+
out="$(guard "$r")"; rc=$?
|
|
185
|
+
expect same-name 0 'clean (3 migration(s), 1 added, against merge base' "$rc" "$out"
|
|
186
|
+
expect same-name-read 0 ', 1 other ref(s) read' "$rc" "$out"
|
|
187
|
+
|
|
188
|
+
# --- a sibling merged into the base after the branch forked reads as ORDER, never CLASH; a file
|
|
189
|
+
# the base took by cherry-pick under its name is the base's, and the branch passes clean.
|
|
190
|
+
r="$(fresh merged)"
|
|
191
|
+
on "$r" sib 0003_theirs.sql 'CREATE TABLE t (id INTEGER);'
|
|
192
|
+
git -C "$r" checkout -q main && git -C "$r" merge -q --ff-only sib && git -C "$r" checkout -q topic
|
|
193
|
+
printf 'CREATE TABLE m (id INTEGER);\n' > "$r/db/migrations/0003_mine.sql"
|
|
194
|
+
out="$(guard "$r")"; rc=$?
|
|
195
|
+
expect merged-after-fork 1 'db/migrations/0003_mine.sql: [MIGRATION-ORDER] 0003 <= 0003' "$rc" "$out"
|
|
196
|
+
refute merged-after-fork 'MIGRATION-CLASH' "$out"
|
|
197
|
+
r="$(fresh picked)"
|
|
198
|
+
on "$r" topic 0003_c.sql 'DROP TABLE a;'
|
|
199
|
+
git -C "$r" checkout -q main && git -C "$r" -c user.name=t -c user.email=t@e.invalid cherry-pick topic >/dev/null \
|
|
200
|
+
&& git -C "$r" checkout -q topic
|
|
201
|
+
out="$(guard "$r")"; rc=$?
|
|
202
|
+
expect cherry-picked 0 'clean (3 migration(s), 0 added, against merge base' "$rc" "$out"
|
|
203
|
+
|
|
204
|
+
# --- the precedence: an addition both a duplicate and a clash prints DUP alone.
|
|
205
|
+
r="$(fresh precedence)"
|
|
206
|
+
on "$r" sib 0003_q.sql 'CREATE TABLE q (id INTEGER);'
|
|
207
|
+
printf 'CREATE TABLE a2 (id INTEGER);\n' > "$r/db/migrations/0003_a.sql"
|
|
208
|
+
printf 'CREATE TABLE b2 (id INTEGER);\n' > "$r/db/migrations/0003_b.sql"
|
|
209
|
+
out="$(guard "$r")"; rc=$?
|
|
210
|
+
expect precedence-dup 1 'db/migrations/0003_b.sql: [MIGRATION-DUP] 0003 also 0003_a.sql' "$rc" "$out"
|
|
211
|
+
expect precedence-clash 1 'db/migrations/0003_a.sql: [MIGRATION-CLASH] 0003 refs/heads/sib 0003_q.sql' "$rc" "$out"
|
|
212
|
+
refute precedence-one 'db/migrations/0003_b.sql: [MIGRATION-CLASH]' "$out"
|
|
213
|
+
|
|
214
|
+
# --- the ref set: a detached HEAD excludes no ref, an orphan is skipped and named, `none` turns the check
|
|
215
|
+
# off, a glob narrows it, and a glob opening with '-' is refused at 2.
|
|
216
|
+
r="$(fresh detached)"
|
|
217
|
+
on "$r" topic 0003_c.sql 'CREATE TABLE c (id INTEGER);'
|
|
218
|
+
out="$(guard "$r")"; rc=$?
|
|
219
|
+
expect own-ref 0 ', 0 other ref(s) read' "$rc" "$out"
|
|
220
|
+
git -C "$r" checkout -q --detach topic
|
|
221
|
+
out="$(guard "$r")"; rc=$?
|
|
222
|
+
expect detached 0 ', 1 other ref(s) read' "$rc" "$out"
|
|
223
|
+
o="$SANDBOX/orphan-src"
|
|
224
|
+
mkdir -p "$o/db/migrations"
|
|
225
|
+
git -C "$o" init -q -b main
|
|
226
|
+
printf 'CREATE TABLE x (id INTEGER);\n' > "$o/db/migrations/0003_x.sql"
|
|
227
|
+
git -C "$o" add db
|
|
228
|
+
git -C "$o" -c user.name=t -c user.email=t@e.invalid commit -qm lone
|
|
229
|
+
r="$(fresh orphan)"
|
|
230
|
+
git -C "$r" fetch -q "$o" main:refs/heads/lone
|
|
231
|
+
printf 'CREATE TABLE m (id INTEGER);\n' > "$r/db/migrations/0003_mine.sql"
|
|
232
|
+
out="$(guard "$r")"; rc=$?
|
|
233
|
+
expect orphan 0 'clean (3 migration(s), 1 added, against merge base' "$rc" "$out"
|
|
234
|
+
expect orphan-named 0 ', 0 other ref(s) read, 1 unrelated ref(s) skipped: refs/heads/lone)' "$rc" "$out"
|
|
235
|
+
|
|
236
|
+
# --- an unrelated ref under each GATE_SDK_MIGRATION_UNRELATED_REFS value: named on a red run's
|
|
237
|
+
# header under the default, refused at 3 under `error`, and an unknown value refused at 2.
|
|
238
|
+
unrelated() { # unrelated <repo> <value> — the gate in <repo> under GATE_SDK_MIGRATION_UNRELATED_REFS=<value>
|
|
239
|
+
( cd "$1" && gate_env GATE_SDK_MIGRATION_DIR=db/migrations GATE_SDK_MIGRATION_DESTRUCTIVE="$LIST" \
|
|
240
|
+
GATE_SDK_MIGRATION_UNRELATED_REFS="$2" && gate_run check-migration-guard "$CHECKS" 2>&1 )
|
|
241
|
+
}
|
|
242
|
+
out="$(unrelated "$r" error)"; rc=$?
|
|
243
|
+
expect orphan-error 3 '1 ref(s) share no merge base with the base ref, so their additions cannot be read: refs/heads/lone' "$rc" "$out"
|
|
244
|
+
expect orphan-remedy 3 'fetch the history their merge base needs, or narrow GATE_SDK_MIGRATION_REFS past them' "$rc" "$out"
|
|
245
|
+
refute orphan-error-clean 'clean (' "$out"
|
|
246
|
+
out="$(unrelated "$r" strict)"; rc=$?
|
|
247
|
+
expect unrelated-unknown 2 "GATE_SDK_MIGRATION_UNRELATED_REFS must be off|error (got 'strict')" "$rc" "$out"
|
|
248
|
+
printf 'CREATE TABLE z (id INTEGER);\n' > "$r/db/migrations/0001_z.sql"
|
|
249
|
+
out="$(unrelated "$r" off)"; rc=$?
|
|
250
|
+
expect orphan-red-header 1 ', 1 unrelated ref(s) skipped: refs/heads/lone:' "$rc" "$out"
|
|
251
|
+
rm "$r/db/migrations/0001_z.sql"
|
|
252
|
+
|
|
253
|
+
# --- a shallow clone: a sibling forked before the base's last commit has its merge base cut, so it
|
|
254
|
+
# is named rather than read.
|
|
255
|
+
o="$(fresh shallow-src)"
|
|
256
|
+
git -C "$o" checkout -q main
|
|
257
|
+
on "$o" sib 0003_t.sql 'CREATE TABLE t (id INTEGER);'
|
|
258
|
+
git -C "$o" checkout -q main
|
|
259
|
+
printf 'later\n' > "$o/LATER"
|
|
260
|
+
git -C "$o" add LATER && git -C "$o" -c user.name=t -c user.email=t@e.invalid commit -qm later
|
|
261
|
+
r="$SANDBOX/shallow"
|
|
262
|
+
git clone -q --depth 1 --no-single-branch --branch main "file://$o" "$r"
|
|
263
|
+
git -C "$r" branch -q sib origin/sib && git -C "$r" checkout -qb topic
|
|
264
|
+
printf 'CREATE TABLE m (id INTEGER);\n' > "$r/db/migrations/0003_mine.sql"
|
|
265
|
+
out="$(guard "$r")"; rc=$?
|
|
266
|
+
expect shallow-named 0 ', 0 other ref(s) read, 1 unrelated ref(s) skipped: refs/heads/sib)' "$rc" "$out"
|
|
267
|
+
out="$(unrelated "$r" error)"; rc=$?
|
|
268
|
+
expect shallow-error 3 'refs/heads/sib' "$rc" "$out"
|
|
269
|
+
r="$SANDBOX/clash"
|
|
270
|
+
refs() { # refs <value> — the gate in the clash repository under GATE_SDK_MIGRATION_REFS=<value>
|
|
271
|
+
( cd "$r" && gate_env GATE_SDK_MIGRATION_DIR=db/migrations GATE_SDK_MIGRATION_DESTRUCTIVE="$LIST" \
|
|
272
|
+
GATE_SDK_MIGRATION_REFS="$1" && gate_run check-migration-guard "$CHECKS" 2>&1 )
|
|
273
|
+
}
|
|
274
|
+
out="$(refs none)"; rc=$?
|
|
275
|
+
expect refs-none 0 '; clash check off: GATE_SDK_MIGRATION_REFS is none' "$rc" "$out"
|
|
276
|
+
out="$(refs 'refs/heads/feat/**')"; rc=$?
|
|
277
|
+
expect refs-narrowed 0 ', 0 other ref(s) read' "$rc" "$out"
|
|
278
|
+
out="$(refs -x)"; rc=$?
|
|
279
|
+
expect refs-option 2 "'-x' opens with '-'" "$rc" "$out"
|
|
280
|
+
|
|
106
281
|
# --- a stray file is 3; an unresolved base, a malformed list and a bad argument are 2.
|
|
107
282
|
r="$(fresh refusals)"
|
|
108
283
|
printf 'notes\n' > "$r/db/migrations/README.md"
|
|
@@ -132,5 +307,5 @@ if [[ "$fails" -gt 0 ]]; then
|
|
|
132
307
|
echo "check-migration-guard.test.sh: $fails case(s) failed"
|
|
133
308
|
exit 1
|
|
134
309
|
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)"
|
|
310
|
+
echo "check-migration-guard.test.sh: clean (the git arm's edit, checkout-form, attribute-drift, missing-driver, delete, rename, order, width, duplicate, clash, ref-set and destructive cases, and its exit classes — $cases cases)"
|
|
136
311
|
exit 0
|
|
@@ -57,6 +57,19 @@ out="$( cd "$SANDBOX/empty" && gate_env GATE_SDK_PIPEFAIL_ALL=yes \
|
|
|
57
57
|
&& gate_run check-pipefail-readers "$CHECKS" 2>&1 )"; rc=$?
|
|
58
58
|
expect all-value 2 'GATE_SDK_PIPEFAIL_ALL must be 0|1' "$rc" "$out"
|
|
59
59
|
|
|
60
|
+
# --- the waiver floor is the consumer's: a five-character reason the default passes reds under
|
|
61
|
+
# a floor of 10, and a value that is no positive integer is refused at 2.
|
|
62
|
+
mkdir -p "$SANDBOX/floor"
|
|
63
|
+
printf '#!/usr/bin/env bash\nset -o pipefail\nls | head -1 # pipefail-ok: short\n' > "$SANDBOX/floor/waived.sh"
|
|
64
|
+
out="$( cd "$SANDBOX/floor" && gate_run check-pipefail-readers "$CHECKS" waived.sh 2>&1 )"; rc=$?
|
|
65
|
+
expect floor-default 0 'clean (1 shell file(s) read' "$rc" "$out"
|
|
66
|
+
out="$( cd "$SANDBOX/floor" && gate_env GATE_SDK_PIPEFAIL_WAIVER_MIN=10 \
|
|
67
|
+
&& gate_run check-pipefail-readers "$CHECKS" waived.sh 2>&1 )"; rc=$?
|
|
68
|
+
expect floor-raised 1 'waived.sh:3: [PIPEFAIL-EARLY-EXIT] waiver reason under 10 characters' "$rc" "$out"
|
|
69
|
+
out="$( cd "$SANDBOX/floor" && gate_env GATE_SDK_PIPEFAIL_WAIVER_MIN=0 \
|
|
70
|
+
&& gate_run check-pipefail-readers "$CHECKS" waived.sh 2>&1 )"; rc=$?
|
|
71
|
+
expect floor-value 2 'GATE_SDK_PIPEFAIL_WAIVER_MIN must be a positive integer' "$rc" "$out"
|
|
72
|
+
|
|
60
73
|
# --- a span the reader cannot read is LINT-PARSE at 3, and the fix arm writes nothing to it.
|
|
61
74
|
mkdir -p "$SANDBOX/parse"
|
|
62
75
|
printf '#!/usr/bin/env bash\nset -o pipefail\necho "open\nls | head -1\n' > "$SANDBOX/parse/broken.sh"
|
|
@@ -110,5 +123,5 @@ if [[ "$fails" -gt 0 ]]; then
|
|
|
110
123
|
echo "check-pipefail-readers.test.sh: $fails case(s) failed"
|
|
111
124
|
exit 1
|
|
112
125
|
fi
|
|
113
|
-
echo "check-pipefail-readers.test.sh: clean (configuration, operands, exit classes, the whole-file knob, pruning and the fix arm — $cases cases)"
|
|
126
|
+
echo "check-pipefail-readers.test.sh: clean (configuration, operands, exit classes, the whole-file knob, the waiver floor, pruning and the fix arm — $cases cases)"
|
|
114
127
|
exit 0
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# spec: gate-sdk/SPEC.md §Fail-closed contract — under a non-C LC_ALL a roster tool the binary runs takes the C locale, a native gate's git included, while a consumer shell member keeps the exported value; under --init the commit's placed hook takes the caller's LC_ALL back, so a hook gate and a chained consumer hook record the caller's value, empty or unset as the caller had it
|
|
3
|
+
set -uo pipefail
|
|
4
|
+
source "$(dirname "${BASH_SOURCE[0]}")/../../gate-sdk/lib/test-hermetic.sh"
|
|
5
|
+
|
|
6
|
+
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
|
|
7
|
+
# shellcheck source=../lib/gate.sh
|
|
8
|
+
source "$HERE/gate-sdk/lib/gate.sh"
|
|
9
|
+
PINNED="$GATE_SDK_NATIVE_BIN"
|
|
10
|
+
[[ -x "$PINNED" ]] || { echo "child-locale.test: the gate binary $PINNED is absent — build it first"; exit 2; }
|
|
11
|
+
unset GATE_SDK_NATIVE_BIN GATE_SDK_GATES_DIR GATE_SDK_KIT_DIRS GATE_SDK_ROOT GATE_SDK_VERBOSE
|
|
12
|
+
|
|
13
|
+
if [[ -n "$(gate_exe_suffix)" ]]; then
|
|
14
|
+
echo "child-locale.test: clean (skipped — its git wrapper and hook gates are sh scripts, which a host with an executable suffix cannot start)"
|
|
15
|
+
exit 0
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
SANDBOX="$(mktemp -d)"
|
|
19
|
+
trap 'rm -rf "$SANDBOX"' EXIT
|
|
20
|
+
LOCALE=el_GR.UTF-8
|
|
21
|
+
|
|
22
|
+
fails=0
|
|
23
|
+
note() { echo " FAIL [$1]: $2"; fails=$((fails + 1)); }
|
|
24
|
+
|
|
25
|
+
recorder() {
|
|
26
|
+
printf '#!/bin/sh\n# graph: couples=%s dir=one valve=none tier=precommit\n%sprintf '"'"'%%s\\n'"'"' "${LC_ALL-<unset>}" >>"%s"\necho "%s: clean"\n' "$1" "$2" "$3" "$4"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
# 1. a native gate's git and the runner's take C, and a consumer shell member keeps the exported value
|
|
30
|
+
real_git="$(command -v git)"
|
|
31
|
+
wrap="$SANDBOX/wrap"
|
|
32
|
+
mkdir -p "$wrap"
|
|
33
|
+
printf '#!/bin/sh\nprintf '"'"'%%s\\n'"'"' "${LC_ALL-<unset>}" >>"%s"\nexec "%s" "$@"\n' "$SANDBOX/git-rec" "$real_git" >"$wrap/git"
|
|
34
|
+
chmod +x "$wrap/git"
|
|
35
|
+
run="$SANDBOX/run"
|
|
36
|
+
mkdir -p "$run/scripts"
|
|
37
|
+
printf 'check-exec-bit\ncheck-print-locale\n' >"$run/scripts/gates.list"
|
|
38
|
+
cp "$HERE/gate-sdk/checks/check-exec-bit.gate" "$run/scripts/"
|
|
39
|
+
recorder '*.txt' '' "$SANDBOX/member-rec" PRINT-LOCALE >"$run/scripts/check-print-locale.sh"
|
|
40
|
+
chmod +x "$run/scripts/check-print-locale.sh"
|
|
41
|
+
git -C "$run" init -q -b main
|
|
42
|
+
git -C "$run" add -A
|
|
43
|
+
git -C "$run" -c user.email=t@example.invalid -c user.name=t commit -qm seed
|
|
44
|
+
out="$( cd "$run" && PATH="$wrap:$PATH" LC_ALL="$LOCALE" "$PINNED" --run 2>&1 )"; rc=$?
|
|
45
|
+
[[ "$rc" -eq 0 ]] || note run-status "want exit 0 from --run, got $rc -- $out"
|
|
46
|
+
grep -qF 'All 2 gates passed.' <<<"$out" || note run-summary "the native gate and the member did not both run: $out"
|
|
47
|
+
git_rec="$(cat "$SANDBOX/git-rec" 2>/dev/null)"
|
|
48
|
+
[[ -n "$git_rec" ]] || note git-recorded "the wrapper recorded no git the binary ran: $out"
|
|
49
|
+
[[ -z "$(grep -vxF C <<<"$git_rec")" ]] || note git-locale "a git the binary ran kept a locale other than C: $git_rec"
|
|
50
|
+
[[ "$(cat "$SANDBOX/member-rec" 2>/dev/null)" == "$LOCALE" ]] || note member-locale "want the consumer member to keep $LOCALE, got: $(cat "$SANDBOX/member-rec" 2>/dev/null)"
|
|
51
|
+
|
|
52
|
+
# 2. --init's commit runs the placed hook, whose gate and chained consumer hook record the caller's LC_ALL
|
|
53
|
+
pkg="$SANDBOX/pkg"
|
|
54
|
+
mkdir -p "$pkg/payload/artifact/t" "$pkg/payload/a-kit/checks" "$SANDBOX/home"
|
|
55
|
+
printf '{"name":"scratch","version":"1.2.3"}\n' >"$pkg/package.json"
|
|
56
|
+
printf 'starter\ta-kit\n' >"$pkg/profiles.list"
|
|
57
|
+
cp "$PINNED" "$pkg/payload/artifact/t/checkwright-gates"
|
|
58
|
+
recorder checkwright.lock $'# install: zero-config\n' '$REC/gate' REC >"$pkg/payload/a-kit/checks/check-rec.sh"
|
|
59
|
+
chmod +x "$pkg/payload/a-kit/checks/check-rec.sh"
|
|
60
|
+
|
|
61
|
+
init_case() {
|
|
62
|
+
local label="$1" want="$2"; shift 2
|
|
63
|
+
local repo="$SANDBOX/init-$label" rec="$SANDBOX/rec-$label"
|
|
64
|
+
mkdir -p "$repo/scripts" "$repo/native/target/release" "$rec"
|
|
65
|
+
printf 'native/target/\n' >"$repo/.gitignore"
|
|
66
|
+
printf 'check-rec\n' >"$repo/scripts/gates.list"
|
|
67
|
+
cp "$pkg/payload/a-kit/checks/check-rec.sh" "$repo/scripts/"
|
|
68
|
+
cp "$PINNED" "$repo/native/target/release/checkwright-gates"
|
|
69
|
+
git -C "$repo" init -q -b main
|
|
70
|
+
git -C "$repo" config user.email t@example.invalid
|
|
71
|
+
git -C "$repo" config user.name t
|
|
72
|
+
git -C "$repo" add -A
|
|
73
|
+
git -C "$repo" commit -qm seed
|
|
74
|
+
printf '#!/bin/sh\nprintf '"'"'%%s\\n'"'"' "${LC_ALL-<unset>}" >>"$REC/chained"\n' >"$repo/.git/hooks/pre-commit"
|
|
75
|
+
chmod +x "$repo/.git/hooks/pre-commit"
|
|
76
|
+
local out rc
|
|
77
|
+
out="$( cd "$repo" && ./native/target/release/checkwright-gates --install-hooks 2>&1 )"; rc=$?
|
|
78
|
+
[[ "$rc" -eq 0 ]] || { note "$label-hooks" "want exit 0 from --install-hooks, got $rc -- $out"; return; }
|
|
79
|
+
out="$( cd "$repo" && env "$@" HOME="$SANDBOX/home" XDG_CONFIG_HOME="$SANDBOX/home" GATE_SDK_UPDATE_CHECK=off \
|
|
80
|
+
REC="$rec" "$pkg/payload/artifact/t/checkwright-gates" --init 2>&1 )"; rc=$?
|
|
81
|
+
[[ "$rc" -eq 0 ]] || { note "$label-init" "want exit 0 from --init, got $rc -- $out"; return; }
|
|
82
|
+
[[ "$(git -C "$repo" rev-list --count HEAD)" -eq 2 ]] || note "$label-commit" "--init committed nothing: $out"
|
|
83
|
+
local f
|
|
84
|
+
for f in gate chained; do
|
|
85
|
+
[[ -f "$rec/$f" && "$(cat "$rec/$f")" == "$want" ]] || note "$label-$f" "want the hook's $f to record '$want', got: $(cat "$rec/$f" 2>/dev/null || echo '<no record>')"
|
|
86
|
+
done
|
|
87
|
+
}
|
|
88
|
+
init_case value "$LOCALE" LC_ALL="$LOCALE"
|
|
89
|
+
init_case empty '' LC_ALL=
|
|
90
|
+
init_case unset '<unset>' -u LC_ALL
|
|
91
|
+
|
|
92
|
+
[[ "$fails" -eq 0 ]] || { echo "child-locale.test: $fails assertion(s) failed"; exit 1; }
|
|
93
|
+
echo "child-locale.test: clean (under a non-C LC_ALL a native gate's git and the runner's take C while a consumer shell member keeps the exported value; --init's commit runs the placed hook in the caller's locale, its gate and a chained consumer hook recording the caller's value, empty or unset as the caller had it)"
|
|
94
|
+
exit 0
|
|
@@ -39,4 +39,43 @@ leaked="$(env -u GIT_CONFIG_NOSYSTEM "$system=$hostile/system.config" GIT_CONFIG
|
|
|
39
39
|
printf 'FAIL: a sourcing suite read host git config: %s\n' "$leaked"
|
|
40
40
|
exit 1
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
|
|
43
|
+
# A name under the temp dir that is not private to this user is refused at 3 and never written:
|
|
44
|
+
# a link to another directory, and off native Windows a directory open to others.
|
|
45
|
+
mkdir -p "$hostile/tmp-link" "$hostile/target" "$hostile/tmp-open/gate-sdk-hermetic.$(id -u)"
|
|
46
|
+
ln -s "$hostile/target" "$hostile/tmp-link/gate-sdk-hermetic.$(id -u)"
|
|
47
|
+
TMPDIR="$hostile/tmp-link" bash -c 'source "$1"' bash "$GATE_SDK_TEST_LIB_DIR/test-hermetic.sh" 2>/dev/null
|
|
48
|
+
rc=$?
|
|
49
|
+
[[ "$rc" == 3 && -z "$(ls -A "$hostile/target")" ]] || {
|
|
50
|
+
printf 'FAIL: a linked private-dir name was used (exit %s): %s\n' "$rc" "$(ls -A "$hostile/target")"
|
|
51
|
+
exit 1
|
|
52
|
+
}
|
|
53
|
+
case "${OSTYPE:-}" in
|
|
54
|
+
msys* | cygwin* | win32*) ;;
|
|
55
|
+
*)
|
|
56
|
+
open="$hostile/tmp-open/gate-sdk-hermetic.$(id -u)"
|
|
57
|
+
chmod 755 "$open"
|
|
58
|
+
TMPDIR="$hostile/tmp-open" bash -c 'source "$1"' bash "$GATE_SDK_TEST_LIB_DIR/test-hermetic.sh" 2>/dev/null
|
|
59
|
+
rc=$?
|
|
60
|
+
[[ "$rc" == 3 && -z "$(ls -A "$open")" ]] || {
|
|
61
|
+
printf 'FAIL: an open private-dir name was used (exit %s)\n' "$rc"
|
|
62
|
+
exit 1
|
|
63
|
+
}
|
|
64
|
+
;;
|
|
65
|
+
esac
|
|
66
|
+
fresh="$hostile/tmp-fresh"
|
|
67
|
+
mkdir -p "$fresh"
|
|
68
|
+
TMPDIR="$fresh" bash -c 'source "$1"' bash "$GATE_SDK_TEST_LIB_DIR/test-hermetic.sh" || {
|
|
69
|
+
echo 'FAIL: a fresh temp dir refused the private dir'
|
|
70
|
+
exit 1
|
|
71
|
+
}
|
|
72
|
+
[[ -f "$fresh/gate-sdk-hermetic.$(id -u)/empty.knobs" ]] || {
|
|
73
|
+
echo 'FAIL: the empty files are not under the private dir'
|
|
74
|
+
exit 1
|
|
75
|
+
}
|
|
76
|
+
twice="$(TMPDIR="$fresh" bash -ec 'source "$1"; source "$1"; echo twice' bash "$GATE_SDK_TEST_LIB_DIR/test-hermetic.sh")"
|
|
77
|
+
[[ "$twice" == twice ]] || {
|
|
78
|
+
echo 'FAIL: a second source under errexit died on the private dir already present'
|
|
79
|
+
exit 1
|
|
80
|
+
}
|
|
81
|
+
echo 'LIB-TEST-HERMETIC: clean (inherited kit variables cleared, binary kept, library and later pins applied, host git config unread, a non-private temp name refused, a second source under errexit survived)'
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# spec: gate-sdk/SPEC.md §run-gates — the verdict store end to end through the front end: a
|
|
3
3
|
# registry run on a clean tree keeps its verdict under the key its SARIF log's provenance carries,
|
|
4
|
-
# --verdict-lookup answers it there and answers absent under another digest,
|
|
4
|
+
# --verdict-lookup answers it there and answers absent under another digest, --verdict-key prints
|
|
5
|
+
# that key, a tree that moves while
|
|
5
6
|
# members run or a modified tree keeps nothing, and an unset store is refused with its error
|
|
6
7
|
# document. Run by the --run-gate-tests arm.
|
|
7
8
|
set -uo pipefail
|
|
@@ -65,6 +66,24 @@ got="$(lookup GATE_SDK_VERDICT_STORE="$store")"; rc=$?
|
|
|
65
66
|
[[ "$rc" -eq 0 && "$got" == '{"contract":"1.0.0","verdict":"pass"}' ]] || fail "lookup pass" "exit $rc: $got"
|
|
66
67
|
pass_key=("${key[@]}")
|
|
67
68
|
|
|
69
|
+
# verdict_key [args] — the front end's --verdict-key on the scratch registry, its document alone
|
|
70
|
+
verdict_key() {
|
|
71
|
+
(cd "$repo" && env GATE_SDK_GATES_DIR="$gates" GATE_SDK_KIT_DIRS="$gates" bash "$RUN" --verdict-key "$@" 2>/dev/null)
|
|
72
|
+
}
|
|
73
|
+
# spec: gate-sdk/SPEC.md §run-gates — --verdict-key prints the key the run stored under, and its
|
|
74
|
+
# three fields handed to --verdict-lookup answer the stored verdict
|
|
75
|
+
doc="$(verdict_key)"; rc=$?
|
|
76
|
+
key=(
|
|
77
|
+
"$(grep -oE '"treeId":"[0-9a-f]+"' <<<"$doc" | grep -oE '[0-9a-f]{40,64}')"
|
|
78
|
+
"$(grep -oE '"tool":\{"version":"[^"]+"' <<<"$doc" | sed 's/.*"version":"//; s/"$//')"
|
|
79
|
+
"$(grep -oE '"gateSet":"[0-9a-f]+"' <<<"$doc" | grep -oE '[0-9a-f]{64}')"
|
|
80
|
+
)
|
|
81
|
+
[[ "$rc" -eq 0 && "${key[*]}" == "${pass_key[*]}" ]] || fail "verdict-key" "exit $rc: the key differs from the run's: ${key[*]} vs ${pass_key[*]}" "$doc"
|
|
82
|
+
got="$(lookup GATE_SDK_VERDICT_STORE="$store")"; rc=$?
|
|
83
|
+
[[ "$rc" -eq 0 && "$got" == '{"contract":"1.0.0","verdict":"pass"}' ]] || fail "verdict-key lookup" "exit $rc: $got"
|
|
84
|
+
got="$(verdict_key --json)"; rc=$?
|
|
85
|
+
[[ "$rc" -eq 2 && "$got" == '{"contract":"1.0.0","error":"usage"}' ]] || fail "verdict-key operand" "exit $rc: $got"
|
|
86
|
+
|
|
68
87
|
printf 'r\n' > "$repo/red"
|
|
69
88
|
git -C "$repo" add red
|
|
70
89
|
git -C "$repo" -c user.name=t -c user.email=t@e.invalid commit -qm red
|
|
@@ -89,11 +108,13 @@ printf 'b\n' >> "$repo/a.txt"
|
|
|
89
108
|
out="$(battery GATE_SDK_VERDICT_STORE="$scratch/modified")"; rc=$?
|
|
90
109
|
[[ "$rc" -eq 1 ]] || fail "modified run" "expected exit 1, got $rc" "$out"
|
|
91
110
|
[[ ! -e "$scratch/modified" ]] || fail "modified run" "a modified tree kept a verdict" "$(ls -A "$scratch/modified")"
|
|
111
|
+
got="$(verdict_key)"; rc=$?
|
|
112
|
+
[[ "$rc" -eq 2 && "$got" == '{"contract":"1.0.0","error":"refused"}' ]] || fail "verdict-key modified" "a modified tree has no key: exit $rc: $got"
|
|
92
113
|
|
|
93
114
|
key=("${pass_key[@]}")
|
|
94
115
|
got="$(lookup)"; rc=$?
|
|
95
116
|
[[ "$rc" -eq 2 && "$got" == '{"contract":"1.0.0","error":"refused"}' ]] || fail "unset store" "exit $rc: $got"
|
|
96
117
|
|
|
97
118
|
[[ "$fails" -eq 0 ]] || { echo "verdict-store.test: $fails assertion(s) failed"; exit 1; }
|
|
98
|
-
echo "verdict-store.test: clean (a registry run on a clean tree kept its pass and its fail under the SARIF log's key, --verdict-lookup answered each at exit 0 and absent under another digest, a tree moved mid-run and a modified tree kept nothing, and an unset store was refused at exit 2 with its error document)"
|
|
119
|
+
echo "verdict-store.test: clean (a registry run on a clean tree kept its pass and its fail under the SARIF log's key, --verdict-lookup answered each at exit 0 and absent under another digest, --verdict-key printed the stored key, refused a modified tree and an unknown operand at exit 2, a tree moved mid-run and a modified tree kept nothing, and an unset store was refused at exit 2 with its error document)"
|
|
99
120
|
exit 0
|
|
@@ -5,9 +5,29 @@
|
|
|
5
5
|
# shellcheck disable=SC2164 # the anchor is the contract's bare builtin, which check-path-dialect clears only as the whole line; a failed chdir leaves the cwd where it was
|
|
6
6
|
cd "$(pwd -P)"
|
|
7
7
|
_th_root="$(cd "${BASH_SOURCE[0]%/*}/../.." && pwd)"
|
|
8
|
-
|
|
8
|
+
_th_sep=:
|
|
9
|
+
case "${OSTYPE:-}" in msys* | cygwin* | win32*) _th_sep=';' ;; esac
|
|
10
|
+
# spec: gate-sdk/SPEC.md §lib/test-hermetic.sh — the empty files live in a directory private to this
|
|
11
|
+
# user, made mode 700 and owner-checked before use; a name that is not private is refused, never used
|
|
12
|
+
_th_dir="${TMPDIR:-/tmp}/gate-sdk-hermetic.$(id -u)"
|
|
13
|
+
# spec: gate-sdk/SPEC.md §lib/test-hermetic.sh — a name already present is left to the checks below, never an errexit death
|
|
14
|
+
mkdir -m 700 "$_th_dir" 2>/dev/null || :
|
|
15
|
+
_th_why=
|
|
16
|
+
if [[ -L "$_th_dir" || ! -d "$_th_dir" ]]; then
|
|
17
|
+
_th_why='is not a directory'
|
|
18
|
+
elif [[ ! -O "$_th_dir" ]]; then
|
|
19
|
+
_th_why='is owned by another user'
|
|
20
|
+
elif [[ "$_th_sep" == : ]]; then
|
|
21
|
+
case "$(ls -ld "$_th_dir")" in d???------*) ;; *) _th_why='is open to group or other' ;; esac
|
|
22
|
+
fi
|
|
23
|
+
if [[ -n "$_th_why" ]]; then
|
|
24
|
+
printf 'test-hermetic.sh: %s %s, so nothing is written there; remove it, or point TMPDIR at a directory of your own\n' \
|
|
25
|
+
"$_th_dir" "$_th_why" >&2
|
|
26
|
+
exit 3
|
|
27
|
+
fi
|
|
28
|
+
_th_empty="$_th_dir/empty.sh"
|
|
9
29
|
: >"$_th_empty"
|
|
10
|
-
_th_empty_knobs="$
|
|
30
|
+
_th_empty_knobs="$_th_dir/empty.knobs"
|
|
11
31
|
: >"$_th_empty_knobs"
|
|
12
32
|
for _th_kit in "$_th_root"/gate-sdk "$_th_root"/*-kit; do
|
|
13
33
|
[[ -d "$_th_kit" ]] || continue
|
|
@@ -20,12 +40,10 @@ for _th_kit in "$_th_root"/gate-sdk "$_th_root"/*-kit; do
|
|
|
20
40
|
[[ "$_th_var" == GATE_SDK ]] || export "${_th_var}_LOCAL_KNOB_FILE=${_th_empty_knobs}"
|
|
21
41
|
done
|
|
22
42
|
# spec: gate-sdk/SPEC.md §lib/test-hermetic.sh — the temp dir the suite is handed heads the git ceiling list
|
|
23
|
-
_th_sep=:
|
|
24
|
-
case "${OSTYPE:-}" in msys* | cygwin* | win32*) _th_sep=';' ;; esac
|
|
25
43
|
_th_tmp="$(cd -P "${TMPDIR:-/tmp}" && pwd -P)"
|
|
26
44
|
export GIT_CEILING_DIRECTORIES="${_th_tmp}${GIT_CEILING_DIRECTORIES:+${_th_sep}${GIT_CEILING_DIRECTORIES}}"
|
|
27
45
|
# spec: gate-sdk/SPEC.md §lib/test-hermetic.sh — git reads no host global config, and no system config off native Windows
|
|
28
|
-
_th_git_global="$
|
|
46
|
+
_th_git_global="$_th_dir/empty.gitconfig"
|
|
29
47
|
: >"$_th_git_global"
|
|
30
48
|
export GIT_CONFIG_GLOBAL="$_th_git_global"
|
|
31
49
|
[[ "$_th_sep" == ';' ]] || export GIT_CONFIG_NOSYSTEM=1
|
|
@@ -44,7 +62,7 @@ if [[ -z "${GATE_SDK_NATIVE_BIN:-}" ]]; then
|
|
|
44
62
|
fi
|
|
45
63
|
# spec: gate-sdk/SPEC.md §lib/test-hermetic.sh — gate-sdk's overlay is pinned after the binary read above, outside its already-set guard
|
|
46
64
|
export GATE_SDK_LOCAL_KNOB_FILE="$_th_empty_knobs"
|
|
47
|
-
unset _th_name _th_root _th_empty _th_empty_knobs _th_kit _th_var _th_bin _th_sep _th_tmp _th_git_global
|
|
65
|
+
unset _th_name _th_root _th_empty _th_empty_knobs _th_kit _th_var _th_bin _th_sep _th_tmp _th_git_global _th_dir _th_why
|
|
48
66
|
|
|
49
67
|
# spec: gate-sdk/SPEC.md §run-gate-tests — invoke a gate through its declared dispatch rather
|
|
50
68
|
# than by script path, so a bespoke test names a gate and never a substrate: gate_command
|