From 085e620e5f5d0f85a8012785c89604ffa1a598d4 Mon Sep 17 00:00:00 2001 From: Ben Brown Date: Tue, 22 Oct 2013 12:40:30 +0100 Subject: Add new Yarn based test suite This introduces a yarn which demonstrates testing tbdiff. Also included is a shell library to assist with writing yarn based tests, a script for running the test suite and a simple README for executing the tests. --- yarns/README | 6 ++++++ yarns/create-deploy.yarn | 40 ++++++++++++++++++++++++++++++++++++++++ yarns/run_yarns.sh | 7 +++++++ yarns/tbdiff.shell-lib | 14 ++++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 yarns/README create mode 100644 yarns/create-deploy.yarn create mode 100755 yarns/run_yarns.sh create mode 100644 yarns/tbdiff.shell-lib 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 +} -- cgit v1.2.1