summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Allen <screwtape@froup.com>2007-05-19 19:53:35 +1000
committerYann Dirson <ydirson@altern.org>2008-03-31 16:09:13 +0200
commitd21458c0fe3e64313b23b406a5df64565d210034 (patch)
tree9b2cd28e12e2ca6ff9130137421b924ec4fb2846
parentdc7f8632341107da52a5604e99041da4e84fd92c (diff)
downloadcvsps-d21458c0fe3e64313b23b406a5df64565d210034.tar.gz
A basic test suite for cvsps.
To run the tests, go into the test/ directory, run maketestrepo.sh once and then run runtests.sh as often as you like. Currently, the following things are tested: - A basic CVS repository can be parsed without using the cache. - Parsing a basic CVS repository produces a sensible cache file. - The cache-file produced can be read again. - Patchset output read from the cache file is the same as patchset output read directly from CVS.
-rw-r--r--test/.gitignore2
-rwxr-xr-xtest/maketestrepo.sh36
-rwxr-xr-xtest/runtests.sh57
-rw-r--r--test/test1.output12
-rw-r--r--test/test2.cache23
5 files changed, 130 insertions, 0 deletions
diff --git a/test/.gitignore b/test/.gitignore
new file mode 100644
index 0000000..0cad1c3
--- /dev/null
+++ b/test/.gitignore
@@ -0,0 +1,2 @@
+repo
+wd
diff --git a/test/maketestrepo.sh b/test/maketestrepo.sh
new file mode 100755
index 0000000..4a0f9bf
--- /dev/null
+++ b/test/maketestrepo.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+CVSROOT="$PWD/repo"
+WORKINGDIR="$PWD/wd"
+export CVSROOT
+
+rm -rf "$CVSROOT" "$WORKINGDIR" || exit
+
+# Set up the repository
+mkdir -p "$CVSROOT"
+cvs init
+
+# Set up the module
+mkdir -p "$WORKINGDIR"
+(
+ cd "$WORKINGDIR"
+ cvs import -m "Initial import" wd vendor-tag release-tag
+)
+rm -rf "$WORKINGDIR"
+cvs co wd
+
+# Add a dummy file to the module, with some tags
+(
+ cd "$WORKINGDIR"
+
+ echo "A test of multiple tags" > tag-testing
+
+ cvs add tag-testing
+
+ cvs commit -m "Initial file"
+
+ cvs tag -c tag1
+
+ cvs tag -c tag2
+
+)
diff --git a/test/runtests.sh b/test/runtests.sh
new file mode 100755
index 0000000..7c91971
--- /dev/null
+++ b/test/runtests.sh
@@ -0,0 +1,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."
diff --git a/test/test1.output b/test/test1.output
new file mode 100644
index 0000000..1728662
--- /dev/null
+++ b/test/test1.output
@@ -0,0 +1,12 @@
+---------------------
+PatchSet 1
+Date: DATESTAMP
+Author: AUTHOR
+Branch: HEAD
+Tag: tag2
+Log:
+Initial file
+
+Members:
+ tag-testing:INITIAL->1.1
+
diff --git a/test/test2.cache b/test/test2.cache
new file mode 100644
index 0000000..e23e11d
--- /dev/null
+++ b/test/test2.cache
@@ -0,0 +1,23 @@
+cache version: 1
+cache date: DATESTAMP
+file: tag-testing
+
+tag1: 1.1
+tag2: 1.1
+
+1.1 HEAD
+
+
+patchset: 1
+date: DATESTAMP
+author: AUTHOR
+tag: tag2
+tag_flags: 0
+branch: HEAD
+branch_add: 0
+descr:
+Initial file
+-=-END CVSPS DESCR-=-
+members:
+file:tag-testing; pre_rev:INITIAL; post_rev:1.1; dead:0; branch_point:0
+