X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/6d01db205f41f16755fe7fbe49694b3bba2121c8..e4f38459c02cf617f4621ce607caf48d0b1af771:/t/comments.t

diff --git a/t/comments.t b/t/comments.t
index 4721d7a9c..fc87d72ff 100755
--- a/t/comments.t
+++ b/t/comments.t
@@ -1,7 +1,8 @@
 #!/usr/bin/perl
 use warnings;
 use strict;
-use Test::More 'no_plan';
+use Cwd qw(getcwd);
+use Test::More;
 use IkiWiki;
 
 ok(! system("rm -rf t/tmp"));
@@ -9,6 +10,20 @@ 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");
 
+my $installed = $ENV{INSTALLED_TESTS};
+
+my @command;
+if ($installed) {
+	@command = qw(ikiwiki);
+}
+else {
+	ok(! system("make -s ikiwiki.out"));
+	@command = ("perl", "-I".getcwd, qw(./ikiwiki.out
+		--underlaydir=underlays/basewiki
+		--set underlaydirbase=underlays
+		--templatedir=templates));
+}
+
 my $comment;
 
 $comment = <<EOF;
@@ -21,26 +36,25 @@ writefile("post/comment_3._comment", "t/tmp/in", $comment);
 
 $comment = <<EOF;
 [[!comment username="christopher"
-  date="1492-10-12T07:00:00Z"
+  date="1969-02-12T07:00:00Z"
   content="I explored"]]
 EOF
-writefile("post/comment_2._comment", "t/tmp/in", $comment);
+writefile("post/comment_2_10a49d69282155c5c3e66dc58f64f956._comment", "t/tmp/in", $comment);
 
 $comment = <<EOF;
 [[!comment username="william"
-  date="1066-10-14T12:00:00Z"
+  date="1969-01-14T12:00:00Z"
   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"));
-ok(utime(222222222, 222222222, "t/tmp/in/post/comment_2._comment"));
+ok(utime(222222222, 222222222, "t/tmp/in/post/comment_2_10a49d69282155c5c3e66dc58f64f956._comment"));
 ok(utime(333333333, 333333333, "t/tmp/in/post/comment_1._comment"));
 
 # Build the wiki
-ok(! system("make -s ikiwiki.out"));
-ok(! system("perl -I. ./ikiwiki.out -verbose -plugin comments -url=http://example.com -cgiurl=http://example.com/ikiwiki.cgi -rss -atom -underlaydir=underlays/basewiki -set underlaydirbase=underlays -set comments_pagespec='*' -templatedir=templates t/tmp/in t/tmp/out"));
+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)));
 
 # Check that the comments are in the right order
 
@@ -54,4 +68,18 @@ sub slurp {
 
 my $content = slurp("t/tmp/out/post/index.html");
 ok(defined $content);
-ok($content =~ m/I conquered.*I explored.*I landed/s);
+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:]]+/});
+
+done_testing();