From 82b5f445fe4ead5968d5e328665e83fbccc0b8d5 Mon Sep 17 00:00:00 2001 From: Remzi Arpaci-Dusseau Date: Sun, 5 Sep 2021 12:54:43 -0500 Subject: [PATCH] updated color stuff to work more broadly --- tester/run-tests.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tester/run-tests.sh b/tester/run-tests.sh index df08581..3d0bfa4 100755 --- a/tester/run-tests.sh +++ b/tester/run-tests.sh @@ -1,4 +1,8 @@ -#! /usr/bin/env bash +#! /usr/bin/env bash + +GREEN='\033[0;32m' +RED='\033[0;31m' +NONE='\033[0m' # run_test testdir testnumber run_test () { @@ -39,11 +43,12 @@ print_error_message () { local testnum=$1 local contrunning=$2 local filetype=$3 - builtin echo -e "\e[31mtest $testnum: $filetype incorrect\e[0m" + builtin echo -e "test $testnum: ${RED}$testnum.$filetype incorrect${NONE}" echo " what results should be found in file: $testdir/$testnum.$filetype" echo " what results produced by your program: tests-out/$testnum.$filetype" echo " compare the two using diff, cmp, or related tools to debug, e.g.:" echo " prompt> diff $testdir/$testnum.$filetype tests-out/$testnum.$filetype" + echo " See tests/$testnum.run for what is being run" if (( $contrunning == 0 )); then exit 1 fi @@ -82,7 +87,7 @@ run_and_check () { exit 0 fi if (( $verbose == 1 )); then - echo -n -e "\e[33mrunning test $testnum: \e[0m" + echo -n -e "running test $testnum: " cat $testdir/$testnum.desc fi run_test $testdir $testnum $verbose @@ -95,7 +100,7 @@ run_and_check () { fi # echo "results: outcheck:$outcheck errcheck:$errcheck" if (( $rccheck == 0 )) && (( $outcheck == 0 )) && (( $errcheck == 0 )) && (( $othercheck == 0 )); then - builtin echo -e "\e[32mtest $testnum: passed\e[0m" + echo -e "test $testnum: ${GREEN}passed${NONE}" if (( $verbose == 1 )); then echo "" fi @@ -183,7 +188,7 @@ fi # do a one-time setup step if (( $skippre == 0 )); then if [[ -f tests/pre ]]; then - builtin echo -e "\e[33mdoing one-time pre-test\e[0m (use -s to suppress)" + echo -e "doing one-time pre-test (use -s to suppress)" source tests/pre if (( $? != 0 )); then echo "pre-test: failed"