aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2012-04-07 17:52:29 +0100
committerSimon McVittie <smcv@debian.org>2012-04-07 17:52:29 +0100
commit5674e7fc1273800554c23ad6194e8a06dee851ae (patch)
treec5ae178e0a15350dc44507c5612bd58dae98e2f4 /t
parentf5f41fa59af064ce3d5e038154950aefdc8d6f65 (diff)
downloadikiwiki-5674e7fc1273800554c23ad6194e8a06dee851ae.tar
ikiwiki-5674e7fc1273800554c23ad6194e8a06dee851ae.tar.gz
prune: do not prune beyond an optional base directory, and add a test
Previously, prune("wiki/srcdir/sandbox/test.mdwn") could delete srcdir or even wiki, if they happened to be empty. This is rarely what you want: there's usually some base directory (destdir, srcdir, transientdir or another subdirectory of wikistatedir) beyond which you do not want to delete.
Diffstat (limited to 't')
-rwxr-xr-xt/prune.t23
1 files changed, 23 insertions, 0 deletions
diff --git a/t/prune.t b/t/prune.t
new file mode 100755
index 000000000..8c3925e9e
--- /dev/null
+++ b/t/prune.t
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use Test::More tests => 6;
+use File::Path qw(make_path remove_tree);
+
+BEGIN { use_ok("IkiWiki"); }
+BEGIN { use_ok("IkiWiki::Render"); }
+
+%config=IkiWiki::defaultconfig();
+
+remove_tree("t/tmp");
+
+make_path("t/tmp/srcdir/a/b/c");
+make_path("t/tmp/srcdir/d/e/f");
+writefile("a/b/c/d.mdwn", "t/tmp/srcdir", "foo");
+writefile("d/e/f/g.mdwn", "t/tmp/srcdir", "foo");
+IkiWiki::prune("t/tmp/srcdir/d/e/f/g.mdwn");
+ok(-d "t/tmp/srcdir");
+ok(! -e "t/tmp/srcdir/d");
+IkiWiki::prune("t/tmp/srcdir/a/b/c/d.mdwn", "t/tmp/srcdir");
+ok(-d "t/tmp/srcdir");
+ok(! -e "t/tmp/srcdir/a");