testmark-bash

Rename testcase_read_myhunk to testcase_hunk, and testcase_read_anyhunk to testcase_doc_hunk.

commit 5cf95dcbac84e700e4fd0a388ab0e482fb0ef8d2 · parent 477bcbbdcb · browse this tree
Ximianth, 2026-10-25 15:28:41 UTC

Short, and both say hunk, so neither reads as a path in the filesystem.
diff --git a/examples/test-todos-files.sh b/examples/test-todos-files.sh
index f4bff73..40750b0 100755
--- a/examples/test-todos-files.sh
+++ b/examples/test-todos-files.sh
@@ -5,8 +5,8 @@ source "$(dirname "${BASH_SOURCE[0]}")/../lib/testmark.bash"
 
 exercise_todos_files() {
 	testcase_withtmpdir
-	testcase_read_myhunk mine.txt >mine.txt
-	testcase_read_anyhunk shared/theirs.txt >theirs.txt
+	testcase_hunk mine.txt >mine.txt
+	testcase_doc_hunk shared/theirs.txt >theirs.txt
 	"$TESTCASE_DIR/todos.sh" mine.txt theirs.txt | testcase_output output
 }
 
diff --git a/lib/testmark.bash b/lib/testmark.bash
index 9642d77..09850a3 100644
--- a/lib/testmark.bash
+++ b/lib/testmark.bash
@@ -119,7 +119,7 @@ testmarktest_rule_basic() { _testmark_call _testmarktest_rule_basic "$@"; }
 ## Makes every hunk whose name matches GLOB a case, to be exercised by FN, which reads hunks and gives outputs by calling testcase_* functions.
 ## Cases are found and run as for testmarktest_rule_basic, except that stdin is empty, and output works differently:
 ##
-## - `testcase_read_myhunk NAME` prints the body of hunk CASE/NAME.  `testcase_read_anyhunk NAME` prints the body of hunk NAME.
+## - `testcase_hunk NAME` prints the body of hunk CASE/NAME.  `testcase_doc_hunk NAME` prints the body of hunk NAME.
 ## - `testcase_output NAME` reads its stdin, which testmarktest_run checks against hunk CASE/NAME, using testmark_check.
 ##   NAME is always in the case: no leading `/`, and no whitespace.
 ## - Anything FN prints otherwise, and a nonzero exit, have no hunk to go in, so they fail the case.
diff --git a/lib/testmark/testcase.bash b/lib/testmark/testcase.bash
index c1b8649..070aa8a 100644
--- a/lib/testmark/testcase.bash
+++ b/lib/testmark/testcase.bash
@@ -4,20 +4,20 @@
 ## Their contract is documented with testmarktest_rule, in testmark.bash.
 # shellcheck disable=SC2154 # _testcase_case, _testcase_index, and _testcase_blob are set by the case's script
 
-testcase_read_myhunk() {
+testcase_hunk() {
 	(($# == 1)) || {
-		>&2 echo "usage: testcase_read_myhunk NAME"
+		>&2 echo "usage: testcase_hunk NAME"
 		return 1
 	}
-	_testcase_read testcase_read_myhunk "$_testcase_case/$1"
+	_testcase_read testcase_hunk "$_testcase_case/$1"
 }
 
-testcase_read_anyhunk() {
+testcase_doc_hunk() {
 	(($# == 1)) || {
-		>&2 echo "usage: testcase_read_anyhunk NAME"
+		>&2 echo "usage: testcase_doc_hunk NAME"
 		return 1
 	}
-	_testcase_read testcase_read_anyhunk "$1"
+	_testcase_read testcase_doc_hunk "$1"
 }
 
 ## Prints the body of hunk $2; $1 is the public function asking, for the message.
diff --git a/tests/test-run-full.sh b/tests/test-run-full.sh
index acfbce4..b49ff14 100755
--- a/tests/test-run-full.sh
+++ b/tests/test-run-full.sh
@@ -19,8 +19,8 @@ one() {
 
 run_case "outputs are checked against the case's hunks" "$(one $'hello\n' $'shared\n')" '
 exercise_x() {
-	testcase_read_myhunk in | testcase_output out
-	testcase_read_anyhunk shared/x | testcase_output side
+	testcase_hunk in | testcase_output out
+	testcase_doc_hunk shared/x | testcase_output side
 }
 testmarktest_rule "*/in" exercise_x
 testmarktest_run doc.md' "PASS  doc.md: a/in (exercise_x)
@@ -29,7 +29,7 @@ testmarktest_run doc.md' "PASS  doc.md: a/in (exercise_x)
 --- status 0"
 
 run_case "a mismatch fails, with a diff" "$(one $'bye\n' '')" '
-exercise_x() { testcase_read_myhunk in | testcase_output out; }
+exercise_x() { testcase_hunk in | testcase_output out; }
 testmarktest_rule "*/in" exercise_x
 testmarktest_run doc.md' "FAIL  doc.md: a/in (exercise_x)
 --- stderr
@@ -75,7 +75,7 @@ run_case "hunks read back exactly, whatever their names and bytes" '[testmark]:#
   \\ $(x) `y` '$'\xff''
 
 ```' '
-exercise_x() { testcase_read_myhunk "\$(echo)\`echo\`[\"x\"]'"'"'y" | testcase_output out; }
+exercise_x() { testcase_hunk "\$(echo)\`echo\`[\"x\"]'"'"'y" | testcase_output out; }
 testmarktest_rule "*/in" exercise_x
 testmarktest_run doc.md' "PASS  doc.md: a/in (exercise_x)
 --- stderr
@@ -107,7 +107,7 @@ testmark: WORK/t/doc.md:6: hunk \"a/in\": the case printed this outside testcase
 expect_eq "and the doc is unchanged" "$(<t/doc.md)" "$(one '' '')"
 
 run_case "a nonzero exit fails the case, and outputs given before it are still checked" "$(one $'hello\n' '')" '
-exercise_x() { testcase_read_myhunk in | testcase_output out; false; echo unreached; }
+exercise_x() { testcase_hunk in | testcase_output out; false; echo unreached; }
 testmarktest_rule "*/in" exercise_x
 testmarktest_run doc.md' "FAIL  doc.md: a/in (exercise_x)
 --- stderr
@@ -146,14 +146,14 @@ echo leaked | testmarktest_run doc.md' "PASS  doc.md: a/in (exercise_x)
 # --- the testcase_* functions refusing ---
 
 run_case "a missing hunk fails the case, naming it" "$(one '' '')" '
-exercise_x() { testcase_read_myhunk nope; }
-exercise_y() { testcase_read_anyhunk in; }
+exercise_x() { testcase_hunk nope; }
+exercise_y() { testcase_doc_hunk in; }
 testmarktest_rule "*/in" exercise_x
 testmarktest_rule "*/in" exercise_y
-testmarktest_run doc.md 2>&1 | grep -E "^(\+[^+]|FAIL)"' "+testcase_read_myhunk: no hunk named \"a/nope\"
+testmarktest_run doc.md 2>&1 | grep -E "^(\+[^+]|FAIL)"' "+testcase_hunk: no hunk named \"a/nope\"
 +exit status: 1
 FAIL  doc.md: a/in (exercise_x)
-+testcase_read_anyhunk: no hunk named \"in\"
++testcase_doc_hunk: no hunk named \"in\"
 +exit status: 1
 FAIL  doc.md: a/in (exercise_y)
 --- stderr
@@ -162,8 +162,8 @@ FAIL  doc.md: a/in (exercise_y)
 
 run_case "testcase_* functions refuse bad arguments" "$(one '' '')" '
 exercise_x() {
-	testcase_read_myhunk || :
-	testcase_read_anyhunk a b || :
+	testcase_hunk || :
+	testcase_doc_hunk a b || :
 	testcase_output </dev/null || :
 	testcase_output /a/out </dev/null || :
 	testcase_output "a b" </dev/null || :
@@ -172,8 +172,8 @@ exercise_x() {
 	testcase_withtmpdir x || :
 }
 testmarktest_rule "*/in" exercise_x
-testmarktest_run doc.md 2>&1 | grep "^+[^+]"' '+usage: testcase_read_myhunk NAME
-+usage: testcase_read_anyhunk NAME
+testmarktest_run doc.md 2>&1 | grep "^+[^+]"' '+usage: testcase_hunk NAME
++usage: testcase_doc_hunk NAME
 +usage: testcase_output NAME <OUTPUT
 +testcase_output: "/a/out" is not an output name: it names a hunk in the case, so it has no leading "/", and no whitespace
 +testcase_output: "a b" is not an output name: it names a hunk in the case, so it has no leading "/", and no whitespace
@@ -237,7 +237,7 @@ removed
 # --- regen, and mixing the roads ---
 
 run_case "regen writes every output given" "$(one '' '')" '
-exercise_x() { testcase_read_myhunk in | testcase_output out; echo s | testcase_output side; }
+exercise_x() { testcase_hunk in | testcase_output out; echo s | testcase_output side; }
 testmarktest_rule "*/in" exercise_x
 TESTMARK_REGEN=1 testmarktest_run doc.md && testmarktest_run doc.md' "PASS  doc.md: a/in (exercise_x)
 PASS  doc.md: a/in (exercise_x)
@@ -265,7 +265,7 @@ hello
 hello
 ```' '
 exercise_cat() { cat; }
-exercise_full() { testcase_read_anyhunk a/in | testcase_output out; }
+exercise_full() { testcase_doc_hunk a/in | testcase_output out; }
 testmarktest_rule_basic "*/in" exercise_cat
 testmarktest_rule "*/script" exercise_full
 testmarktest_run doc.md' "PASS  doc.md: a/in (exercise_cat)