File: run-test

package info (click to toggle)
midish 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,344 kB
  • sloc: ansic: 22,502; sh: 268; makefile: 119
file content (53 lines) | stat: -rwxr-xr-x 1,006 bytes parent folder | download
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
47
48
49
50
51
52
53
#!/bin/sh

#
# For each command-line argument, run the corresponding test as follows:
#
# - Load the expected result $testname.res and save it in $testname.tmp1
#
# - Run $testname.cmd and save the actual result in $testname.tmp2
#
# - Check that there are no differences between the actual and the
#   expected results. If there are, the resulting $testname.diff and
#   and $testname.log files are kept.
#

if [ -z "$*" ]; then
	set -- *.cmd
fi

echo 1..$#

#
# loop over all tests
#
for i; do
	i=${i%.cmd}
	(echo	load \"$i.res\"\;				\
		save \"$i.tmp1\"\;				\
		reset \;					\
		exec \"$i.cmd\"\;				\
		save \"$i.tmp2\"\;				\
			| ../midish -b >$i.log 2>&1 )		\
	&&							\
	diff -u $i.tmp1 $i.tmp2 >$i.diff 2>>$i.log
	if [ "$?" -eq 0 ]; then
		echo ok $i
		rm -- $i.tmp1 $i.tmp2 $i.diff $i.log
	else
		echo not ok $i
		failed="$failed $i"
	fi
done

#
# print summary, and set exit code
#
echo >&2
if [ -n "$failed" ]; then
	echo Tests failed: $failed >&2
	exit 1
else
	echo Tests passed
	exit 0
fi