summaryrefslogtreecommitdiff
path: root/2016/test.sh
blob: 78d4a5ab9c91479b68494df5bb8c0f99fd9d1a2d (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
33
34
35
36
37
38
#!/usr/bin/env bash
set -e
set -o pipefail

function prepare() {
	fname="$1"
	ext="${fname##*.}"
	base="${fname:0:${#fname}-${#ext}-1}"
	case "$ext" in
		py)
			echo "./$fname"
			;;
		c|cpp)
			make "$base" 2>&1 | grep -v 'is up to date' >&2
			echo "./$base"
			;;
		rip)
			echo "rip $fname"
			;;
		*)
			echo >&2 "No handler for file '$fname'!"
			exit 1
	esac
}


for i in $(seq 1 25); do
	for a in a b; do
		exe=""
		for fname in $i$a.{py,c,cpp,rip}; do
			test -f $fname || continue
			cmd="$(prepare "$fname")"
			echo -n "$i$a: \"$cmd\" "
			diff <($cmd <$i.in 2>/dev/null) $i$a.out
			echo ok
		done
	done
done