testmark-bash

tests: find the library from the repo root, not through tests/testdata.

commit 421966087ac448c4db4d7938c56ad8127b3612a3 · parent 7331992346 · browse this tree
Ximianth, 2026-10-23 09:44:48 UTC

The testdata dir arrived a commit later than the tests that went through it,
so the first two commits' tests couldn't find the library.
diff --git a/tests/lib.sh b/tests/lib.sh
index a679d3c..54f633b 100644
--- a/tests/lib.sh
+++ b/tests/lib.sh
@@ -7,9 +7,10 @@
 
 set -euo pipefail
 
-TESTDATA=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/testdata
+ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
+TESTDATA=$ROOT/tests/testdata
 # shellcheck source=lib/testmark.bash
-source "$TESTDATA/../../lib/testmark.bash"
+source "$ROOT/lib/testmark.bash"
 
 work=$(mktemp -d)
 trap 'rm -rf "$work"' EXIT
diff --git a/tests/test-api.sh b/tests/test-api.sh
index eccd71a..e772921 100755
--- a/tests/test-api.sh
+++ b/tests/test-api.sh
@@ -53,12 +53,12 @@ expect_fail "and leaves its handle unusable" 'testmark: unknown handle "b"' test
 
 # --- sourcing: twice keeps state; inside a function still makes globals ---
 # shellcheck source=lib/testmark.bash
-source "$TESTDATA/../../lib/testmark.bash"
+source "$ROOT/lib/testmark.bash"
 expect_eq "sourcing again keeps open docs" "$(testmark_body a x)" "two"
 testmark_parse c none.md
 expect_fail "and later parses don't collide with them" 'testmark: c: no hunk named "x"' testmark_body c x
 expect_eq "sourcing inside a function" "$(
-	"$BASH" -c 'f() { source "$1"; }; f "$1"; testmark_parse d1 a.md; testmark_parse d2 b.md; testmark_body d1 x' _ "$TESTDATA/../../lib/testmark.bash"
+	"$BASH" -c 'f() { source "$1"; }; f "$1"; testmark_parse d1 a.md; testmark_parse d2 b.md; testmark_body d1 x' _ "$ROOT/lib/testmark.bash"
 )" "one"
 
 # --- errors ---