2011-06-04 17:55:24 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
2016-07-28 10:50:09 +02:00
|
|
|
use Cwd qw(getcwd);
|
2015-11-30 18:33:00 +01:00
|
|
|
use Test::More;
|
2011-06-04 17:55:24 +02:00
|
|
|
use IkiWiki;
|
|
|
|
|
|
|
|
ok(! system("rm -rf t/tmp"));
|
|
|
|
ok(mkdir "t/tmp");
|
|
|
|
ok(! system("cp -R t/tinyblog t/tmp/in"));
|
|
|
|
ok(mkdir "t/tmp/in/post" or -d "t/tmp/in/post");
|
|
|
|
|
2015-11-30 18:33:00 +01:00
|
|
|
my $installed = $ENV{INSTALLED_TESTS};
|
|
|
|
|
|
|
|
my @command;
|
|
|
|
if ($installed) {
|
|
|
|
@command = qw(ikiwiki);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ok(! system("make -s ikiwiki.out"));
|
2016-07-28 10:50:09 +02:00
|
|
|
@command = ("perl", "-I".getcwd, qw(./ikiwiki.out
|
2015-11-30 18:33:00 +01:00
|
|
|
--underlaydir=underlays/basewiki
|
|
|
|
--set underlaydirbase=underlays
|
2016-07-28 10:50:09 +02:00
|
|
|
--templatedir=templates));
|
2015-11-30 18:33:00 +01:00
|
|
|
}
|
|
|
|
|
2011-06-04 17:55:24 +02:00
|
|
|
my $comment;
|
|
|
|
|
|
|
|
$comment = <<EOF;
|
|
|
|
[[!comment username="neil"
|
|
|
|
date="1969-07-20T20:17:40Z"
|
|
|
|
content="I landed"]]
|
|
|
|
EOF
|
|
|
|
#ok(eval { writefile("post/comment_3._comment", "t/tmp/in", $comment); 1 });
|
|
|
|
writefile("post/comment_3._comment", "t/tmp/in", $comment);
|
|
|
|
|
|
|
|
$comment = <<EOF;
|
|
|
|
[[!comment username="christopher"
|
2011-09-05 19:15:59 +02:00
|
|
|
date="1969-02-12T07:00:00Z"
|
2011-06-04 17:55:24 +02:00
|
|
|
content="I explored"]]
|
|
|
|
EOF
|
2019-02-03 17:05:13 +01:00
|
|
|
writefile("post/comment_2_10a49d69282155c5c3e66dc58f64f956._comment", "t/tmp/in", $comment);
|
2011-06-04 17:55:24 +02:00
|
|
|
|
|
|
|
$comment = <<EOF;
|
|
|
|
[[!comment username="william"
|
2011-09-05 19:15:59 +02:00
|
|
|
date="1969-01-14T12:00:00Z"
|
2011-06-04 17:55:24 +02:00
|
|
|
content="I conquered"]]
|
|
|
|
EOF
|
|
|
|
writefile("post/comment_1._comment", "t/tmp/in", $comment);
|
|
|
|
|
|
|
|
# Give the files mtimes in the wrong order
|
|
|
|
ok(utime(111111111, 111111111, "t/tmp/in/post/comment_3._comment"));
|
2019-02-03 17:05:13 +01:00
|
|
|
ok(utime(222222222, 222222222, "t/tmp/in/post/comment_2_10a49d69282155c5c3e66dc58f64f956._comment"));
|
2011-06-04 17:55:24 +02:00
|
|
|
ok(utime(333333333, 333333333, "t/tmp/in/post/comment_1._comment"));
|
|
|
|
|
|
|
|
# Build the wiki
|
2015-11-30 18:33:00 +01:00
|
|
|
ok(! system(@command, qw(--verbose --plugin comments --url=http://example.com --cgiurl=http://example.com/ikiwiki.cgi --rss --atom --set comments_pagespec=* t/tmp/in t/tmp/out)));
|
2011-06-04 17:55:24 +02:00
|
|
|
|
|
|
|
# Check that the comments are in the right order
|
|
|
|
|
|
|
|
sub slurp {
|
|
|
|
open my $fh, "<", shift or return undef;
|
|
|
|
local $/;
|
|
|
|
my $content = <$fh>;
|
|
|
|
close $fh or return undef;
|
|
|
|
return $content;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $content = slurp("t/tmp/out/post/index.html");
|
|
|
|
ok(defined $content);
|
2019-02-03 17:06:36 +01:00
|
|
|
like($content, qr/I conquered.*I explored.*I landed/s);
|
|
|
|
|
|
|
|
$content = slurp("t/tmp/out/post/index.atom");
|
|
|
|
ok(defined $content);
|
|
|
|
like($content, qr{
|
|
|
|
<link\s*href="http://example\.com/post/[#]comment-[[:xdigit:]]+"
|
|
|
|
.*
|
|
|
|
<link\s*href="http://example\.com/post/[#]comment-[[:xdigit:]]+"
|
|
|
|
.*
|
|
|
|
<link\s*href="http://example\.com/post/[#]comment-[[:xdigit:]]+"
|
|
|
|
}sx, 'Each comment gets an appropriate permalink in <link>');
|
|
|
|
unlike($content, qr{<link\s*href=.*/post/comment_[123]/});
|
|
|
|
unlike($content, qr{<link\s*href=.*/post/comment_[123]_[[:xdigit:]]+/});
|
2015-11-30 18:33:00 +01:00
|
|
|
|
|
|
|
done_testing();
|