Fix a typo in the web commit test.
[ikiwiki.git] / t / cvs.t
diff --git a/t/cvs.t b/t/cvs.t
index 2937ac2ed76ede48672ca1cbbb251119e8a9df5b..c4e9eb2765c66a0d0ce723841f0116581b15ea09 100755 (executable)
--- a/t/cvs.t
+++ b/t/cvs.t
@@ -1,35 +1,29 @@
 #!/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 +32,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";
@@ -63,9 +64,9 @@ sub test_web_commit {
        writefile('test1.mdwn', $config{srcdir}, $test1);
        IkiWiki::rcs_add("test1.mdwn");
        IkiWiki::rcs_commit(
-               files => "test1.mdwn",
+               file => "test1.mdwn",
                message => "Added the first page",
-               token => "moo"
+               token => "moo",
        );
 
        my @changes = IkiWiki::rcs_recentchanges(3);
@@ -99,6 +100,7 @@ sub test_manual_commit {
        is($changes[1]{pages}[0]{"page"}, "test1");
 }
 
+plan(_determine_test_plan());
 _startup();
 test_web_commit();
 test_manual_commit();