examples: pick hunks out with a case statement on the name, the shape table-driven testmark tests tend to grow into.
commit 423732f80f5d0c60b060d24b23b47e4c0f12d6df · parent 563bee7ae1
· browse this tree
Ximianth, 2026-10-24 12:00:45 UTC
The README's copy of the test follows.
diff --git a/README.md b/README.md index a138b1c..998ef26 100644 --- a/README.md +++ b/README.md @@ -72,15 +72,18 @@ testmark_parse doc todos.md mapfile -t names < <(testmark_names doc) fails=0 for name in "${names[@]}"; do - [[ $name == */input ]] || continue - case=${name%/input} - testmark_body doc "$case/input" >"$work/notes.txt" - if testmark_check doc "$case/output" < <(./todos.sh "$work/notes.txt" | sed "s|$work|WORK|g"); then - echo "PASS $case" - else - echo "FAIL $case" - fails=$((fails + 1)) - fi + case $name in + */input) + case=${name%/input} + testmark_body doc "$name" >"$work/notes.txt" + if testmark_check doc "$case/output" < <(./todos.sh "$work/notes.txt" | sed "s|$work|WORK|g"); then + echo "PASS $case" + else + echo "FAIL $case" + fails=$((fails + 1)) + fi + ;; + esac done testmark_write doc ((fails == 0)) diff --git a/examples/test-todos.sh b/examples/test-todos.sh index f8f19b9..61a3ceb 100755 --- a/examples/test-todos.sh +++ b/examples/test-todos.sh @@ -12,15 +12,18 @@ testmark_parse doc todos.md mapfile -t names < <(testmark_names doc) fails=0 for name in "${names[@]}"; do - [[ $name == */input ]] || continue - case=${name%/input} - testmark_body doc "$case/input" >"$work/notes.txt" - if testmark_check doc "$case/output" < <(./todos.sh "$work/notes.txt" | sed "s|$work|WORK|g"); then - echo "PASS $case" - else - echo "FAIL $case" - fails=$((fails + 1)) - fi + case $name in + */input) + case=${name%/input} + testmark_body doc "$name" >"$work/notes.txt" + if testmark_check doc "$case/output" < <(./todos.sh "$work/notes.txt" | sed "s|$work|WORK|g"); then + echo "PASS $case" + else + echo "FAIL $case" + fails=$((fails + 1)) + fi + ;; + esac done testmark_write doc ((fails == 0))