summaryrefslogtreecommitdiff
path: root/test/runtests.sh
blob: 7c9197172487d769b35978a205d4ad902d78a685 (plain)
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
#!/bin/sh

CVSROOT="$PWD/repo"
export CVSROOT

if [ ! -d "$CVSROOT" ]; then
    echo "$CVSROOT should be a CVS repository."
    echo "Have you run maketestrepo.sh?"
    exit
fi

if [ ! -x ../cvsps ]; then
    echo "../cvsps needs to exist before it can be tested."
    exit
fi

CVSMODULE=wd
CVSPSFLAGS="--cvs-direct -q"
DIFFFLAGS="-u -a"
CVSPSFILTER="
    s/^Date: */Date: DATESTAMP/
    s/^Author: .*/Author: AUTHOR/
    "
CVSPSCACHEFILTER="
    s/^cache date: */cache date: DATESTAMP/
    s/^date: .*/date: DATESTAMP/
    s/^author: .*/author: AUTHOR/
    "

# Test 1: Can we produce sensible output without the cache
EXPECTED="$PWD/test1.output"
ACTUAL=`mktemp`
../cvsps -x $CVSPSFLAGS $CVSMODULE | sed -e "$CVSPSFILTER" > "$ACTUAL" || exit

diff $DIFFFLAGS "$EXPECTED" "$ACTUAL" || exit

# Test 2: Do we produce a sensible cache file?
EXPECTED="$PWD/test2.cache"
RAWCACHE=`mktemp`
ACTUAL=`mktemp`
../cvsps -x -c "$RAWCACHE" $CVSPSFLAGS $CVSMODULE > /dev/null 
sed -e "$CVSPSCACHEFILTER" "$RAWCACHE" > "$ACTUAL" || exit

diff $DIFFFLAGS "$EXPECTED" "$ACTUAL" || exit

# Test 3: Can we read the cache file we produce?
../cvsps -c "$RAWCACHE" $CVSPSFLAGS $CVSMODULE > /dev/null || exit

# Test 4: Do we produce the same output by reading the cache as we did
# originally?
EXPECTED="$PWD/test1.output"
ACTUAL=`mktemp`
../cvsps -c "$RAWCACHE" $CVSPSFLAGS $CVSMODULE | sed -e "$CVSPSFILTER" > "$ACTUAL" || exit

diff $DIFFFLAGS "$EXPECTED" "$ACTUAL" || exit

echo "Tests passed."