6 $dir="/tmp/ikiwiki-test-cvs.$$";
9 my $cvsps=`which cvsps`;
11 if (! -x $cvs || ! -x $cvsps || ! mkdir($dir)) {
13 use Test::More skip_all => "cvs or cvsps not available or could not make test dir"
17 use Test::More tests => 12;
19 BEGIN { use_ok("IkiWiki"); }
21 %config=IkiWiki::defaultconfig();
23 $config{srcdir} = "$dir/src";
24 $config{cvsrepo} = "$dir/repo";
25 $config{cvspath} = "ikiwiki";
26 IkiWiki::loadplugins();
27 IkiWiki::checkconfig();
29 my $cvsrepo = "$dir/repo";
31 system "cvs -d $cvsrepo init >/dev/null";
32 system "mkdir $dir/ikiwiki >/dev/null";
33 system "cd $dir/ikiwiki && cvs -d $cvsrepo import -m import ikiwiki VENDOR RELEASE >/dev/null";
34 system "rm -rf $dir/ikiwiki >/dev/null";
35 system "cvs -d $cvsrepo co -d $config{srcdir} ikiwiki >/dev/null";
38 my $test1 = readfile("t/test1.mdwn");
39 writefile('test1.mdwn', $config{srcdir}, $test1);
40 IkiWiki::rcs_add("test1.mdwn");
41 IkiWiki::rcs_commit("test1.mdwn", "Added the first page", "moo");
44 @changes = IkiWiki::rcs_recentchanges(3);
47 is($changes[0]{message}[0]{"line"}, "Added the first page");
48 is($changes[0]{pages}[0]{"page"}, "test1");
51 my $message = "Added the second page";
53 my $test2 = readfile("t/test2.mdwn");
54 writefile('test2.mdwn', $config{srcdir}, $test2);
55 system "cd $config{srcdir} && cvs add test2.mdwn >/dev/null 2>&1";
56 system "cd $config{srcdir} && cvs commit -m \"$message\" test2.mdwn >/dev/null";
58 @changes = IkiWiki::rcs_recentchanges(3);
60 is($changes[0]{message}[0]{"line"}, $message);
61 is($changes[0]{pages}[0]{"page"}, "test2");
62 is($changes[1]{pages}[0]{"page"}, "test1");
64 # extra slashes in the path shouldn't break things
65 $config{cvspath} = "/ikiwiki//";
66 IkiWiki::checkconfig();
67 @changes = IkiWiki::rcs_recentchanges(3);
69 is($changes[0]{message}[0]{"line"}, $message);
70 is($changes[0]{pages}[0]{"page"}, "test2");
71 is($changes[1]{pages}[0]{"page"}, "test1");