summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Brown <ben.brown@codethink.co.uk>2013-10-24 13:57:01 +0100
committerBen Brown <ben.brown@codethink.co.uk>2013-10-24 13:57:01 +0100
commit5b704bb1c1c826891897dee156edb58e2f5c197a (patch)
tree9ca3801b8fc6c016b08bf7c00fe5b6f957024d9b
parent2fdfa3149be9ae43fb23cda6459e841fb3a90698 (diff)
parent085e620e5f5d0f85a8012785c89604ffa1a598d4 (diff)
downloadtbdiff-5b704bb1c1c826891897dee156edb58e2f5c197a.tar.gz
Merge branch 'benbrown/yarns'
-rw-r--r--yarns/README6
-rw-r--r--yarns/create-deploy.yarn40
-rwxr-xr-xyarns/run_yarns.sh7
-rw-r--r--yarns/tbdiff.shell-lib14
4 files changed, 67 insertions, 0 deletions
diff --git a/yarns/README b/yarns/README
new file mode 100644
index 0000000..67e2bcc
--- /dev/null
+++ b/yarns/README
@@ -0,0 +1,6 @@
+Running the test suite
+----------------------
+Change to the top-level directory of the tbdiff source tree and
+execute run_yarns.sh:
+
+$ ./yarns/run_yarns.sh
diff --git a/yarns/create-deploy.yarn b/yarns/create-deploy.yarn
new file mode 100644
index 0000000..5a332d7
--- /dev/null
+++ b/yarns/create-deploy.yarn
@@ -0,0 +1,40 @@
+Trebuchet tests for the creating and deploying of binary deltas
+===============================================================
+
+The following scenarios test tbdiff-deploy's ability to correctly transform
+the content of a target directory, to that of a source directory, given an
+appropriate binary delta created by tbdiff-create.
+
+Simple file diff
+----------------
+
+This simple test checks that file content is as expected, if the content of
+the two text files are different, the test will fail.
+
+ SCENARIO Changing a file's content works
+ GIVEN a directory exists named 'A'
+ AND the directory 'A' contains a file named 'foo.txt' with '1' in it
+ AND a directory exists named 'B'
+ AND the directory 'B' contains a file named 'foo.txt' with '2' in it
+ WHEN tbdiff-create creates a binary delta named 'AB.tbdiff' from 'A' to 'B'
+ AND tbdiff-deploy applies the delta 'AB.tbdiff' to 'A'
+ THEN the files 'A/foo.txt' and 'B/foo.txt' have the same contents
+
+Implementations for simple file diff
+------------------------------------
+
+ IMPLEMENTS GIVEN a directory exists named '([^']+)'
+ mkdir "$DATADIR/$MATCH_1"
+
+ IMPLEMENTS GIVEN the directory '([^']+)' contains a file named '([^']+)' with '([^']+)' in it
+ echo $MATCH_3 > "$DATADIR/$MATCH_1/$MATCH_2"
+
+ IMPLEMENTS WHEN tbdiff-create creates a binary delta named '([^']+)' from '([^']+)' to '([^']+)'
+ "$SRCDIR/tbdiff-create/tbdiff-create" "$DATADIR/$MATCH_1" "$DATADIR/$MATCH_2" "$DATADIR/$MATCH_3"
+
+ IMPLEMENTS WHEN tbdiff-deploy applies the delta '([^']+)' to '([^']+)'
+ cd "$DATADIR/$MATCH_2"
+ "$SRCDIR/tbdiff-deploy/tbdiff-deploy" "$DATADIR/$MATCH_1"
+
+ IMPLEMENTS THEN the files '([^']+)' and '([^']+)' have the same contents
+ diff "$DATADIR/$MATCH_1" "$DATADIR/$MATCH_2"
diff --git a/yarns/run_yarns.sh b/yarns/run_yarns.sh
new file mode 100755
index 0000000..ce26b86
--- /dev/null
+++ b/yarns/run_yarns.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+#
+# Run test suite for tbdiff.
+
+# Run scenario tests with yarn.
+
+yarn -s yarns/tbdiff.shell-lib yarns/*.yarn
diff --git a/yarns/tbdiff.shell-lib b/yarns/tbdiff.shell-lib
new file mode 100644
index 0000000..658efe6
--- /dev/null
+++ b/yarns/tbdiff.shell-lib
@@ -0,0 +1,14 @@
+# Shell library for tbdiff yarns.
+#
+# The shell functions in this library are meant to make writing IMPLEMENTS
+# sections for yarn scenario tests easier.
+
+# Currently, yarn isn't setting $SRCDIR to point at the project source
+# directory. We simulate this here.
+
+{
+ set +u
+ if [ -z "$SRCDIR" ]; then
+ export SRCDIR="$(pwd)"
+ fi
+}