6 $dir = "/tmp/ikiwiki-test-bzr.$$";
9 if (! -x
$bzr || ! mkdir($dir)) {
11 use Test::More skip_all => "bzr not available or could not make test dir"
15 use Test
::More tests
=> 16;
17 BEGIN { use_ok
("IkiWiki"); }
19 %config=IkiWiki
::defaultconfig
();
21 $config{srcdir
} = "$dir/repo";
22 IkiWiki
::loadplugins
();
23 IkiWiki
::checkconfig
();
25 system "bzr init $config{srcdir}";
28 my $test1 = readfile
("t/test1.mdwn");
29 writefile
('test1.mdwn', $config{srcdir
}, $test1);
30 IkiWiki
::rcs_add
("test1.mdwn");
31 IkiWiki
::rcs_commit
("test1.mdwn", "Added the first page", "moo", "Joe User");
34 @changes = IkiWiki
::rcs_recentchanges
(3);
37 is
($changes[0]{message
}[0]{"line"}, "Added the first page");
38 is
($changes[0]{pages
}[0]{"page"}, "test1");
39 is
($changes[0]{user
}, "Joe User");
42 my $username = "Foo Bar";
43 my $user = "$username <foo.bar\@example.com>";
44 my $message = "Added the second page";
46 my $test2 = readfile
("t/test2.mdwn");
47 writefile
('test2.mdwn', $config{srcdir
}, $test2);
48 system "bzr add --quiet $config{srcdir}/test2.mdwn";
49 system "bzr commit --quiet --author \"$user\" -m \"$message\" $config{srcdir}";
51 @changes = IkiWiki
::rcs_recentchanges
(3);
54 is
($changes[0]{message
}[0]{"line"}, $message);
55 is
($changes[0]{user
}, $username);
56 is
($changes[0]{pages
}[0]{"page"}, "test2");
58 is
($changes[1]{pages
}[0]{"page"}, "test1");
60 my $ctime = IkiWiki
::rcs_getctime
("test2.mdwn");
61 ok
($ctime >= time() - 20);
63 writefile
('test3.mdwn', $config{srcdir
}, $test1);
64 IkiWiki
::rcs_add
("test3.mdwn");
65 IkiWiki
::rcs_rename
("test3.mdwn", "test4.mdwn");
66 IkiWiki
::rcs_commit_staged
("Added the 4th page", "moo", "Joe User");
68 @changes = IkiWiki
::rcs_recentchanges
(4);
71 is
($changes[0]{pages
}[0]{"page"}, "test4");
73 ok
(mkdir($config{srcdir
}."/newdir"));
74 IkiWiki
::rcs_rename
("test4.mdwn", "newdir/test5.mdwn");
75 IkiWiki
::rcs_commit_staged
("Added the 5th page", "moo", "Joe User");
77 @changes = IkiWiki
::rcs_recentchanges
(4);
80 is
($changes[0]{pages
}[0]{"page"}, "newdir/test5");
82 IkiWiki
::rcs_remove
("newdir/test5.mdwn");
83 IkiWiki
::rcs_commit_staged
("Remove the 5th page", "moo", "Joe User");