summaryrefslogtreecommitdiffstats
path: root/pp-test
blob: 5158a2310ae09f98f6ddc7dc76dfef274cb75df6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/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