-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtidyc_test
executable file
·48 lines (42 loc) · 1013 Bytes
/
tidyc_test
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
#!/bin/bash
# Run tests for tidyc.
#
# Each test checks the expected output for an input file with particular tidyc
# arguments. The input file and arguments are encoded in the expected output
# filename as follows;
#
# output: <testX>_arg1_arg2_[...].out
# input: <testX>.c
# args: -arg1 -arg2 [...]
#
# Expected outputs of tests to run on cmdline (Default: tests/*.out).
tests=${@:-tests/*.out}
# Run a cmd and fail the test if cmd fails.
run_test () {
echo "Running: $@" >&2
"$@" || fail_test
}
# Fail the test and exit.
fail_test () {
echo "FAIL" >&2
exit 2
}
# Run a test for a given expected output file.
do_test () {
expect="$1"
name=${expect%.out}
input=${name%%_*}.c
output=tests/output.c
args="${name//_/ -} "; args=${args#* }
echo
echo $expect
run_test ./tidyc $args <$input >$output
run_test diff -q $expect $output
run_test ./tidyc $args $output
run_test diff -q $expect $output
echo "PASS"
rm -f $output
}
for expect in $tests; do
do_test $expect
done