summaryrefslogtreecommitdiff
path: root/yarns
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2014-04-18 13:45:56 +0100
committerLars Wirzenius <liw@liw.fi>2014-04-18 13:45:56 +0100
commit564b31b1e36af4e37b182ef9dbaaede908ca2000 (patch)
tree075ad21d3b368e9631502cc6e0d88937318afd7b /yarns
parentc96ce873b1692da2f51e1722d38c42dc6188fb11 (diff)
downloaddistix-564b31b1e36af4e37b182ef9dbaaede908ca2000.tar.gz
Add test for _list with empty file; fix code
Diffstat (limited to 'yarns')
-rw-r--r--yarns/020-metadata-manipulation.yarn6
-rw-r--r--yarns/900-implements.yarn37
2 files changed, 37 insertions, 6 deletions
diff --git a/yarns/020-metadata-manipulation.yarn b/yarns/020-metadata-manipulation.yarn
index c7616f6..38703bc 100644
--- a/yarns/020-metadata-manipulation.yarn
+++ b/yarns/020-metadata-manipulation.yarn
@@ -16,3 +16,9 @@ metadata file doesn't exist.
THEN attempt failed
AND error message matches R465BCX
+An empty file should result in empty output.
+
+ GIVEN file METADATA containing ""
+ WHEN user attempts to run distix _list METADATA
+ THEN attempt succeeded
+ AND output is ""
diff --git a/yarns/900-implements.yarn b/yarns/900-implements.yarn
index 4761005..21a9fc9 100644
--- a/yarns/900-implements.yarn
+++ b/yarns/900-implements.yarn
@@ -15,21 +15,37 @@ allow the step to provide the command line arguments, but then also
adds in options and things to make distix be isolated from, say,
global configuration etc.
+Note that we change the working directory to `$DATADIR` so that any
+filename arguments the step gives refer to files there rather than in
+`$SRCDIR`, which is the default working directory for step execution.
+
IMPLEMENTS WHEN user attempts to run distix (.*)
- rm -f "$DATADIR/attempt.exit"
- rm -f "$DATADIR/attempt.stdout"
- rm -f "$DATADIR/attempt.stderr"
+ cd "$DATADIR"
+ rm -f attempt.exit attempt.stdout attempt.stderr
if "$SRCDIR/distix" --no-default-config $MATCH_1 \
- > "$DATADIR/attempt.stdout" 2> "$DATADIR/attempt.stderr"
+ > attempt.stdout 2> $DATADIR/attempt.stderr
then
- echo 0 > "$DATADIR/attempt.exit"
+ echo 0 > attempt.exit
else
- echo "$?" > "$DATADIR/attempt.exit"
+ echo "$?" > attempt.exit
fi
We also need steps for inspecting the results of attempting to run
distix.
+ IMPLEMENTS THEN attempt succeeded
+ cat "$DATADIR/attempt.exit"
+ if ! grep -Fx 0 "$DATADIR/attempt.exit"
+ then
+ echo "Attempt should have succeeded, but didn't" 1>&2
+ exit 1
+ fi
+
+ IMPLEMENTS THEN output is "(.*)"
+ cat "$DATADIR/attempt.stdout"
+ printf "$MATCH_1" > "$DATADIR/temp-stdout"
+ diff -u "$DATADIR/temp-stdout" "$DATADIR/attempt.stdout"
+
IMPLEMENTS THEN attempt failed
cat "$DATADIR/attempt.exit" # helps debugging scenarios
if grep -Fx 0 "$DATADIR/attempt.exit"
@@ -41,3 +57,12 @@ distix.
IMPLEMENTS THEN error message matches (.*)
cat "$DATADIR/attempt.stderr"
grep -e "$MATCH_1" "$DATADIR/attempt.stderr"
+
+File creation
+-------------
+
+We need to provide a way for scenarios to create files with known
+content.
+
+ IMPLEMENTS GIVEN file (\S+) containing "(.*)"
+ printf "$MATCH_2" > "$DATADIR/$MATCH_1"