New withlist item: [[!meta redir]] -- tell what's going on
[ikiwiki.git] / t / cvs.t
blob2808973be55a1819c65d2178cab3cf5e76841872
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 || ! mkdir($dir)) {
12 eval q{
13 use Test::More skip_all => "cvs or cvsps not available or could not make test dir"
16 foreach my $module ('File::ReadBackwards', 'File::MimeInfo') {
17 eval qq{use $module};
18 if ($@) {
19 eval qq{
20 use Test::More skip_all => "$module not available"
25 use Test::More tests => 12;
27 BEGIN { use_ok("IkiWiki"); }
29 %config=IkiWiki::defaultconfig();
30 $config{rcs} = "cvs";
31 $config{srcdir} = "$dir/src";
32 $config{cvsrepo} = "$dir/repo";
33 $config{cvspath} = "ikiwiki";
34 IkiWiki::loadplugins();
35 IkiWiki::checkconfig();
37 my $cvsrepo = "$dir/repo";
39 system "cvs -d $cvsrepo init >/dev/null";
40 system "mkdir $dir/ikiwiki >/dev/null";
41 system "cd $dir/ikiwiki && cvs -d $cvsrepo import -m import ikiwiki VENDOR RELEASE >/dev/null";
42 system "rm -rf $dir/ikiwiki >/dev/null";
43 system "cvs -d $cvsrepo co -d $config{srcdir} ikiwiki >/dev/null";
45 # Web commit
46 my $test1 = readfile("t/test1.mdwn");
47 writefile('test1.mdwn', $config{srcdir}, $test1);
48 IkiWiki::rcs_add("test1.mdwn");
49 IkiWiki::rcs_commit("test1.mdwn", "Added the first page", "moo");
51 my @changes;
52 @changes = IkiWiki::rcs_recentchanges(3);
54 is($#changes, 0);
55 is($changes[0]{message}[0]{"line"}, "Added the first page");
56 is($changes[0]{pages}[0]{"page"}, "test1");
58 # Manual commit
59 my $message = "Added the second page";
61 my $test2 = readfile("t/test2.mdwn");
62 writefile('test2.mdwn', $config{srcdir}, $test2);
63 system "cd $config{srcdir} && cvs add test2.mdwn >/dev/null 2>&1";
64 system "cd $config{srcdir} && cvs commit -m \"$message\" test2.mdwn >/dev/null";
66 @changes = IkiWiki::rcs_recentchanges(3);
67 is($#changes, 1);
68 is($changes[0]{message}[0]{"line"}, $message);
69 is($changes[0]{pages}[0]{"page"}, "test2");
70 is($changes[1]{pages}[0]{"page"}, "test1");
72 # extra slashes in the path shouldn't break things
73 $config{cvspath} = "/ikiwiki//";
74 IkiWiki::checkconfig();
75 @changes = IkiWiki::rcs_recentchanges(3);
76 is($#changes, 1);
77 is($changes[0]{message}[0]{"line"}, $message);
78 is($changes[0]{pages}[0]{"page"}, "test2");
79 is($changes[1]{pages}[0]{"page"}, "test1");
81 system "rm -rf $dir";