summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-12-05 17:40:26 +0000
committerLars Wirzenius <liw@liw.fi>2013-12-05 17:40:26 +0000
commitcf5ce3a40e8610d5df33ea2e6a0722d670658075 (patch)
tree59e143aaeeced7572379ad6b2519e52da31f674c
parentac42720f7d0309036c6af31372f28d13c7da5d80 (diff)
downloadobnam-cf5ce3a40e8610d5df33ea2e6a0722d670658075.tar.gz
Convert ls tests to better yarn
-rw-r--r--yarns/0040-generations.yarn25
-rw-r--r--yarns/9000-implements.yarn40
2 files changed, 64 insertions, 1 deletions
diff --git a/yarns/0040-generations.yarn b/yarns/0040-generations.yarn
index adc7d849..61de6ce4 100644
--- a/yarns/0040-generations.yarn
+++ b/yarns/0040-generations.yarn
@@ -50,7 +50,30 @@ commands should show that number of generations.
Listing contents of a generation (`obnam ls`)
--------------------------------
-FIXME.
+We'll assume the `obnam ls` command shows any generation.
+However, there's a couple of ways of using it: either listing
+everything, or only a specific directory to list.
+
+ SCENARIO list generation content
+ GIVEN 1MB of new data in directory D
+ WHEN user backs up directory D
+ AND user lists latest generation into all.txt
+ THEN all.txt matches /.*/D/.
+ WHEN user lists D in latest generation into some.txt
+ THEN all lines in some.txt match (/D|Generation)
+
+The first line of the generation listing contains the word
+"Generation". Every other line should contain the directory we
+requested as part of the pathname.
+
+There was a bug in Obnam 1.5 (and possibly other versions) that
+listing contents of a directory that ends in a slash (but isn't the
+root directory) fails. The following is a test for that bug by
+requesting `D/` to be listed, and verifying that we get at least one
+line for that.
+
+ WHEN user lists D/ in latest generation into bug.txt
+ THEN some.txt matches /D
Comparing generations (`obnam diff`)
------------------------------------
diff --git a/yarns/9000-implements.yarn b/yarns/9000-implements.yarn
index 41f99118..5d05b7dd 100644
--- a/yarns/9000-implements.yarn
+++ b/yarns/9000-implements.yarn
@@ -37,6 +37,11 @@ for single-client scenarios.
IMPLEMENTS GIVEN (\S+) of live data
genbackupdata --quiet --create "$MATCH_1" "$LIVEDATA"
+Generate requested amount of data in the named directory.
+
+ IMPLEMENTS GIVEN (\S+) of new data in directory (\S+)
+ genbackupdata --quiet --create "$MATCH_1" "$DATADIR/$MATCH_2"
+
We also need to generate a sparse file. A sparse file has at least one
hole in it, and it may matter where the hole is: at the beginning,
middle, or end of the file. Thus, we provide a way for scenarios to
@@ -92,6 +97,11 @@ addition to backing up, this makes a manifest of the data.
IMPLEMENTS WHEN user backs up live data
run_obnam backup -r "$REPO" "$LIVEDATA"
+Back up a named directory.
+
+ IMPLEMENTS WHEN user backs up directory (\S+)
+ run_obnam backup -r "$REPO" "$DATADIR/$MATCH_1"
+
fsck'ing a repository
---------------------
@@ -117,6 +127,19 @@ that is unpredictable.
id=$(run_obnam -r "$REPO" genids | awk -v "n=$MATCH_1" 'NR == n')
run_obnam restore -r "$REPO" --to "$DATADIR/$MATCH_2" --generation "$id"
+List generations
+----------------
+
+List everything in a generation. Capture the listing in a named file.
+
+ IMPLEMENTS WHEN user lists latest generation into (\S+)
+ run_obnam ls -r "$REPO" > "$DATADIR/$MATCH_1"
+
+List only parts of a generation. Again, capture in a named file.
+
+ IMPLEMENTS WHEN user lists (\S+) in latest generation into (\S+)
+ run_obnam ls -r "$REPO" "$DATADIR/$MATCH_1" > "$DATADIR/$MATCH_2"
+
Checks on generations
---------------------
@@ -145,6 +168,23 @@ original one in live data.
new=$(stat -c %b "$DATADIR/$MATCH_2/$LIVEDATA/$MATCH_1")
test "$old" -lt "$new"
+Checks on contents of files
+---------------------------
+
+Regular expressions are very powerful, and sometimes that power is
+warranted to use. It isn't always clear enough to the lay reader, so
+be careful. `grep -E` regular expressions are used here.
+
+Does any line match?
+
+ IMPLEMENTS THEN (\S+) matches (\S+)
+ grep -E -e "$MATCH_2" -- "$DATADIR/$MATCH_1"
+
+Do all lines match?
+
+ IMPLEMENTS THEN all lines in (\S+) match (\S+)
+ ! grep -E -v -e "$MATCH_2" -- "$DATADIR/$MATCH_1"
+
Check on user group membership
------------------------------