summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--obnamlib/plugins/show_plugin.py3
-rw-r--r--yarns/0300-kdirstat-integration.yarn25
-rw-r--r--yarns/9000-implements.yarn22
3 files changed, 48 insertions, 2 deletions
diff --git a/obnamlib/plugins/show_plugin.py b/obnamlib/plugins/show_plugin.py
index 9114f309..5e28fed2 100644
--- a/obnamlib/plugins/show_plugin.py
+++ b/obnamlib/plugins/show_plugin.py
@@ -264,8 +264,7 @@ class ShowPlugin(obnamlib.ObnamPlugin):
self.traverse(self.show_hdr_kdirstat, self.show_item_kdirstat, args)
def show_hdr_kdirstat(self, comment):
- self.app.output.write('''
-[kdirstat 4.0 cache file]
+ self.app.output.write('''[kdirstat 4.0 cache file]
# Generated by obnam %s
# Do not edit!
#
diff --git a/yarns/0300-kdirstat-integration.yarn b/yarns/0300-kdirstat-integration.yarn
new file mode 100644
index 00000000..a2ff8e69
--- /dev/null
+++ b/yarns/0300-kdirstat-integration.yarn
@@ -0,0 +1,25 @@
+kdirstat integration: producing kdirstat cache files
+====================================================
+
+Obnam implements an ls variant whose output format is compatible with
+the kdirstat cache format.
+
+Create a simple cache file
+--------------------------
+
+Here we create a simple backup and dump the output as a kdirstat cache
+file.
+
+ SCENARIO create and do a simple check of a kdirstat cache
+ GIVEN 10kB of new data in directory L
+ WHEN user U backs up directory L to repository R
+ AND user U creates a kdirstat cache file C of repository R
+ THEN first line of C matches [kdirstat 4.0 cache file]
+ AND for each file in directory L a line in the kdircache C matches it
+
+Validating the cache file
+-------------------------
+
+Sadly there seems to be no CLI usable program to read or validate the
+produced cache files. If there were we would do a more thorough test
+of the syntax here.
diff --git a/yarns/9000-implements.yarn b/yarns/9000-implements.yarn
index 1a86fbe7..de26a8b3 100644
--- a/yarns/9000-implements.yarn
+++ b/yarns/9000-implements.yarn
@@ -573,6 +573,11 @@ Does any line match?
IMPLEMENTS THEN (\S+) matches (.*)$
grep -E -e "$MATCH_2" -- "$DATADIR/$MATCH_1"
+Does first line match?
+
+ IMPLEMENTS THEN first line of (\S+) matches (.*)$
+ head -n1 "$DATADIR/$MATCH_1" | grep -E -e "$MATCH_2" --
+
Do all lines match?
IMPLEMENTS THEN all lines in (\S+) match (\S+)
@@ -628,3 +633,20 @@ Run the Nagios monitoring subcommand.
IMPLEMENTS WHEN user (\S+) attempts nagios-last-backup-age against repository (\S+)
attempt run_obnam "$MATCH_1" nagios-last-backup-age \
-r "$DATADIR/$MATCH_2"
+
+kdirstat
+--------
+
+Create a kdirstat cache.
+
+ IMPLEMENTS WHEN user (\S+) creates a kdirstat cache file (\S+) of repository (\S+)
+ run_obnam "$MATCH_1" -r "$DATADIR/$MATCH_3" kdirstat > "$DATADIR/$MATCH_2"
+
+Check that the cache mentions each file in the repository. Since grep
+-E cannot specifically match a tab we check only for one character of
+whitespace.
+
+ IMPLEMENTS THEN for each file in directory (\S+) a line in the kdircache (\S+) matches it
+ find "$DATADIR/$MATCH_1" -type f | while read f ; do \
+ grep -E -e "^F[[:space:]]$f" "$DATADIR/$MATCH_2" || exit 1; \
+ done