updated color stuff to work more broadly

This commit is contained in:
Remzi Arpaci-Dusseau
2021-09-05 12:54:43 -05:00
parent c88570189e
commit 82b5f445fe

View File

@@ -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"