icp/oer/courses/c-newcomers/sections/02-dice/01-dice/test.sh

28 lines
391 B
Bash
Executable File

#!/bin/bash
pass=true
out=""
regex='^You rolled a [1-6]$'
# figure out a way to make this more reliable
for i in {1..1}
do
sleep .15
program_out=$(./program)
if [[ "$program_out" =~ $regex ]]
then
out="$out\nPASS $program_out"
else
pass=false
out="$out\nFAIL $program_out"
fi
done
if("$pass" = true)
then
echo PASS
else
echo FAIL
fi
echo ""
echo -e $out