diff --git a/test.sh b/test.sh index 5293964..5d3977e 100755 --- a/test.sh +++ b/test.sh @@ -4,15 +4,22 @@ set -uo pipefail declare -i FAILED=0 declare -i SUCCEDED=0 +declare -i TODTODO=0 declare -i RAN=0 NAME="" -failed_report() +report_header() { echo "++++++++++++++++++++++++++++++++++++++++++++++++++++" echo $NAME echo "++++++++++++++++++++++++++++++++++++++++++++++++++++" - echo "++++ Failed test:" + echo "++++ test input:" +} + +failed_report() +{ + NAME="failed: $NAME" + report_header cat /tmp/input.minishell echo "++++ Got output:" cat /tmp/got.minishell @@ -22,14 +29,28 @@ failed_report() echo "(red is got, green is expected)" diff --color=always /tmp/got.minishell /tmp/expected.minishell echo "++++ Run this to debug:" - echo "echo '$(cat /tmp/input.minishell)' | ./minishell" + cat < /tmp/input.minishell > /tmp/input.failed.$FAILED.minishell + echo "cat /tmp/input.failed.$FAILED.minishell | ./minishell" +} + +todo_report() +{ + NAME="todo: $NAME" + report_header + cat /tmp/input.minishell + echo "++++ Got output:" + cat /tmp/got.minishell + echo "++++ But test was marked as todo." + echo "++++ Run this to debug:" + cat < /tmp/input.minishell > /tmp/input.todo.$TODO.minishell + echo "cat /tmp/input.todo.$TODO.minishell | ./minishell" } failed() { - failed_report >> report.txt echo -n "F" FAILED+=1 + failed_report >> report.txt } succeded() @@ -57,6 +78,13 @@ expecting() assert } +todo() +{ + echo -n "t" + TODO+=1 + todo_report >> report.txt +} + setup() { rm -f report.txt @@ -65,13 +93,13 @@ setup() finalize() { echo - echo "$RAN tests ran. $SUCCEDED succeded, $FAILED failed." + echo "$RAN tests ran. $SUCCEDED succeded, $FAILED failed, $TODO todo." if [ $SUCCEDED -eq $RAN ]; then echo "All integration tests passed!" else echo "cat report.txt" - echo "to see details of failed tests" + echo "to see details of failed/todo tests" fi exit $FAILED } @@ -263,4 +291,9 @@ expecting <