]> pd.if.org Git - zpackage/blob - t/tap.sh
add bad file type tests to addfile test
[zpackage] / t / tap.sh
1 #!/bin/sh
2
3 tn=0
4 planned=0
5
6 tryrun() {
7         note="$@"
8         program=$1
9         shift
10         $program "$@"
11         if [ $? -ne 0 ]; then
12                 printf 'not ';
13         fi
14         tn=$((tn + 1))
15         printf 'ok %d - %s %s\n' $tn $program "$*"
16 }
17
18 shownote() {
19         if [ "$note" != "" ]; then
20                 printf '# %s\n' "$note"
21         fi
22 }
23
24 okexit() {
25         exitwith 0 "$*"
26 }
27
28 failsok() {
29         rv=$?
30         note=
31         if [ $rv -eq 0 ]; then
32                 printf 'not ';
33                 note=$(printf 'got "%d" expected "%d"' "$rv" "0")
34         fi
35         tn=$((tn + 1))
36         printf 'ok %d - %s\n' $tn "$*"
37         shownote
38 }
39
40 exitwith() {
41         rv=$?
42         note=
43         if [ $rv -ne $1 ]; then
44                 printf 'not ';
45                 note=$(printf '# got "%d" expected "%d"' "$1" "$2")
46         fi
47         shift
48         tn=$((tn + 1))
49         printf 'ok %d - %s\n' $tn "$*"
50         shownote
51 }
52
53 okstreq() {
54         note=
55         if [ "$1" != "$2" ]; then
56                 printf 'not ';
57                 note=$(printf 'got "%s" expected "%s"' "$1" "$2")
58         fi
59
60         shift;shift;
61         tn=$((tn + 1))
62         printf 'ok %d - %s\n' $tn "$*"
63         shownote
64 }
65
66 plan() {
67         planned=$1
68         printf '1..%d\n' $planned
69 }
70
71 finish() {
72         if [ $planned -eq 0 ]; then
73                 printf '1..%d\n' $tn
74         fi
75 }