6 $dir="/tmp/ikiwiki-test-svn.$$";
9 my $svnadmin=`which svnadmin`;
11 if (! -x $svn || ! -x $svnadmin || ! mkdir($dir)) {
13 use Test::More skip_all => "svn 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{svnrepo} = "$dir/repo";
25 $config{svnpath} = "trunk";
26 IkiWiki::loadplugins();
27 IkiWiki::checkconfig();
29 my $svnrepo = "$dir/repo";
31 system "svnadmin create $svnrepo >/dev/null";
32 system "svn mkdir file://$svnrepo/trunk -m add >/dev/null";
33 system "svn co file://$svnrepo/trunk $config{srcdir} >/dev/null";
36 my $test1 = readfile("t/test1.mdwn");
37 writefile('test1.mdwn', $config{srcdir}, $test1);
38 IkiWiki::rcs_add("test1.mdwn");
41 message => "Added the first page",
46 @changes = IkiWiki::rcs_recentchanges(3);
49 is($changes[0]{message}[0]{"line"}, "Added the first page");
50 is($changes[0]{pages}[0]{"page"}, "test1");
53 my $message = "Added the second page";
55 my $test2 = readfile("t/test2.mdwn");
56 writefile('test2.mdwn', $config{srcdir}, $test2);
57 system "svn add $config{srcdir}/test2.mdwn >/dev/null";
58 system "svn commit $config{srcdir}/test2.mdwn -m \"$message\" >/dev/null";
60 @changes = IkiWiki::rcs_recentchanges(3);
62 is($changes[0]{message}[0]{"line"}, $message);
63 is($changes[0]{pages}[0]{"page"}, "test2");
64 is($changes[1]{pages}[0]{"page"}, "test1");
66 # extra slashes in the path shouldn't break things
67 $config{svnpath} = "/trunk//";
68 IkiWiki::checkconfig();
69 @changes = IkiWiki::rcs_recentchanges(3);
71 is($changes[0]{message}[0]{"line"}, $message);
72 is($changes[0]{pages}[0]{"page"}, "test2");
73 is($changes[1]{pages}[0]{"page"}, "test1");