tests: describe names by what they contain, and caller settings as unusual, not hostile.
commit 21fc89340dad5df7130c3f766ae741516990251c · parent 1fa208e690
· browse this tree
Ximianth, 2026-10-23 14:46:58 UTC
Hunk names are document content, and the caller's settings are the caller's choice; neither means harm. What the tests check is that the library processes such names and settings safely. test-hostile-env.sh becomes test-caller-env.sh.
diff --git a/tests/lib.sh b/tests/lib.sh index 58081a8..7940209 100644 --- a/tests/lib.sh +++ b/tests/lib.sh @@ -1,7 +1,7 @@ #!/bin/bash ## Shared helpers for the testmark-bash tests. Sourced, not executed. ## Sources the library, makes a scratch dir and cd's into it, and provides PASS/FAIL reporting. -## The helpers stay exact under the hostile settings test-hostile-env.sh turns on: +## The helpers stay exact under the unusual settings test-caller-env.sh turns on: ## comparisons use `[ = ]`, which `nocasematch` doesn't touch. # shellcheck disable=SC2034 # RESULT is read by the test scripts diff --git a/tests/test-api.sh b/tests/test-api.sh index 1c22dd4..deecb4a 100755 --- a/tests/test-api.sh +++ b/tests/test-api.sh @@ -102,19 +102,19 @@ expect_fail "names arity" 'testmark: usage: testmark_names HANDLE' testmark_name expect_fail "body arity" 'testmark: usage: testmark_body HANDLE NAME' testmark_body a x y expect_fail "info arity" 'testmark: usage: testmark_info HANDLE NAME' testmark_info a -# --- hostile hunk names: plain data, never evaluated --- +# --- names with shell syntax: plain data, never evaluated --- names=('$(>pwned1)' '`>pwned2`' 'a]b' 'x[0]' '@' '*' '$HOME' "'q'" '"q"' 'a\b') for name in "${names[@]}"; do printf '[testmark]:# (%s)\n```\nbody of %s\n```\n\n' "$name" "$name" -done >hostile.md -testmark_parse h hostile.md +done >syntax.md +testmark_parse h syntax.md mapfile -t got < <(testmark_names h) -expect_eq "hostile names list" "$(printf '%s\n' "${got[@]}")" "$(printf '%s\n' "${names[@]}")" +expect_eq "names with shell syntax: list" "$(printf '%s\n' "${got[@]}")" "$(printf '%s\n' "${names[@]}")" for name in "${names[@]}"; do - expect_eq "hostile name $name" "$(testmark_body h "$name")" "body of $name" + expect_eq "name $name" "$(testmark_body h "$name")" "body of $name" done -expect_fail "a hostile unknown name" 'testmark: h: no hunk named "$(>pwned3)"' testmark_body h '$(>pwned3)' -expect_fail "a hostile handle" 'testmark: unknown handle "h[$(>pwned4)]"' testmark_body 'h[$(>pwned4)]' x +expect_fail "an unknown name with shell syntax" 'testmark: h: no hunk named "$(>pwned3)"' testmark_body h '$(>pwned3)' +expect_fail "a handle with shell syntax" 'testmark: unknown handle "h[$(>pwned4)]"' testmark_body 'h[$(>pwned4)]' x expect_eq "nothing was executed" "$(echo pwned*)" "pwned*" exit "$RESULT" diff --git a/tests/test-hostile-env.sh b/tests/test-caller-env.sh similarity index 100% rename from tests/test-hostile-env.sh rename to tests/test-caller-env.sh