test-testdata.sh
#!/bin/bash
## go-testmark's testdata files, parsed whole.
set -euo pipefail
cd "$(dirname "$0")"
# shellcheck source=tests/lib.sh
source ./lib.sh
cd "$TESTDATA" # so error messages carry the short relative path
dump_parse example.md >"$work/got"
expect_eq "example.md" "$(<"$work/got")" "$(
cat <<-'EOF'
hunk "this-is-the-data-name"
info "text"
body "the content of this code block is data which can be read,\nand *replaced*, by testmark.\n"
hunk "more-data"
info "go"
body "func OtherMarkdownParsers() (shouldHighlight bool) {\n\treturn true\n}\n"
hunk "cannot-describe-no-linebreak"
info ""
body "A markdown codeblock always has a trailing linebreak before its close indicator, you see.\n"
EOF
)"
dump_parse exampleWithDirs.md >"$work/got"
expect_eq "exampleWithDirs.md" "$(<"$work/got")" "$(
cat <<-'EOF'
hunk "one/two"
info "text"
body "foo\n"
hunk "one/three"
info "text"
body "bar\n"
hunk "one"
info "text"
body "baz\n"
hunk "really/deep/dirs/wow"
info "text"
body "zot\n"
hunk "one/four/bang"
info "text"
body "mop\n"
EOF
)"
dump_parse exampleWithDuplicateHunks.md >"$work/got"
expect_eq "exampleWithDuplicateHunks.md" "$(<"$work/got")" \
'error: testmark: exampleWithDuplicateHunks.md:12: duplicate hunk name "one/two/three"'
exit "$RESULT"
tests/test-testdata.sh · 1.3 KiB · c28251e29f