aboutsummaryrefslogtreecommitdiff
path: root/tests/test_macro_processor.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_macro_processor.sh')
-rwxr-xr-xtests/test_macro_processor.sh43
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
+