6 $dir="/tmp/ikiwiki-test-cvs.$$";
9 my $cvsps=`which cvsps`;
11 if (! -x $cvs || ! -x $cvsps) {
13 use Test::More skip_all => "cvs or cvsps not available"
19 foreach my $module ('File::ReadBackwards', 'File::MimeInfo') {
23 use Test::More skip_all => "$module not available"
28 use Test::More tests => 12;
30 BEGIN { use_ok("IkiWiki"); }
32 %config=IkiWiki::defaultconfig();
34 $config{srcdir} = "$dir/src";
35 $config{cvsrepo} = "$dir/repo";
36 $config{cvspath} = "ikiwiki";
37 IkiWiki::loadplugins();
38 IkiWiki::checkconfig();
40 my $cvsrepo = "$dir/repo";
42 system "cvs -d $cvsrepo init >/dev/null";
43 system "mkdir $dir/ikiwiki >/dev/null";
44 system "cd $dir/ikiwiki && cvs -d $cvsrepo import -m import ikiwiki VENDOR RELEASE >/dev/null";
45 system "rm -rf $dir/ikiwiki >/dev/null";
46 system "cvs -d $cvsrepo co -d $config{srcdir} ikiwiki >/dev/null";
49 my $test1 = readfile("t/test1.mdwn");
50 writefile('test1.mdwn', $config{srcdir}, $test1);
51 IkiWiki::rcs_add("test1.mdwn");
53 files => "test1.mdwn",
54 message => "Added the first page",
59 @changes = IkiWiki::rcs_recentchanges(3);
62 is($changes[0]{message}[0]{"line"}, "Added the first page");
63 is($changes[0]{pages}[0]{"page"}, "test1");
66 my $message = "Added the second page";
68 my $test2 = readfile("t/test2.mdwn");
69 writefile('test2.mdwn', $config{srcdir}, $test2);
70 system "cd $config{srcdir} && cvs add test2.mdwn >/dev/null 2>&1";
71 system "cd $config{srcdir} && cvs commit -m \"$message\" test2.mdwn >/dev/null";
73 @changes = IkiWiki::rcs_recentchanges(3);
75 is($changes[0]{message}[0]{"line"}, $message);
76 is($changes[0]{pages}[0]{"page"}, "test2");
77 is($changes[1]{pages}[0]{"page"}, "test1");
79 # extra slashes in the path shouldn't break things
80 $config{cvspath} = "/ikiwiki//";
81 IkiWiki::checkconfig();
82 @changes = IkiWiki::rcs_recentchanges(3);
84 is($changes[0]{message}[0]{"line"}, $message);
85 is($changes[0]{pages}[0]{"page"}, "test2");
86 is($changes[1]{pages}[0]{"page"}, "test1");