diff options
author | Qrius <[email protected]> | 2025-02-21 12:51:08 +0100 |
---|---|---|
committer | Qrius <[email protected]> | 2025-02-21 12:51:11 +0100 |
commit | 5394cfcf6e0ab0d110429b22dffa7e8bd1cf39dc (patch) | |
tree | 748dc9a19cdc3e9910f832d1a7a1ba81acbe22e9 /tests/test_macro_processor.sh | |
download | skaldpress-5394cfcf6e0ab0d110429b22dffa7e8bd1cf39dc.tar.gz skaldpress-5394cfcf6e0ab0d110429b22dffa7e8bd1cf39dc.zip |
first version of python rewrite
Diffstat (limited to 'tests/test_macro_processor.sh')
-rwxr-xr-x | tests/test_macro_processor.sh | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/test_macro_processor.sh b/tests/test_macro_processor.sh new file mode 100755 index 0000000..1a7accd --- /dev/null +++ b/tests/test_macro_processor.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +ALL_OUTPUT=0 + +test () { + file_content=$(<tests/input_files/$1) + readarray -t sections < <(awk -v RS="---" '{print}' <<< "$file_content") + var1=$(echo "$file_content" | awk -v RS="\n---\n" 'NR==1') + var2=$(echo "$file_content" | awk -v RS="\n---\n" 'NR==2') + + if [ "$ALL_OUTPUT" -eq 0 ]; then + res=$(echo -n "$var1" | smp 2> /dev/null) + else + res=$(echo -n "$var1" | smp) + fi + if [ ! "$res" = "$var2" ]; then + tput setaf 1 + echo "$1 NOT OK:" + tput setaf 3 + echo "- Expected --" + echo "$var2" + tput setaf 1 + echo "- Result ----" + echo "$res" + echo "-------------" + tput sgr0 + exit 1 + else + tput setaf 2 + echo "$1 OK" + tput sgr0 + fi +} + +if [ "$#" -eq 1 ]; then + ALL_OUTPUT=1 + test $1 +else + for file in tests/input_files/*; do + test "$(basename $file)" + done +fi + |