#!/bin/bash prog="$1"; shift realpath="$(readlink -f "$prog")" workdir=${realpath%/*} basepath=${workdir##*/} cd $workdir javac $prog.java || exit 1 testcase() { if [[ ! -e "$basepath.i$i" ]]; then return 1 fi echo "testing $basepath.i$1" java -ea "$prog" < "$basepath.i$1" &> tmpout diff --strip-trailing-cr -Nua "$basepath.o$1" tmpout rm tmpout } if (($#)); then for i in "$@"; do testcase $i done else i=1 while true; do testcase $i || break ((i++)) done fi