computable-pandoc/scripts/test.sh

35 lines
784 B
Bash
Raw Normal View History

2023-02-16 19:04:01 -06:00
# Variables
2023-03-08 21:05:42 -06:00
ROOT=$(git rev-parse --show-toplevel)
FILTER=$ROOT/src/literate.lua
ARGS=()
# Removes unwanted args
for arg in "$@"; do
case $arg in
"--dist") FILTER=$ROOT/dist/literate.min.lua ;;
*) ARGS+=($arg) ;;
esac
done
2023-02-16 19:04:01 -06:00
# Moves to tests directory and clears the terminal
2023-03-08 21:05:42 -06:00
cd $ROOT/tests
2023-02-16 19:04:01 -06:00
clear
# Checks args
if [ -z "$*" ]; then
echo "ERROR: At least one argument is needed. For example:"
echo " sh $0 native"
echo " sh $0 native markdown"
exit 1
fi
# Does tests
echo "🐾 Starting tests"
2023-03-08 21:05:42 -06:00
for arg in "$ARGS"; do
2023-02-16 19:04:01 -06:00
echo && echo "⚗️ Test in '$arg' format:"
2023-03-08 21:05:42 -06:00
mds=$'\n\n'`(pandoc -t markdown *.md)`
rst=$'\n\n'`(pandoc -t markdown *.rst)`
org=$'\n\n'`(pandoc -t markdown *.org)`
echo "$mds" "$rst" "$org" | pandoc --lua-filter $FILTER -t $arg
2023-02-16 19:04:01 -06:00
done