aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rwxr-xr-xt/trail.t73
1 files changed, 42 insertions, 31 deletions
diff --git a/t/trail.t b/t/trail.t
index 17fe54310..b24a81e41 100755
--- a/t/trail.t
+++ b/t/trail.t
@@ -9,9 +9,19 @@ my $blob;
ok(! system("rm -rf t/tmp"));
ok(! system("mkdir t/tmp"));
+# Write files with a date in the past, so that when we refresh,
+# the update is detected.
+sub write_old_file {
+ my $name = shift;
+ my $content = shift;
+
+ writefile($name, "t/tmp/in", $content);
+ ok(utime(333333333, 333333333, "t/tmp/in/$name"));
+}
+
# Use a rather stylized template to override the default rendering, to make
# it easy to search for the desired results
-writefile("templates/trails.tmpl", "t/tmp/in", <<EOF
+write_old_file("templates/trails.tmpl", <<EOF
<TMPL_LOOP TRAILLOOP>
<TMPL_IF __FIRST__><nav></TMPL_IF>
<div>
@@ -30,46 +40,46 @@ trail=<TMPL_VAR TRAILPAGE> n=<TMPL_VAR NEXTPAGE> p=<TMPL_VAR PREVPAGE>
</TMPL_LOOP>
EOF
);
-writefile("badger.mdwn", "t/tmp/in", "[[!meta title=\"The Breezy Badger\"]]\ncontent of badger");
-writefile("mushroom.mdwn", "t/tmp/in", "content of mushroom");
-writefile("snake.mdwn", "t/tmp/in", "content of snake");
-writefile("ratty.mdwn", "t/tmp/in", "content of ratty");
-writefile("mr_toad.mdwn", "t/tmp/in", "content of mr toad");
-writefile("add.mdwn", "t/tmp/in", '[[!trailitems pagenames="add/a add/b add/c add/d add/e"]]');
-writefile("add/b.mdwn", "t/tmp/in", "b");
-writefile("add/d.mdwn", "t/tmp/in", "d");
-writefile("del.mdwn", "t/tmp/in", '[[!trailitems pages="del/*" sort=title]]');
-writefile("del/a.mdwn", "t/tmp/in", "a");
-writefile("del/b.mdwn", "t/tmp/in", "b");
-writefile("del/c.mdwn", "t/tmp/in", "c");
-writefile("del/d.mdwn", "t/tmp/in", "d");
-writefile("del/e.mdwn", "t/tmp/in", "e");
-writefile("self_referential.mdwn", "t/tmp/in", '[[!trailitems pagenames="self_referential" circular=yes]]');
-writefile("sorting/linked.mdwn", "t/tmp/in", "linked");
-writefile("sorting/a/b.mdwn", "t/tmp/in", "a/b");
-writefile("sorting/a/c.mdwn", "t/tmp/in", "a/c");
-writefile("sorting/z/a.mdwn", "t/tmp/in", "z/a");
-writefile("sorting/beginning.mdwn", "t/tmp/in", "beginning");
-writefile("sorting/middle.mdwn", "t/tmp/in", "middle");
-writefile("sorting/end.mdwn", "t/tmp/in", "end");
-writefile("sorting/new.mdwn", "t/tmp/in", "new");
-writefile("sorting/old.mdwn", "t/tmp/in", "old");
-writefile("sorting/ancient.mdwn", "t/tmp/in", "ancient");
+write_old_file("badger.mdwn", "[[!meta title=\"The Breezy Badger\"]]\ncontent of badger");
+write_old_file("mushroom.mdwn", "content of mushroom");
+write_old_file("snake.mdwn", "content of snake");
+write_old_file("ratty.mdwn", "content of ratty");
+write_old_file("mr_toad.mdwn", "content of mr toad");
+write_old_file("add.mdwn", '[[!trailitems pagenames="add/a add/b add/c add/d add/e"]]');
+write_old_file("add/b.mdwn", "b");
+write_old_file("add/d.mdwn", "d");
+write_old_file("del.mdwn", '[[!trailitems pages="del/*" sort=title]]');
+write_old_file("del/a.mdwn", "a");
+write_old_file("del/b.mdwn", "b");
+write_old_file("del/c.mdwn", "c");
+write_old_file("del/d.mdwn", "d");
+write_old_file("del/e.mdwn", "e");
+write_old_file("self_referential.mdwn", '[[!trailitems pagenames="self_referential" circular=yes]]');
+write_old_file("sorting/linked.mdwn", "linked");
+write_old_file("sorting/a/b.mdwn", "a/b");
+write_old_file("sorting/a/c.mdwn", "a/c");
+write_old_file("sorting/z/a.mdwn", "z/a");
+write_old_file("sorting/beginning.mdwn", "beginning");
+write_old_file("sorting/middle.mdwn", "middle");
+write_old_file("sorting/end.mdwn", "end");
+write_old_file("sorting/new.mdwn", "new");
+write_old_file("sorting/old.mdwn", "old");
+write_old_file("sorting/ancient.mdwn", "ancient");
# These three need to be in the appropriate age order
ok(utime(333333333, 333333333, "t/tmp/in/sorting/new.mdwn"));
ok(utime(222222222, 222222222, "t/tmp/in/sorting/old.mdwn"));
ok(utime(111111111, 111111111, "t/tmp/in/sorting/ancient.mdwn"));
-writefile("sorting/linked2.mdwn", "t/tmp/in", "linked2");
+write_old_file("sorting/linked2.mdwn", "linked2");
# This initially uses the default sort order: age for the inline, and path
# for trailitems. We change it later.
-writefile("sorting.mdwn", "t/tmp/in",
+write_old_file("sorting.mdwn",
'[[!traillink linked]] ' .
'[[!trailitems pages="sorting/z/a or sorting/a/b or sorting/a/c"]] ' .
'[[!trailitems pagenames="beginning middle end"]] ' .
'[[!inline pages="sorting/old or sorting/ancient or sorting/new" trail="yes"]] ' .
'[[!traillink linked2]]');
-writefile("meme.mdwn", "t/tmp/in", <<EOF
+write_old_file("meme.mdwn", <<EOF
[[!trail]]
* [[!traillink badger]]
* [[!traillink badger text="This is a link to badger, with a title"]]
@@ -82,7 +92,7 @@ writefile("meme.mdwn", "t/tmp/in", <<EOF
EOF
);
-writefile("wind_in_the_willows.mdwn", "t/tmp/in", <<EOF
+write_old_file("wind_in_the_willows.mdwn", <<EOF
[[!trailoptions circular=yes sort=title]]
[[!trailitems pages="ratty or badger or mr_toad"]]
[[!trailitem moley]]
@@ -173,7 +183,8 @@ ok($blob =~ m{^trail=sorting n=sorting/linked2 p=sorting/old$}m);
$blob = readfile("t/tmp/out/sorting/linked2.html");
ok($blob =~ m{^trail=sorting n= p=sorting/ancient$}m);
-# Make some changes and refresh
+# Make some changes and refresh. These writefile calls don't set an
+# old mtime, so they're strictly newer than the "old" files.
writefile("add/a.mdwn", "t/tmp/in", "a");
writefile("add/c.mdwn", "t/tmp/in", "c");