YAML is YAML
[ikiwiki.git] / t / cvs.t
blob5ed377ed5e7234b369cc456d814e4ceefb51266c
1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4 my $dir;
5 BEGIN {
6 $dir="/tmp/ikiwiki-test-cvs.$$";
7 my $cvs=`which cvs`;
8 chomp $cvs;
9 my $cvsps=`which cvsps`;
10 chomp $cvsps;
11 if (! -x $cvs || ! -x $cvsps) {
12 eval q{
13 use Test::More skip_all => "cvs or cvsps not available"
16 if (! mkdir($dir)) {
17 die $@;
19 foreach my $module ('File::ReadBackwards', 'File::MimeInfo') {
20 eval qq{use $module};
21 if ($@) {
22 eval qq{
23 use Test::More skip_all => "$module not available"
28 use Test::More tests => 12;
30 BEGIN { use_ok("IkiWiki"); }
32 %config=IkiWiki::defaultconfig();
33 $config{rcs} = "cvs";
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";
48 # Web commit
49 my $test1 = readfile("t/test1.mdwn");
50 writefile('test1.mdwn', $config{srcdir}, $test1);
51 IkiWiki::rcs_add("test1.mdwn");
52 IkiWiki::rcs_commit(
53 files => "test1.mdwn",
54 message => "Added the first page",
55 token => "moo"
58 my @changes;
59 @changes = IkiWiki::rcs_recentchanges(3);
61 is($#changes, 0);
62 is($changes[0]{message}[0]{"line"}, "Added the first page");
63 is($changes[0]{pages}[0]{"page"}, "test1");
65 # Manual commit
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);
74 is($#changes, 1);
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);
83 is($#changes, 1);
84 is($changes[0]{message}[0]{"line"}, $message);
85 is($changes[0]{pages}[0]{"page"}, "test2");
86 is($changes[1]{pages}[0]{"page"}, "test1");
88 system "rm -rf $dir";