#!/bin/sh ################################################## # A test script that uses ./runner.sh to run all # # tests for a given phase. # ################################################## function java() { expected=$(bash runner.sh java "$1.java") } function match() { [[ "$1" == *"error"* ]] && expected="Type error" || expected="Program type checked successfully" } testdir="./output" case "$1" in "heat") ext="java" comp="match" ;; "boil") ext="java" comp="java" ;; "vaporize") ext="vapor" comp="java" ;; "condense") ext="vaporm" comp="java" ;; *) echo "usage $0 [heat|boil|vaporize|condense]" exit 1 ;; esac echo "$testdir/*.$ext" for file in $testdir/*.$ext; do [ -f "$file" ] || break base=${file%.*} echo -n "Processing file: $base " $comp $base actual=$(bash runner.sh $1 $file 2>/dev/null) [[ $expected == $actual ]] && echo 'PASSED' || echo -e "FAILED" done