summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2013-10-21 19:25:30 +0100
committerLars Wirzenius <liw@liw.fi>2013-10-21 19:25:30 +0100
commit45dd7c6089f7b09d1f8a85ee35f8cc179393cd54 (patch)
treec59f9709df033acbef7880cd8988e700b778f781
parent052238fe969c41927292e89a81832c6ef5c62ee9 (diff)
downloadobnam-45dd7c6089f7b09d1f8a85ee35f8cc179393cd54.tar.gz
Add some yarn tests for "obnam ls"
-rw-r--r--yarns/ls.yarn106
-rw-r--r--yarns/obnam.sh2
2 files changed, 107 insertions, 1 deletions
diff --git a/yarns/ls.yarn b/yarns/ls.yarn
new file mode 100644
index 00000000..c40ff2d1
--- /dev/null
+++ b/yarns/ls.yarn
@@ -0,0 +1,106 @@
+`obnam ls`
+==========
+
+`obnam ls` lists contents of repositories. To test this, we start
+by backing up some live data to a repository, and then we query it
+in various ways.
+
+ SCENARIO obnam ls
+ GIVEN a live data directory xyzzy
+ AND a file xyzzy/foo.txt containing "foo"
+ AND a directory xyzzy/bar
+ AND a file xyzzy/bar/yo containing "yo"
+ AND an obnam config called xyzzy.conf
+ AND config xyzzy.conf sets repository to xyzzy.repo
+ AND config xyzzy.conf sets root to xyzzy
+ WHEN "obnam backup" using xyzzy.conf is run
+ THEN plain "obnam ls" using xyzzy.conf contains "bar/yo$"
+ AND "obnam ls" using xyzzy.conf when given xyzzy contains "bar/yo$"
+
+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.
+
+ AND "obnam ls" using xyzzy.conf when given xyzzy/ contains "bar/yo$"
+
+That's it.
+
+Implementations
+===============
+
+Introduction
+------------
+
+We run Obnam in `$DATADIR` so that any paths to test data, etc,
+may be relative to `$DATADIR`. The `run_obnam` shell function in
+`obnam.sh` allows us to do that safely.
+
+Live data creation
+------------------
+
+There's several steps to creating live data. First is to create
+directory for the live data. We let the user choose the name, in case
+they need to have more than one live data (perhaps for simulating
+multiple clients).
+
+ IMPLEMENTS GIVEN a live data directory (\S+)
+ mkdir "$DATADIR/$MATCH_1"
+
+Create a file. This is meant for live data creation, but it can
+actually create any file. The contents printed using `printf`(1), so
+that escapes may be used.
+
+ IMPLEMENTS GIVEN a file (\S+) containing "(.*)"
+ printf "$MATCH_1" > "$DATADIR/$MATCH_1"
+
+Likewise, a directory may be created.
+
+ IMPLEMENTS GIVEN a directory (\S+)
+ mkdir "$DATADIR/$MATCH_1"
+
+Obnam configuration file creation
+---------------------------------
+
+Various tests need to set up configuration files with specific
+settings.
+
+ IMPLEMENTS GIVEN an obnam config called (\S+)
+ printf '[config]\n' > "$DATADIR/$MATCH_1"
+
+ IMPLEMENTS GIVEN config (\S+) sets (\S+) to (\S+)
+ printf '%s = %s\n' "$MATCH_2" "$MATCH_3" >> "$DATADIR/$MATCH_1"
+
+Backing up with Obnam
+---------------------
+
+We need to backup with Obnam.
+
+ IMPLEMENTS WHEN "obnam backup" using (\S+) is run
+ cd "$DATADIR"
+ run_obnam --config "$DATADIR/$MATCH_1" backup
+
+Checking `obnam ls` results
+---------------------------
+
+`obnam ls` produces output that mimicks (but doesn't exactly match)
+that of `ls -lAR` using GNU coreutils and other popular
+implementations of the Unix `ls`(1) command. This makes exact output
+matching a bit tricky to do. Instead, we check whether specific files
+are in the output.
+
+ IMPLEMENTS THEN plain "obnam ls" using (\S+) contains "(.+)"
+ cd "$DATADIR"
+ run_obnam --config "$DATADIR/$MATCH_1" ls | grep "$MATCH_2"
+
+This is similar to a plain `obnam ls`, but we give it an argument, to
+restrict what gets listed. If the argument is not an absolute path, we
+make it one, since Obnam expects it to be. It is, unfortunately,
+difficult to let the user of this IMPLEMENTS specify an absolute path.
+
+ IMPLEMENTS THEN "obnam ls" using (\S+) when given (\S+) contains "(.+)"
+ cd "$DATADIR"
+ case "$MATCH_2" in
+ /*) path="$MATCH_2" ;;
+ *) path="$(pwd)/$MATCH_2" ;;
+ esac
+ run_obnam --config "$DATADIR/$MATCH_1" ls "$path" | grep "$MATCH_3"
diff --git a/yarns/obnam.sh b/yarns/obnam.sh
index 9de72ba7..eafc8b8d 100644
--- a/yarns/obnam.sh
+++ b/yarns/obnam.sh
@@ -21,7 +21,7 @@
run_obnam()
{
- ./obnam --no-default-config "$@"
+ "$SRCDIR/obnam" --no-default-config "$@"
}