]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/commitdiff
t: Consistently remove temp directory before testing, not after
authorSimon McVittie <smcv@debian.org>
Sun, 3 Feb 2019 12:25:20 +0000 (12:25 +0000)
committerSimon McVittie <smcv@debian.org>
Sun, 3 Feb 2019 12:34:46 +0000 (12:34 +0000)
When a test fails, it's useful to be able to inspect the output.

Signed-off-by: Simon McVittie <smcv@debian.org>
14 files changed:
.gitignore
Makefile.PL
t/basewiki_brokenlinks.t
t/conflicts.t
t/find_src_files.t
t/img.t
t/libdirs.t
t/map.t
t/meta.t
t/permalink.t
t/podcast.t
t/tag.t
t/trail.t
t/wrapper-environ.t

index a8d5ae77f63cafe05aec5b97266b561ae5242490..b3636c42bc3a125c712f2e0dccb85327e065d104 100644 (file)
@@ -27,3 +27,5 @@ underlays/locale
 /t/tmp/
 /t/manual/*/git/
 /t/manual/*/html/
+/t/tinyblog/.ikiwiki/
+/t/tinypodcast/.ikiwiki/
index f2080be2b49887e2dcfe363cdb255b541c3e6840..2df9ae1a68776f2a814a15b2231fb37d0242749c 100755 (executable)
@@ -87,6 +87,7 @@ sysconfdir:
 extra_clean: perl_shebangs_clean
        $(PERL) -Iblib/lib $(extramodules) $(tflag) ikiwiki.in --setup docwiki.setup --clean
        rm -f *.man $(outprogs) ikiwiki.setup plugins/*.pyc
+       rm -fr t/tmp t/manual/*/git/ t/manual/*/html/ t/tinyblog/.ikiwiki/ t/tinypodcast/.ikiwiki/
        $(MAKE) -C po clean
 
 reset-generated:
index f639d0dd88abef1477afb738ccc5df6419e165a5..6a86c4313d8ee0b3060f26e261701cafb356cd98 100755 (executable)
@@ -38,6 +38,5 @@ foreach my $plugin ("", "listdirectives") {
        ok(-e "t/tmp/out/style.css"); # linked to..
        ok(! system("rm -rf t/tmp/out t/basewiki_brokenlinks/.ikiwiki"));
 }
-ok(! system("rm -rf t/tmp"));
 
 done_testing();
index 2c2761efb9e129d68fcfe0547ec34b3e89ca896d..ef183c6b6854939a32818c3fd9f655d7211ed64f 100755 (executable)
@@ -3,7 +3,7 @@
 use warnings;
 use strict;
 use Cwd qw(getcwd);
-use Test::More tests => 106;
+use Test::More;
 
 my $installed = $ENV{INSTALLED_TESTS};
 
@@ -143,5 +143,4 @@ ok(! system("mkdir -p $srcdir/foo"));
 ok(! system("touch $srcdir/foo/index.html"));
 setupiki("rawhtml file rendered same as existing page in setup");
 
-# cleanup
-ok(! system("rm -rf t/tmp"));
+done_testing;
index a3742db75862b37360f5687b2b02dc0478a467de..9dbf6eafe2f8d7c4b4272c51be5c399e8a79d507 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 use warnings;
 use strict;
-use Test::More tests => 20;
+use Test::More;
 
 BEGIN { use_ok("IkiWiki"); }
 BEGIN { use_ok("IkiWiki::Render"); }
@@ -91,7 +91,4 @@ test_src_files(\@list, "deep dir symlink in srcdir skipped");
 system("ln -sf /etc/ $config{underlaydir}/ikiwiki/symdir");
 test_src_files(\@list, "deep dir symlink in underlaydir skipped");
 
-
-
-
-cleanup();
+done_testing;
diff --git a/t/img.t b/t/img.t
index 92cd61e138951e598f2e536da5c7b9c1ad39ceff..d5479b96dad9b7726b683aeb8fa5e02f5ccb23e7 100755 (executable)
--- a/t/img.t
+++ b/t/img.t
@@ -257,9 +257,6 @@ if (1) { # for easier testing
        ok(! -e "$outpath/x8-hello:world.png");
        ok(! -e "$outpath/x4-a:b:c.png");
        ok(! -e "$outpath/x6-a:b:c:d:e:f:g:h:i:j.png");
-
-       # cleanup
-       ok(! system("rm -rf t/tmp"));
 }
 done_testing;
 
index 906a541057def0bea3d90638df79c368961ac3e3..994ceb67d8230d582f2f4059fe56e2b37cd8abb2 100755 (executable)
@@ -6,6 +6,7 @@ use File::Path qw(make_path remove_tree);
 
 BEGIN { use_ok("IkiWiki"); }
 
+remove_tree("t/tmp");
 make_path("t/tmp/libdir");
 make_path("t/tmp/libdirs");
 make_path("t/tmp/libdirs/1");
@@ -36,7 +37,4 @@ ok(grep { m/^ext_plugin_in_libdir$/ } @plugins);
 ok(grep { m/^ext_plugin_in_libdir_1$/ } @plugins);
 ok(grep { m/^ext_plugin_in_libdir_2$/ } @plugins);
 
-remove_tree("t/tmp/libdir");
-remove_tree("t/tmp/libdirs");
-
 done_testing;
diff --git a/t/map.t b/t/map.t
index 5d4713d6fc9604d91018280c253911082d75c212..36210d808273a4182c66c9f89606b72e58eee59e 100755 (executable)
--- a/t/map.t
+++ b/t/map.t
@@ -236,7 +236,6 @@ check('alpha/1/i*',
                node('iv', []),
        ]);
 
-ok(! system("rm -rf t/tmp"));
 done_testing;
 
 1;
index 8602930bcfde2d3cf90bd7d603807288a2d0bc46..7f26a957ba4b7c9245d14cca427e3099301afa39 100755 (executable)
--- a/t/meta.t
+++ b/t/meta.t
@@ -28,11 +28,11 @@ push @command, $srcdir, $destdir;
 
 sub write_build_read_compare {
        my ($pagename, $input, $expected_output) = @_;
+       ok(! system("rm -rf $tmp"), q{setup});
        ok(! system("mkdir -p $srcdir"), q{setup});
        writefile("$pagename.mdwn", $srcdir, $input);
        ok(! system(@command), q{build});
        like(readfile("$destdir/$pagename/index.html"), $expected_output);
-       ok(! system("rm -rf $tmp"), q{teardown});
 }
 
 write_build_read_compare(
index 2eb557e1d649c2e5605b76e2285a9dfb2890635e..7b6b89bead2a91a5a1140fe50f1403f4e5becbac 100755 (executable)
@@ -18,7 +18,7 @@ else {
                --templatedir=templates));
 }
 
-ok(! system("rm -rf t/tmp"));
+ok(! system("rm -rf t/tmp t/tinyblog/.ikiwiki"));
 ok(! system("mkdir t/tmp"));
 ok(! system(@command, qw(--plugin inline --url=http://example.com
                --cgiurl=http://example.com/ikiwiki.cgi --rss --atom
@@ -27,6 +27,5 @@ ok(! system(@command, qw(--plugin inline --url=http://example.com
 my $guid="http://example.com/post/";
 ok(length `egrep '<guid.*>$guid</guid>' t/tmp/out/index.rss`);
 ok(length `egrep '<id>$guid</id>' t/tmp/out/index.atom`);
-ok(! system("rm -rf t/tmp t/tinyblog/.ikiwiki"));
 
 done_testing();
index 708ac7640322f58fbb02d2cca622e6e115325724..7b0987e21321f2e7738b71903a8381da3361a0b1 100755 (executable)
@@ -9,7 +9,7 @@ BEGIN {
                        "XML::Feed and/or HTML::Parser or File::MimeInfo not available"};
        }
        else {
-               eval q{use Test::More tests => 137};
+               eval q{use Test::More};
        }
 }
 
@@ -41,6 +41,8 @@ sub podcast {
        my @command = (@base_command, qw(--plugin inline --rss --atom));
        push @command, "--url=$baseurl", qw(t/tinypodcast), "$tmp/out";
 
+       ok(! system("rm -rf $tmp $statedir"), q{setup});
+
        ok(! system("mkdir $tmp"),
                q{setup});
        ok(! system(@command),
@@ -121,14 +123,14 @@ sub podcast {
                        }
                }
        }
-
-       ok(! system("rm -rf $tmp $statedir"), q{teardown});
 }
 
 sub single_page_html {
        my @command = @base_command;
        push @command, qw(t/tinypodcast), "$tmp/out";
 
+       ok(! system("rm -rf $tmp $statedir"), q{setup});
+
        ok(! system("mkdir $tmp"),
                q{setup});
        ok(! system(@command),
@@ -172,6 +174,8 @@ sub inlined_pages_html {
        my @command = (@base_command, qw(--plugin inline));
        push @command, qw(t/tinypodcast), "$tmp/out";
 
+       ok(! system("rm -rf $tmp $statedir"), q{setup});
+
        ok(! system("mkdir $tmp"),
                q{setup});
        ok(! system(@command),
@@ -240,3 +244,5 @@ podcast('simple');
 single_page_html();
 inlined_pages_html();
 podcast('fancy');
+
+done_testing;
diff --git a/t/tag.t b/t/tag.t
index cc0a30cadf481c6d0d9be8ad431e67d05f84790e..5bee61f529d7abdc4522ed3e7cd77e4def8af9a3 100755 (executable)
--- a/t/tag.t
+++ b/t/tag.t
@@ -3,7 +3,7 @@ package IkiWiki;
 
 use warnings;
 use strict;
-use Test::More tests => 24;
+use Test::More;
 
 BEGIN { use_ok("IkiWiki"); }
 BEGIN { use_ok("IkiWiki::Render"); }
@@ -81,8 +81,4 @@ IkiWiki::gen_autofile("tags/primes.mdwn", \%pages, \@del);
 is_deeply(\%pages, {});
 is_deeply(\@del, ['tags/primes.mdwn']);
 
-
-# cleanup
-ok(! system("rm -rf t/tmp"));
-
-1;
+done_testing;
index ed180d35cd9820537afead9df25c00696a5cc83f..a49a9e3bc529cbc32cf8437b2997d96fb6c81c7b 100755 (executable)
--- a/t/trail.t
+++ b/t/trail.t
@@ -303,6 +303,4 @@ ok($blob =~ /\^ the new title \^/m);
 check_no_trail("untrail/a.html");
 check_no_trail("untrail/b.html");
 
-ok(! system("rm -rf t/tmp"));
-
 done_testing();
index d6d34b9d95156de34364c9e6e2a75960d8659809..6254816faa79dfe578062c65036e5bef43584476 100755 (executable)
@@ -29,6 +29,8 @@ else {
                --templatedir=templates));
 }
 
+ok(! system("rm -rf t/tmp"));
+
 writefile("test.setup", "t/tmp", <<EOF
 # IkiWiki::Setup::Yaml - YAML formatted setup file
 wikiname: this is the name of my wiki