testmark-bash

test-todos-alone.sh

#!/bin/bash
## Checks todos.sh against every case in todos.md, as test-todos.sh does, but with the primitives instead of the runner.
## Run with TESTMARK_REGEN=1 to update todos.md to match what todos.sh does now; then review the change with `git diff`.
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
source ../lib/testmark.bash

testmark_parse doc todos.md
mapfile -t names < <(testmark_names doc)
fails=0
for name in "${names[@]}"; do
	case $name in
	*/input)
		case=${name%/input}
		if testmark_check doc "$case/output" < <(testmark_body doc "$name" | ./todos.sh /dev/stdin); then
			echo "PASS  $case"
		else
			echo "FAIL  $case"
			fails=$((fails + 1))
		fi
		;;
	esac
done
testmark_write doc
((fails == 0))

examples/test-todos-alone.sh · 721 B · 29dc7c3cab