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 <smcv@debian.org>
master
Simon McVittie 2019-02-03 12:25:20 +00:00
parent 3fe5d0acbf
commit 2bde54c9dc
14 changed files with 23 additions and 30 deletions

2
.gitignore vendored
View File

@ -27,3 +27,5 @@ underlays/locale
/t/tmp/ /t/tmp/
/t/manual/*/git/ /t/manual/*/git/
/t/manual/*/html/ /t/manual/*/html/
/t/tinyblog/.ikiwiki/
/t/tinypodcast/.ikiwiki/

View File

@ -87,6 +87,7 @@ sysconfdir:
extra_clean: perl_shebangs_clean extra_clean: perl_shebangs_clean
$(PERL) -Iblib/lib $(extramodules) $(tflag) ikiwiki.in --setup docwiki.setup --clean $(PERL) -Iblib/lib $(extramodules) $(tflag) ikiwiki.in --setup docwiki.setup --clean
rm -f *.man $(outprogs) ikiwiki.setup plugins/*.pyc 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 $(MAKE) -C po clean
reset-generated: reset-generated:

View File

@ -38,6 +38,5 @@ foreach my $plugin ("", "listdirectives") {
ok(-e "t/tmp/out/style.css"); # linked to.. 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/out t/basewiki_brokenlinks/.ikiwiki"));
} }
ok(! system("rm -rf t/tmp"));
done_testing(); done_testing();

View File

@ -3,7 +3,7 @@
use warnings; use warnings;
use strict; use strict;
use Cwd qw(getcwd); use Cwd qw(getcwd);
use Test::More tests => 106; use Test::More;
my $installed = $ENV{INSTALLED_TESTS}; my $installed = $ENV{INSTALLED_TESTS};
@ -143,5 +143,4 @@ ok(! system("mkdir -p $srcdir/foo"));
ok(! system("touch $srcdir/foo/index.html")); ok(! system("touch $srcdir/foo/index.html"));
setupiki("rawhtml file rendered same as existing page in setup"); setupiki("rawhtml file rendered same as existing page in setup");
# cleanup done_testing;
ok(! system("rm -rf t/tmp"));

View File

@ -1,7 +1,7 @@
#!/usr/bin/perl #!/usr/bin/perl
use warnings; use warnings;
use strict; use strict;
use Test::More tests => 20; use Test::More;
BEGIN { use_ok("IkiWiki"); } BEGIN { use_ok("IkiWiki"); }
BEGIN { use_ok("IkiWiki::Render"); } 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"); system("ln -sf /etc/ $config{underlaydir}/ikiwiki/symdir");
test_src_files(\@list, "deep dir symlink in underlaydir skipped"); test_src_files(\@list, "deep dir symlink in underlaydir skipped");
done_testing;
cleanup();

View File

@ -257,9 +257,6 @@ if (1) { # for easier testing
ok(! -e "$outpath/x8-hello:world.png"); ok(! -e "$outpath/x8-hello:world.png");
ok(! -e "$outpath/x4-a:b:c.png"); ok(! -e "$outpath/x4-a:b:c.png");
ok(! -e "$outpath/x6-a:b:c:d:e:f:g:h:i:j.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; done_testing;

View File

@ -6,6 +6,7 @@ use File::Path qw(make_path remove_tree);
BEGIN { use_ok("IkiWiki"); } BEGIN { use_ok("IkiWiki"); }
remove_tree("t/tmp");
make_path("t/tmp/libdir"); make_path("t/tmp/libdir");
make_path("t/tmp/libdirs"); make_path("t/tmp/libdirs");
make_path("t/tmp/libdirs/1"); 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_1$/ } @plugins);
ok(grep { m/^ext_plugin_in_libdir_2$/ } @plugins); ok(grep { m/^ext_plugin_in_libdir_2$/ } @plugins);
remove_tree("t/tmp/libdir");
remove_tree("t/tmp/libdirs");
done_testing; done_testing;

View File

@ -236,7 +236,6 @@ check('alpha/1/i*',
node('iv', []), node('iv', []),
]); ]);
ok(! system("rm -rf t/tmp"));
done_testing; done_testing;
1; 1;

View File

@ -28,11 +28,11 @@ push @command, $srcdir, $destdir;
sub write_build_read_compare { sub write_build_read_compare {
my ($pagename, $input, $expected_output) = @_; my ($pagename, $input, $expected_output) = @_;
ok(! system("rm -rf $tmp"), q{setup});
ok(! system("mkdir -p $srcdir"), q{setup}); ok(! system("mkdir -p $srcdir"), q{setup});
writefile("$pagename.mdwn", $srcdir, $input); writefile("$pagename.mdwn", $srcdir, $input);
ok(! system(@command), q{build}); ok(! system(@command), q{build});
like(readfile("$destdir/$pagename/index.html"), $expected_output); like(readfile("$destdir/$pagename/index.html"), $expected_output);
ok(! system("rm -rf $tmp"), q{teardown});
} }
write_build_read_compare( write_build_read_compare(

View File

@ -18,7 +18,7 @@ else {
--templatedir=templates)); --templatedir=templates));
} }
ok(! system("rm -rf t/tmp")); ok(! system("rm -rf t/tmp t/tinyblog/.ikiwiki"));
ok(! system("mkdir t/tmp")); ok(! system("mkdir t/tmp"));
ok(! system(@command, qw(--plugin inline --url=http://example.com ok(! system(@command, qw(--plugin inline --url=http://example.com
--cgiurl=http://example.com/ikiwiki.cgi --rss --atom --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/"; my $guid="http://example.com/post/";
ok(length `egrep '<guid.*>$guid</guid>' t/tmp/out/index.rss`); ok(length `egrep '<guid.*>$guid</guid>' t/tmp/out/index.rss`);
ok(length `egrep '<id>$guid</id>' t/tmp/out/index.atom`); ok(length `egrep '<id>$guid</id>' t/tmp/out/index.atom`);
ok(! system("rm -rf t/tmp t/tinyblog/.ikiwiki"));
done_testing(); done_testing();

View File

@ -9,7 +9,7 @@ BEGIN {
"XML::Feed and/or HTML::Parser or File::MimeInfo not available"}; "XML::Feed and/or HTML::Parser or File::MimeInfo not available"};
} }
else { 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)); my @command = (@base_command, qw(--plugin inline --rss --atom));
push @command, "--url=$baseurl", qw(t/tinypodcast), "$tmp/out"; push @command, "--url=$baseurl", qw(t/tinypodcast), "$tmp/out";
ok(! system("rm -rf $tmp $statedir"), q{setup});
ok(! system("mkdir $tmp"), ok(! system("mkdir $tmp"),
q{setup}); q{setup});
ok(! system(@command), ok(! system(@command),
@ -121,14 +123,14 @@ sub podcast {
} }
} }
} }
ok(! system("rm -rf $tmp $statedir"), q{teardown});
} }
sub single_page_html { sub single_page_html {
my @command = @base_command; my @command = @base_command;
push @command, qw(t/tinypodcast), "$tmp/out"; push @command, qw(t/tinypodcast), "$tmp/out";
ok(! system("rm -rf $tmp $statedir"), q{setup});
ok(! system("mkdir $tmp"), ok(! system("mkdir $tmp"),
q{setup}); q{setup});
ok(! system(@command), ok(! system(@command),
@ -172,6 +174,8 @@ sub inlined_pages_html {
my @command = (@base_command, qw(--plugin inline)); my @command = (@base_command, qw(--plugin inline));
push @command, qw(t/tinypodcast), "$tmp/out"; push @command, qw(t/tinypodcast), "$tmp/out";
ok(! system("rm -rf $tmp $statedir"), q{setup});
ok(! system("mkdir $tmp"), ok(! system("mkdir $tmp"),
q{setup}); q{setup});
ok(! system(@command), ok(! system(@command),
@ -240,3 +244,5 @@ podcast('simple');
single_page_html(); single_page_html();
inlined_pages_html(); inlined_pages_html();
podcast('fancy'); podcast('fancy');
done_testing;

View File

@ -3,7 +3,7 @@ package IkiWiki;
use warnings; use warnings;
use strict; use strict;
use Test::More tests => 24; use Test::More;
BEGIN { use_ok("IkiWiki"); } BEGIN { use_ok("IkiWiki"); }
BEGIN { use_ok("IkiWiki::Render"); } BEGIN { use_ok("IkiWiki::Render"); }
@ -81,8 +81,4 @@ IkiWiki::gen_autofile("tags/primes.mdwn", \%pages, \@del);
is_deeply(\%pages, {}); is_deeply(\%pages, {});
is_deeply(\@del, ['tags/primes.mdwn']); is_deeply(\@del, ['tags/primes.mdwn']);
done_testing;
# cleanup
ok(! system("rm -rf t/tmp"));
1;

View File

@ -303,6 +303,4 @@ ok($blob =~ /\^ the new title \^/m);
check_no_trail("untrail/a.html"); check_no_trail("untrail/a.html");
check_no_trail("untrail/b.html"); check_no_trail("untrail/b.html");
ok(! system("rm -rf t/tmp"));
done_testing(); done_testing();

View File

@ -29,6 +29,8 @@ else {
--templatedir=templates)); --templatedir=templates));
} }
ok(! system("rm -rf t/tmp"));
writefile("test.setup", "t/tmp", <<EOF writefile("test.setup", "t/tmp", <<EOF
# IkiWiki::Setup::Yaml - YAML formatted setup file # IkiWiki::Setup::Yaml - YAML formatted setup file
wikiname: this is the name of my wiki wikiname: this is the name of my wiki