9 sub _determine_test_plan {
11 my $cvs=`which cvs`; chomp $cvs;
12 my $cvsps=`which cvsps`; chomp $cvsps;
13 return (skip_all => 'cvs or cvsps not available')
14 unless -x $cvs && -x $cvsps;
16 foreach my $module ('File::ReadBackwards', 'File::MimeInfo') {
19 return (skip_all => "$module not available");
28 _generate_minimal_config();
37 $dir="/tmp/ikiwiki-test-cvs.$$";
43 sub _generate_minimal_config {
44 %config=IkiWiki::defaultconfig();
46 $config{srcdir} = "$dir/src";
47 $config{cvsrepo} = "$dir/repo";
48 $config{cvspath} = "ikiwiki";
49 IkiWiki::loadplugins();
50 IkiWiki::checkconfig();
53 sub _create_test_repo {
54 my $cvsrepo = "$dir/repo";
56 system "cvs -d $cvsrepo init >/dev/null";
57 system "mkdir $dir/ikiwiki >/dev/null";
58 system "cd $dir/ikiwiki && cvs -d $cvsrepo import -m import ikiwiki VENDOR RELEASE >/dev/null";
59 system "rm -rf $dir/ikiwiki >/dev/null";
60 system "cvs -d $cvsrepo co -d $config{srcdir} ikiwiki >/dev/null";
64 my $test1 = readfile("t/test1.mdwn");
65 writefile('test1.mdwn', $config{srcdir}, $test1);
66 IkiWiki::rcs_add("test1.mdwn");
68 files => "test1.mdwn",
69 message => "Added the first page",
73 my @changes = IkiWiki::rcs_recentchanges(3);
76 is($changes[0]{message}[0]{"line"}, "Added the first page");
77 is($changes[0]{pages}[0]{"page"}, "test1");
80 sub test_manual_commit {
81 my $message = "Added the second page";
83 my $test2 = readfile("t/test2.mdwn");
84 writefile('test2.mdwn', $config{srcdir}, $test2);
85 system "cd $config{srcdir} && cvs add test2.mdwn >/dev/null 2>&1";
86 system "cd $config{srcdir} && cvs commit -m \"$message\" test2.mdwn >/dev/null";
88 my @changes = IkiWiki::rcs_recentchanges(3);
90 is($changes[0]{message}[0]{"line"}, $message);
91 is($changes[0]{pages}[0]{"page"}, "test2");
92 is($changes[1]{pages}[0]{"page"}, "test1");
94 # extra slashes in the path shouldn't break things
95 $config{cvspath} = "/ikiwiki//";
96 IkiWiki::checkconfig();
97 @changes = IkiWiki::rcs_recentchanges(3);
99 is($changes[0]{message}[0]{"line"}, $message);
100 is($changes[0]{pages}[0]{"page"}, "test2");
101 is($changes[1]{pages}[0]{"page"}, "test1");
104 plan(_determine_test_plan());
107 test_manual_commit();