Skip to content

Commit 9944dcd

Browse files
committed
fix(tests): harden docker-run.sh argument and image-hash handling
Two papercuts hit while regenerating baselines for the fix in this PR: - `vitest --run -u <filter>` parses <filter> as the *value* of `-u`, so the filter is dropped and the whole suite runs in update mode. The `e2e:updateSnaps` script ends in `-u`, so any filter a caller appends (as CLAUDE.md instructs) lands in exactly that trap - which silently rewrote an unrelated, flaky `deleteShallowerBlock` baseline. `-u` / `--update` is now always passed last. - wasm-pack emits `packages/xl-typst-compiler/pkg/package.json`, which the image content hash globbed, so building the wasm that docker-run.sh itself requires invalidated the image. A fresh clone paid two full image builds. `pkg` is now pruned alongside `dist`.
1 parent 645886b commit 9944dcd

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

.claude/skills/testing-skill/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ bash tests/docker-run.sh -e CI=1 -- --run [filters]
5555

5656
A specific test file may be targeted by appending (part of) its name as a filter. A single browser may be targeted with `--project "e2e (chromium)"`. Individual tests in a file may be disabled using `skip`, i.e. `test.skip("Test name", ...)` (remember to revert this once all tests pass).
5757

58-
Screenshot baselines can be regenerated with the `-u` argument, which must come **after** the filters (`--run <filters> -u`): written as `--run -u <filter>`, the filter is parsed as the flag's value and the **whole** suite runs in update mode, silently rewriting unrelated baselines. Note that `-u` only rewrites baselines whose comparison **fails** — a small intended change (e.g. a short text edit) that fits inside the suite's 2% pixel tolerance leaves the baseline stale while the test passes. To force a fresh capture, delete the baseline file first. Baselines are per-browser (`<name>-<browser>-linux.png`); after regenerating, always inspect the images before committing them.
58+
Screenshot baselines can be regenerated with the `-u` argument. Vitest parses `--run -u <filter>` with the filter as the _value_ of `-u`, which drops the filter and runs the **whole** suite in update mode; `docker-run.sh` now normalizes this by always passing `-u`/`--update` last, so either order is safe through the script (invoking vitest directly still is not). Note that `-u` only rewrites baselines whose comparison **fails** — a small intended change (e.g. a short text edit) that fits inside the suite's 2% pixel tolerance leaves the baseline stale while the test passes. To force a fresh capture, delete the baseline file first. Baselines are per-browser (`<name>-<browser>-linux.png`); after regenerating, always inspect the images before committing them.
5959

6060
When testing a visual change, prefer writing screenshots to verify that the change is working as expected.
6161

tests/docker-run.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,23 @@ done
2626
[ "$#" -gt 0 ] && shift
2727
entrypoint_args=("$@")
2828

29+
# vitest reads `--run -u <filter>` with <filter> as the *value* of `-u`, so the
30+
# filter is dropped and the whole suite silently runs in update mode. The
31+
# `e2e:updateSnaps` script ends in `-u`, so any filter a caller appends to it
32+
# lands in that trap. Keep the flag last so appended filters survive.
33+
_u=() _rest=()
34+
for a in "${entrypoint_args[@]}"; do
35+
case "$a" in -u | --update) _u+=("$a") ;; *) _rest+=("$a") ;; esac
36+
done
37+
entrypoint_args=("${_rest[@]}" "${_u[@]}")
38+
2939
# Auto-rebuild the image if its content hash label doesn't match the current
3040
# repo state. The hash covers every file that affects the image's contents: the
3141
# Dockerfile itself, plus everything it bakes in — the lockfile, workspace file,
32-
# all package.json files, patches, and example sources. When they differ the
42+
# all package.json files, patches, and example sources. Generated output dirs
43+
# are pruned: `pkg/` is wasm-pack's, and it emits a package.json, so without
44+
# that prune, building the wasm this script *requires* would itself invalidate
45+
# the image and force a second full rebuild. When they differ the
3346
# image is rebuilt in place
3447
# (Docker's layer cache makes this fast when only a leaf changed).
3548
_dep_files() {
@@ -42,7 +55,8 @@ _dep_files() {
4255
find . -name package.json \
4356
-not -path '*/node_modules/*' \
4457
-not -path '*/.git/*' \
45-
-not -path '*/dist/*'
58+
-not -path '*/dist/*' \
59+
-not -path '*/pkg/*'
4660
} | sort -u
4761
}
4862
_content_hash() {

0 commit comments

Comments
 (0)