From 73393b9d017179a2a3835ccf606cb505603614a2 Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Fri, 14 Aug 2026 08:03:30 +0000 Subject: [PATCH] fix(scripts): correct shellcheck source directives that resolved to nothing `tests/run-tests.sh` declared `source=lib/batch-run.sh`, which resolves to neither the repo root nor the script's own directory. A directive that does not resolve is silent: it blinds test-vale-wrap.sh's `sourced_files()` seeding exemption, and shellcheck's own SC1091 is `info` while .pre-commit-config.yaml pins `--severity=warning`. Issue #97 names run-bats.sh's `../scripts/lib/batch-run.sh` as the correct spelling. It is not. Directives resolve against the source-path, which under pre-commit is the repo root, so `../scripts/...` escapes the repo and trips SC1091 exactly as `lib/...` does -- verified directly. The spelling satisfying both shellcheck and `sourced_files()`'s two-candidate rule is repo-root-relative, matching scripts/install.sh. Fixes all three: run-tests.sh, run-bats.sh, and check-manifests.sh, the last unmentioned by the issue. Every directive in the repo now resolves, which the previous commit's case 27 asserts. Refs #97 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01X7GvKuJfy2WrdBmUttV4DT --- scripts/check-manifests.sh | 3 ++- tests/run-bats.sh | 4 +++- tests/run-tests.sh | 14 +++++++++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/scripts/check-manifests.sh b/scripts/check-manifests.sh index 93a3252..d3a499b 100755 --- a/scripts/check-manifests.sh +++ b/scripts/check-manifests.sh @@ -46,7 +46,8 @@ if [[ ! -f "$MARKETPLACE" ]]; then fi SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -# shellcheck source=lib/marketplace-plugins.sh +# Repo-root-relative, not script-dir-relative -- see tests/run-tests.sh for why. +# shellcheck source=scripts/lib/marketplace-plugins.sh source "$SCRIPT_DIR/lib/marketplace-plugins.sh" # Every local plugin directory marketplace.json claimed, canonicalized, so the diff --git a/tests/run-bats.sh b/tests/run-bats.sh index 608273d..391fa24 100755 --- a/tests/run-bats.sh +++ b/tests/run-bats.sh @@ -51,7 +51,9 @@ fi # than a rolling `wait -n` pool. SCRATCH_ROOT="$(mktemp -d)" trap 'rm -rf "$SCRATCH_ROOT"' EXIT -# shellcheck source=../scripts/lib/batch-run.sh +# Repo-root-relative -- see tests/run-tests.sh for why `../scripts/...` does not +# resolve here despite looking right. +# shellcheck source=scripts/lib/batch-run.sh source "$REPO_ROOT/scripts/lib/batch-run.sh" declare -a batch_args=() diff --git a/tests/run-tests.sh b/tests/run-tests.sh index ba5b521..bf9569b 100755 --- a/tests/run-tests.sh +++ b/tests/run-tests.sh @@ -58,7 +58,19 @@ done < <( # rolling `wait -n` pool. SCRATCH_ROOT="$(mktemp -d)" trap 'rm -rf "$SCRATCH_ROOT"' EXIT -# shellcheck source=lib/batch-run.sh +# The source= path below is repo-root-relative, matching scripts/install.sh:5 -- +# NOT script-dir-relative. The source-path used to resolve it is the cwd +# pre-commit invokes the linter from, which is the repo root, so `lib/...` +# (resolving to a nonexistent tests/lib/) and `../scripts/...` (escaping the repo +# entirely) both fail. Both spellings were live until issue #97, and neither was +# visible: the resulting SC1091 is `info` while .pre-commit-config.yaml pins +# `--severity=warning`. A directive that does not resolve also blinds +# test-vale-wrap.sh's `sourced_files()` exemption, which reads these same +# directives to find array seeding that lives in the sourced file. +# +# Do not start a comment line here with the linter's name -- it is parsed as a +# directive and errors out (SC1073). +# shellcheck source=scripts/lib/batch-run.sh source "$REPO_ROOT/scripts/lib/batch-run.sh" declare -a batch_args=()