aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorAmitai Schlair <schmonz-web-ikiwiki@schmonz.com>2012-01-21 15:00:52 -0500
committerAmitai Schlair <schmonz-web-ikiwiki@schmonz.com>2012-01-22 10:44:49 -0500
commitf18160b95d1f9120a5cb656aca84892f811f1972 (patch)
tree8ab0f71e1d8a894258b9d4d637a2fbda32094dde /t
parentf98c4c5b727796721ac9b38dc07af2911a13be22 (diff)
downloadikiwiki-f18160b95d1f9120a5cb656aca84892f811f1972.tar
ikiwiki-f18160b95d1f9120a5cb656aca84892f811f1972.tar.gz
Simplify startup: use Test::More unconditionally, then determine
the test plan at runtime. Use IkiWiki unconditionally too (as that's not what I'm testing here) to avoid the TAP error of printing a test result before having printed the plan.
Diffstat (limited to 't')
-rwxr-xr-xt/cvs.t43
1 files changed, 23 insertions, 20 deletions
diff --git a/t/cvs.t b/t/cvs.t
index 2937ac2ed..fdd26dbc8 100755
--- a/t/cvs.t
+++ b/t/cvs.t
@@ -1,35 +1,30 @@
#!/usr/bin/perl
use warnings;
use strict;
+use Test::More;
+use IkiWiki;
+
my $dir;
-BEGIN {
- $dir="/tmp/ikiwiki-test-cvs.$$";
- my $cvs=`which cvs`;
- chomp $cvs;
- my $cvsps=`which cvsps`;
- chomp $cvsps;
- if (! -x $cvs || ! -x $cvsps) {
- eval q{
- use Test::More skip_all => "cvs or cvsps not available"
- }
- }
- if (! mkdir($dir)) {
- die $@;
- }
+
+sub _determine_test_plan {
+
+ my $cvs=`which cvs`; chomp $cvs;
+ my $cvsps=`which cvsps`; chomp $cvsps;
+ return (skip_all => 'cvs or cvsps not available')
+ unless -x $cvs && -x $cvsps;
+
foreach my $module ('File::ReadBackwards', 'File::MimeInfo') {
eval qq{use $module};
if ($@) {
- eval qq{
- use Test::More skip_all => "$module not available"
- }
+ return (skip_all => "$module not available");
}
}
-}
-use Test::More tests => 12;
-BEGIN { use_ok("IkiWiki"); }
+ return (tests => 11);
+}
sub _startup {
+ _mktempdir();
_generate_minimal_config();
_create_test_repo();
}
@@ -38,6 +33,13 @@ sub _shutdown {
system "rm -rf $dir";
}
+sub _mktempdir {
+ $dir="/tmp/ikiwiki-test-cvs.$$";
+ if (! mkdir($dir)) {
+ die $@;
+ }
+}
+
sub _generate_minimal_config {
%config=IkiWiki::defaultconfig();
$config{rcs} = "cvs";
@@ -99,6 +101,7 @@ sub test_manual_commit {
is($changes[1]{pages}[0]{"page"}, "test1");
}
+plan(_determine_test_plan());
_startup();
test_web_commit();
test_manual_commit();