examples: todos.sh on several files, tested with testmarktest_rule, which make test runs.
commit 659f60b19c3bd34322f71d3dd1db4a9df236d79b · parent f074f81300
· browse this tree
Ximianth, 2026-10-25 12:06:24 UTC
Shows the full road's parts: a hunk of the case's own and a hunk shared by every case, both read into files in a temp dir, and an output.
diff --git a/Makefile b/Makefile index cf4999f..5e0c200 100644 --- a/Makefile +++ b/Makefile @@ -31,3 +31,4 @@ test: ## Run all tests. tests/run.sh examples/test-todos.sh examples/test-todos-alone.sh + examples/test-todos-files.sh diff --git a/examples/test-todos-files.sh b/examples/test-todos-files.sh new file mode 100755 index 0000000..ab1efb3 --- /dev/null +++ b/examples/test-todos-files.sh @@ -0,0 +1,15 @@ +#!/bin/bash +## Checks todos.sh on several files at once, against every case in todos-files.md. +## Run with TESTMARK_REGEN=1 to update todos-files.md to match what todos.sh does now; then review the change with `git diff`. +source "$(dirname "${BASH_SOURCE[0]}")/../lib/testmark.bash" + +exercise_todos_files() { + local here=$PWD + testcase_withtmpdir + testcase_read_myhunk mine.txt >mine.txt + testcase_read_anyhunk shared/theirs.txt >theirs.txt + "$here/todos.sh" mine.txt theirs.txt | testcase_output output +} + +testmarktest_rule '*/mine.txt' exercise_todos_files +testmarktest_run todos-files.md diff --git a/examples/todos-files.md b/examples/todos-files.md new file mode 100644 index 0000000..501fbf2 --- /dev/null +++ b/examples/todos-files.md @@ -0,0 +1,40 @@ +todos.sh, across files +====================== + +`todos.sh` takes several files, and names each one's file on its lines. + +Each case below starts with its `CASE/mine.txt`, and `test-todos-files.sh` hands `todos.sh` two files: +that one, as `mine.txt`, and `shared/theirs.txt`, which every case shares, as `theirs.txt`. +What `todos.sh` prints is checked against `CASE/output`. + +[testmark]:# (shared/theirs.txt) +```text +TODO: theirs, first +done: theirs, second +``` + + +### files are listed in the order given + +[testmark]:# (ordered/mine.txt) +```text +TODO: mine +``` + +[testmark]:# (ordered/output) +```text +mine.txt:1:TODO: mine +theirs.txt:1:TODO: theirs, first +``` + + +### a file with nothing to do adds nothing + +[testmark]:# (empty/mine.txt) +```text +``` + +[testmark]:# (empty/output) +```text +theirs.txt:1:TODO: theirs, first +```