computable-pandoc/scripts/test.sh

33 lines
687 B
Bash
Raw Normal View History

2023-03-09 15:58:14 -06:00
# Makes tests
2023-02-16 19:04:01 -06:00
# Variables
2023-03-09 20:13:01 -06:00
NAME=literate.lua
READER=src/$NAME
2023-03-08 21:05:42 -06:00
ARGS=()
# Removes unwanted args
for arg in "$@"; do
case $arg in
2023-03-09 20:13:01 -06:00
"--dist") READER=dist/$NAME ;;
2023-03-08 21:05:42 -06:00
*) ARGS+=($arg) ;;
esac
done
2023-02-16 19:04:01 -06:00
# Checks args
2023-03-09 20:13:01 -06:00
if [ -z "$ARGS" ]; then
2023-02-16 19:04:01 -06:00
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-09 20:13:01 -06:00
mds=$'\n\n'`(pandoc -t markdown tests/*.md)`
rst=$'\n\n'`(pandoc -t markdown tests/*.rst)`
org=$'\n\n'`(pandoc -t markdown tests/*.org)`
echo "$mds" "$rst" "$org" | pandoc -f $READER -t $arg
2023-02-16 19:04:01 -06:00
done