9 sub _determine_test_plan {
10 my $cvs=`which cvs`; chomp $cvs;
11 my $cvsps=`which cvsps`; chomp $cvsps;
12 return (skip_all => 'cvs or cvsps not available')
13 unless -x $cvs && -x $cvsps;
15 foreach my $module ('File::ReadBackwards', 'File::MimeInfo') {
18 return (skip_all => "$module not available");
27 _generate_minimal_config();
36 $dir="/tmp/ikiwiki-test-cvs.$$";
42 sub _generate_minimal_config {
43 %config=IkiWiki::defaultconfig();
45 $config{srcdir} = "$dir/src";
46 $config{cvsrepo} = "$dir/repo";
47 $config{cvspath} = "ikiwiki";
48 IkiWiki::loadplugins();
49 IkiWiki::checkconfig();
52 sub _create_test_repo {
53 my $cvsrepo = "$dir/repo";
55 system "cvs -d $cvsrepo init >/dev/null";
56 system "mkdir $dir/ikiwiki >/dev/null";
57 system "cd $dir/ikiwiki && cvs -d $cvsrepo import -m import ikiwiki VENDOR RELEASE >/dev/null";
58 system "rm -rf $dir/ikiwiki >/dev/null";
59 system "cvs -d $cvsrepo co -d $config{srcdir} ikiwiki >/dev/null";
63 my $test1 = readfile("t/test1.mdwn");
64 writefile('test1.mdwn', $config{srcdir}, $test1);
65 IkiWiki::rcs_add("test1.mdwn");
68 message => "Added the first page",
72 my @changes = IkiWiki::rcs_recentchanges(3);
75 is($changes[0]{message}[0]{"line"}, "Added the first page");
76 is($changes[0]{pages}[0]{"page"}, "test1");
79 sub test_manual_commit {
80 my $message = "Added the second page";
82 my $test2 = readfile("t/test2.mdwn");
83 writefile('test2.mdwn', $config{srcdir}, $test2);
84 system "cd $config{srcdir} && cvs add test2.mdwn >/dev/null 2>&1";
85 system "cd $config{srcdir} && cvs commit -m \"$message\" test2.mdwn >/dev/null";
87 my @changes = IkiWiki::rcs_recentchanges(3);
89 is($changes[0]{message}[0]{"line"}, $message);
90 is($changes[0]{pages}[0]{"page"}, "test2");
91 is($changes[1]{pages}[0]{"page"}, "test1");
93 # extra slashes in the path shouldn't break things
94 $config{cvspath} = "/ikiwiki//";
95 IkiWiki::checkconfig();
96 @changes = IkiWiki::rcs_recentchanges(3);
98 is($changes[0]{message}[0]{"line"}, $message);
99 is($changes[0]{pages}[0]{"page"}, "test2");
100 is($changes[1]{pages}[0]{"page"}, "test1");
103 plan(_determine_test_plan());
106 test_manual_commit();