aboutsummaryrefslogtreecommitdiff
path: root/test/lua/test.sh
blob: 717a02d13bade13993d80a4fb4ba7949ae569681 (plain) (blame)
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
39
40
41
42
43
44
45
46
#!/bin/sh

export VIS_PATH=.
[ -z "$VIS" ] && VIS="../../vis"
$VIS -v

if ! $VIS -v | grep '+lua' >/dev/null 2>&1; then
	echo "vis compiled without lua support, skipping tests"
	exit 0
fi

type busted >/dev/null 2>&1 || {
	echo "busted(1) not found, skipping tests"
	exit 0
}

TESTS_OK=0
TESTS_RUN=0

if [ $# -gt 0 ]; then
	test_files=$*
else
	#test_files="$(find . -type f -name "*.in") basic_empty_file.in"
	test_files="lines.in"
fi

for t in $test_files; do
	TESTS_RUN=$((TESTS_RUN + 1))
	t=${t%.in}
	t=${t#./}
	printf "%-30s" "$t"
	$VIS "$t.in" < /dev/null 2> /dev/null > "$t.busted"

	if [ $? -ne 0 ]; then
		printf "FAIL\n"
		cat "$t.busted"
	else
		TESTS_OK=$((TESTS_OK + 1))
		printf "OK\n"
	fi
done

printf "Tests ok %d/%d\n" $TESTS_OK $TESTS_RUN

# set exit status
[ $TESTS_OK -eq $TESTS_RUN ]