2 # Tests for bugs relating to conflicting files in the srcdir
5 use Test::More tests => 106;
7 my $installed = $ENV{INSTALLED_TESTS};
11 ok(1, "running installed");
12 @command = qw(ikiwiki);
15 ok(! system("make -s ikiwiki.out"));
16 @command = qw(perl -I. ./ikiwiki.out
17 --underlaydir=underlays/basewiki
18 --set underlaydirbase=underlays
19 --templatedir=templates);
23 my $srcdir="t/tmp/src";
24 my $destdir="t/tmp/dest";
26 # runs ikiwiki to build test site
29 ok((! system(@command, qw(--plugin txt --plugin rawhtml),
30 $srcdir, $destdir, @_)),
37 ok(! system("rm -rf $srcdir/.ikiwiki $destdir"));
38 runiki(shift, "--rebuild");
41 ok(! system("rm -rf $srcdir $destdir"));
42 ok(! system("mkdir -p $srcdir"));
45 # At one point, changing the extension of the source file of a page caused
48 ok(! system("touch $srcdir/foo.mdwn"));
49 setupiki("initial setup");
50 ok(! system("mv $srcdir/foo.mdwn $srcdir/foo.txt"));
51 refreshiki("changed extension of source file of page");
52 ok(! system("mv $srcdir/foo.txt $srcdir/foo.mdwn"));
53 refreshiki("changed extension of source file of page 2");
55 # Conflicting page sources is sorta undefined behavior,
56 # but should not crash ikiwiki.
57 # Added when refreshing
58 ok(! system("touch $srcdir/foo.txt"));
59 refreshiki("conflicting page sources in refresh");
60 # Present during setup
62 ok(! system("touch $srcdir/foo.mdwn"));
63 ok(! system("touch $srcdir/foo.txt"));
64 setupiki("conflicting page sources in setup");
66 # Page and non-page file with same pagename.
68 ok(! system("touch $srcdir/foo.mdwn"));
69 ok(! system("touch $srcdir/foo"));
70 setupiki("conflicting page and non-page in setup");
72 ok(! system("touch $srcdir/foo.mdwn"));
73 setupiki("initial setup");
74 ok(! system("touch $srcdir/foo"));
75 refreshiki("conflicting page added (non-page already existing) in refresh");
77 ok(! system("touch $srcdir/foo"));
78 setupiki("initial setup");
79 ok(! system("touch $srcdir/foo.mdwn"));
80 refreshiki("conflicting non-page added (page already existing) in refresh");
82 # Page that renders to a file that is also a subdirectory holding another
85 ok(! system("touch $srcdir/foo.mdwn"));
86 ok(! system("mkdir -p $srcdir/foo/index.html"));
87 ok(! system("touch $srcdir/foo/index.html/bar.mdwn"));
88 setupiki("conflicting page file and subdirectory");
90 ok(! system("touch $srcdir/foo.mdwn"));
91 ok(! system("mkdir -p $srcdir/foo/index.html"));
92 ok(! system("touch $srcdir/foo/index.html/bar"));
93 setupiki("conflicting page file and subdirectory 2");
95 # Changing a page file into a non-page could also cause ikiwiki to fail.
97 ok(! system("touch $srcdir/foo.mdwn"));
98 setupiki("initial setup");
99 ok(! system("mv $srcdir/foo.mdwn $srcdir/foo"));
100 refreshiki("page file turned into non-page");
102 # Changing a non-page file into a page could also cause ikiwiki to fail.
104 ok(! system("touch $srcdir/foo"));
105 setupiki("initial setup");
106 ok(! system("mv $srcdir/foo $srcdir/foo.mdwn"));
107 refreshiki("non-page file turned into page");
109 # What if a page renders to the same html file that a rawhtml file provides?
110 # Added when refreshing
112 ok(! system("touch $srcdir/foo.mdwn"));
113 setupiki("initial setup");
114 ok(! system("mkdir -p $srcdir/foo"));
115 ok(! system("touch $srcdir/foo/index.html"));
116 refreshiki("rawhtml file rendered same as existing page in refresh");
117 # Moved when refreshing
119 ok(! system("touch $srcdir/foo.mdwn"));
120 setupiki("initial setup");
121 ok(! system("mkdir -p $srcdir/foo"));
122 ok(! system("mv $srcdir/foo.mdwn $srcdir/foo/index.html"));
123 refreshiki("existing page moved to rawhtml file in refresh");
124 # Inverse added when refreshing
126 ok(! system("mkdir -p $srcdir/foo"));
127 ok(! system("touch $srcdir/foo/index.html"));
128 setupiki("initial setup");
129 ok(! system("touch $srcdir/foo.mdwn"));
130 refreshiki("page rendered same as existing rawhtml file in refresh");
131 # Inverse moved when refreshing
133 ok(! system("mkdir -p $srcdir/foo"));
134 ok(! system("touch $srcdir/foo/index.html"));
135 setupiki("initial setup");
136 ok(! system("mv $srcdir/foo/index.html $srcdir/foo.mdwn"));
137 refreshiki("rawhtml file moved to page in refresh");
138 # Present during setup
140 ok(! system("touch $srcdir/foo.mdwn"));
141 ok(! system("mkdir -p $srcdir/foo"));
142 ok(! system("touch $srcdir/foo/index.html"));
143 setupiki("rawhtml file rendered same as existing page in setup");
146 ok(! system("rm -rf t/tmp"));