summaryrefslogtreecommitdiffstats
path: root/pp-test
blob: fa3f85137a4d71db35a8141a36611c459640824b (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/sh

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