pure-sh-bible/test.sh

26 lines
565 B
Bash
Raw Permalink Normal View History

2019-09-19 11:26:12 +02:00
#!/bin/sh
# shellcheck source=/dev/null
#
# Tests for the Pure sh Bible.
main() {
trap 'rm -f readme_code test_file' EXIT INT
# Extract code blocks from the README.
while read -r line; do
[ "$code" ] && [ "$line" != \`\`\` ] &&
printf '%s\n' "$line"
case $line in
\`\`\`sh) code=1 ;;
\`\`\`) code=
esac
done < README.md > readme_code
2019-09-24 07:27:56 +02:00
# Run shellcheck on the extracted code blocks
# and this test script itself.
2019-09-19 11:26:12 +02:00
shellcheck -s sh readme_code test.sh || exit 1
}
main "$@"