From 2bde54c9dc0e1776882f4e0fef5750296e848c5b Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 3 Feb 2019 12:25:20 +0000 Subject: t: Consistently remove temp directory before testing, not after When a test fails, it's useful to be able to inspect the output. Signed-off-by: Simon McVittie --- t/basewiki_brokenlinks.t | 1 - t/conflicts.t | 5 ++--- t/find_src_files.t | 7 ++----- t/img.t | 3 --- t/libdirs.t | 4 +--- t/map.t | 1 - t/meta.t | 2 +- t/permalink.t | 3 +-- t/podcast.t | 12 +++++++++--- t/tag.t | 8 ++------ t/trail.t | 2 -- t/wrapper-environ.t | 2 ++ 12 files changed, 20 insertions(+), 30 deletions(-) (limited to 't') diff --git a/t/basewiki_brokenlinks.t b/t/basewiki_brokenlinks.t index f639d0dd8..6a86c4313 100755 --- a/t/basewiki_brokenlinks.t +++ b/t/basewiki_brokenlinks.t @@ -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(); diff --git a/t/conflicts.t b/t/conflicts.t index 2c2761efb..ef183c6b6 100755 --- a/t/conflicts.t +++ b/t/conflicts.t @@ -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; diff --git a/t/find_src_files.t b/t/find_src_files.t index a3742db75..9dbf6eafe 100755 --- a/t/find_src_files.t +++ b/t/find_src_files.t @@ -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 92cd61e13..d5479b96d 100755 --- 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; diff --git a/t/libdirs.t b/t/libdirs.t index 906a54105..994ceb67d 100755 --- a/t/libdirs.t +++ b/t/libdirs.t @@ -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 5d4713d6f..36210d808 100755 --- 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; diff --git a/t/meta.t b/t/meta.t index 8602930bc..7f26a957b 100755 --- 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( diff --git a/t/permalink.t b/t/permalink.t index 2eb557e1d..7b6b89bea 100755 --- a/t/permalink.t +++ b/t/permalink.t @@ -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' t/tmp/out/index.rss`); ok(length `egrep '$guid' t/tmp/out/index.atom`); -ok(! system("rm -rf t/tmp t/tinyblog/.ikiwiki")); done_testing(); diff --git a/t/podcast.t b/t/podcast.t index 708ac7640..7b0987e21 100755 --- a/t/podcast.t +++ b/t/podcast.t @@ -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 cc0a30cad..5bee61f52 100755 --- 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; diff --git a/t/trail.t b/t/trail.t index ed180d35c..a49a9e3bc 100755 --- 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(); diff --git a/t/wrapper-environ.t b/t/wrapper-environ.t index d6d34b9d9..6254816fa 100755 --- a/t/wrapper-environ.t +++ b/t/wrapper-environ.t @@ -29,6 +29,8 @@ else { --templatedir=templates)); } +ok(! system("rm -rf t/tmp")); + writefile("test.setup", "t/tmp", <