test.sh (954B)
1 #!/bin/sh 2 #This is a dumpster fire - I wish I could use rc for this 3 4 dir="$(echo "$0" | cut -c 3- | cut -d. -f1)" 5 prog="$1" 6 total=0 7 tests="$(ls -l "$dir"/input* | wc -l)" 8 out="expected" 9 10 for i in $(seq 1 $(($tests - 1))); do 11 echo "$prog" | grep -q full && test $i -eq 1 && continue 12 echo "$prog" | grep -q full && #Full would take too long to compute big amounts of. Use 30 13 output="$(printf "30\n$(tail +2 "test1/input${i}" | tail -63)" | "$prog")" || 14 output="$("$prog" < "${dir}/input${i}")" 15 first_line="$(echo "$output" | head -n 1)" 16 rest="$(echo "$output" | tail -n +2)" 17 18 total="$(echo "$total" + "$first_line" | bc -l)" 19 if $(echo "$prog" | grep -q full); then 20 printf "30\n$(tail +2 "${dir}/input${i}" | tail -63)" | ./gavrilov/bell | tail +2 > test1/full${i} 21 out="full" 22 fi 23 echo "$prog" | grep -q greed || #greed may have wrong output - ignore it 24 diff -q <(echo "$rest") "${dir}/${out}${i}" || (echo -${i} && exit 1) 25 done 26 27 echo "$total"