File: tooltest.sh

package info (click to toggle)
reprepro 4.2.0-2squeeze1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 4,016 kB
  • ctags: 3,674
  • sloc: ansic: 46,905; sh: 13,899; pascal: 160; makefile: 159; python: 138
file content (137 lines) | stat: -rwxr-xr-x 2,742 bytes parent folder | download | duplicates (2)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/bin/bash

set -e

testrun() {
rules=$1
shift
if test "x$rules" = "x" ; then
	"$TESTTOOL" $TESTOPTIONS "$CHANGESTOOL" "$@"
elif test "x$rules" = "x-" ; then
	"$TESTTOOL" -r $TESTOPTIONS "$CHANGESTOOL" "$@"
else
	"$TESTTOOL" -r $TESTOPTIONS "$CHANGESTOOL" "$@" 3<"$rules".rules
fi
}
testout() {
rules=$1
shift
if test "x$rules" = "x" ; then
	"$TESTTOOL" -o results $TESTOPTIONS "$CHANGESTOOL" "$@"
elif test "x$rules" = "x-" ; then
	"$TESTTOOL" -o results -r $TESTOPTIONS "$CHANGESTOOL" "$@"
else
	"$TESTTOOL" -o results -r $TESTOPTIONS "$CHANGESTOOL" "$@" 3<"$rules".rules
fi
}
dogrep() {
echo grep -q "$@"
grep -q "$@"
}
dongrep() {
echo "!grep" -q "$@"
! grep -q "$@"
}
dodiff() {
echo diff -u "$@"
diff -u "$@"
}
dodo() {
echo "$@"
"$@"
}

WORKDIR="`pwd`/testdir"

if [ "x$1" == "x--delete" ] ; then
	rm -r "$WORKDIR" || true
	shift
fi

mkdir "$WORKDIR"
cd "$WORKDIR"

if [ "1" -gt "$#" ] || [ "3" -lt "$#" ] ; then
	echo "Syntax: test.sh <src-dir> [<testtool-binary>] [<changestool-binary>]" >&2
	exit 1
fi
SRCDIR="$1"
if [ -z "$TESTOPTIONS" ] ; then
	TESTOPTIONS="-e -a"
#	TESTOPTIONS="-e -a --debug --suppressions=$SRCDIR/valgrind.supp"
fi
if [ "2" -le "$#" ] ; then
	TESTTOOL="$2"
else
	TESTTOOL=testtool
fi
if [ "3" -le "$#" ] ; then
	CHANGESTOOL="$3"
else
	CHANGESTOOL="$SRCDIR/changestool"
fi
TESTS="$SRCDIR/tests"
UPDATETYPE=update
export PATH="$TESTS:$PATH"
if ! [ -x "$CHANGESTOOL" ] ; then
	echo "Could not find $CHANGESTOOL!" >&2
	exit 1
fi
TESTTOOLVERSION="`$TESTTOOL --version`"
case $TESTTOOLVERSION in
	"testtool version "*) ;;
	*) echo "Failed to get version of testtool($TESTTOOL)"
	   exit 1
	   ;;
esac
touch results.empty

testrun - 3<<EOF
*=modifychanges: Modify a Debian style .changes file
*=Syntax: modifychanges <changesfile> <commands>
*=Possible commands include:
*= verify
returns 1
EOF

testrun - --help 3<<EOF
stdout
*=modifychanges: Modify a Debian style .changes file
*=Syntax: modifychanges <changesfile> <commands>
*=Possible commands include:
*= verify
returns 0
EOF

testrun - test.changes verify 3<<EOF
stderr
*=No such file 'test.changes'!
stdout
returns 1
EOF

touch test.changes
testrun - test.changes verify 3<<EOF
stderr
=Data seems not to be signed trying to use directly...
*=Could only find spaces within 'test.changes'!
stdout
returns 1
EOF

echo "Format: 2.0" > test.changes
testrun - test.changes verify 3<<EOF
stderr
=Data seems not to be signed trying to use directly...
*=Missing 'Source:' field in test.changes!
=Missing 'Version:' field in test.changes!
=Missing 'Maintainer:' field in test.changes!
stdout
returns 1
EOF

set +v +x
echo
echo "If the script is still running to show this,"
echo "all tested cases seem to work. (Though writing some tests more can never harm)."
exit 0