7 my %ideal_test_plan = (tests => 8);
10 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");
23 return %ideal_test_plan;
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";
63 sub test_web_add_and_commit {
64 writefile('test1.mdwn', $config{srcdir}, readfile("t/test1.mdwn"));
65 IkiWiki::rcs_add("test1.mdwn");
66 my $message = "Added the first page";
73 my @changes = IkiWiki::rcs_recentchanges(3);
80 $changes[0]{message}[0]{"line"},
82 q{first line of most recent commit message matches},
85 $changes[0]{pages}[0]{"page"},
87 q{first pagename from most recent commit matches},
91 sub test_manual_add_and_commit {
92 writefile('test2.mdwn', $config{srcdir}, readfile("t/test2.mdwn"));
93 system "cd $config{srcdir} && cvs add test2.mdwn >/dev/null 2>&1";
94 my $message = "Added the second page";
95 system "cd $config{srcdir} && cvs commit -m \"$message\" test2.mdwn >/dev/null";
97 my @changes = IkiWiki::rcs_recentchanges(3);
104 $changes[0]{message}[0]{"line"},
106 q{first line of most recent commit message matches},
109 $changes[0]{pages}[0]{"page"},
111 q{first pagename from most recent commit matches},
114 $changes[1]{pages}[0]{"page"},
116 q{first pagename from second-most-recent commit matches},
120 sub test_extra_path_slashes {
121 my $initial_cvspath = $config{cvspath};
122 $config{cvspath} = "/ikiwiki//";
123 IkiWiki::checkconfig();
127 q{rcs_recentchanges assumes checkconfig sanitizes cvspath},
131 plan(_determine_test_plan());
133 test_web_add_and_commit();
134 test_manual_add_and_commit();
135 test_extra_path_slashes();