2 # Tests for bugs relating to conflicting files in the srcdir
6 use Test::More tests => 106;
8 my $installed = $ENV{INSTALLED_TESTS};
12 ok(1, "running installed");
13 @command = qw(ikiwiki);
16 ok(! system("make -s ikiwiki.out"));
17 @command = ("perl", "-I".getcwd, qw(./ikiwiki.out
18 --underlaydir=underlays/basewiki
19 --set underlaydirbase=underlays
20 --templatedir=templates));
24 my $srcdir="t/tmp/src";
25 my $destdir="t/tmp/dest";
27 # runs ikiwiki to build test site
30 ok((! system(@command, qw(--plugin txt --plugin rawhtml),
31 $srcdir, $destdir, @_)),
38 ok(! system("rm -rf $srcdir/.ikiwiki $destdir"));
39 runiki(shift, "--rebuild");
42 ok(! system("rm -rf $srcdir $destdir"));
43 ok(! system("mkdir -p $srcdir"));
46 # At one point, changing the extension of the source file of a page caused
49 ok(! system("touch $srcdir/foo.mdwn"));
50 setupiki("initial setup");
51 ok(! system("mv $srcdir/foo.mdwn $srcdir/foo.txt"));
52 refreshiki("changed extension of source file of page");
53 ok(! system("mv $srcdir/foo.txt $srcdir/foo.mdwn"));
54 refreshiki("changed extension of source file of page 2");
56 # Conflicting page sources is sorta undefined behavior,
57 # but should not crash ikiwiki.
58 # Added when refreshing
59 ok(! system("touch $srcdir/foo.txt"));
60 refreshiki("conflicting page sources in refresh");
61 # Present during setup
63 ok(! system("touch $srcdir/foo.mdwn"));
64 ok(! system("touch $srcdir/foo.txt"));
65 setupiki("conflicting page sources in setup");
67 # Page and non-page file with same pagename.
69 ok(! system("touch $srcdir/foo.mdwn"));
70 ok(! system("touch $srcdir/foo"));
71 setupiki("conflicting page and non-page in setup");
73 ok(! system("touch $srcdir/foo.mdwn"));
74 setupiki("initial setup");
75 ok(! system("touch $srcdir/foo"));
76 refreshiki("conflicting page added (non-page already existing) in refresh");
78 ok(! system("touch $srcdir/foo"));
79 setupiki("initial setup");
80 ok(! system("touch $srcdir/foo.mdwn"));
81 refreshiki("conflicting non-page added (page already existing) in refresh");
83 # Page that renders to a file that is also a subdirectory holding another
86 ok(! system("touch $srcdir/foo.mdwn"));
87 ok(! system("mkdir -p $srcdir/foo/index.html"));
88 ok(! system("touch $srcdir/foo/index.html/bar.mdwn"));
89 setupiki("conflicting page file and subdirectory");
91 ok(! system("touch $srcdir/foo.mdwn"));
92 ok(! system("mkdir -p $srcdir/foo/index.html"));
93 ok(! system("touch $srcdir/foo/index.html/bar"));
94 setupiki("conflicting page file and subdirectory 2");
96 # Changing a page file into a non-page could also cause ikiwiki to fail.
98 ok(! system("touch $srcdir/foo.mdwn"));
99 setupiki("initial setup");
100 ok(! system("mv $srcdir/foo.mdwn $srcdir/foo"));
101 refreshiki("page file turned into non-page");
103 # Changing a non-page file into a page could also cause ikiwiki to fail.
105 ok(! system("touch $srcdir/foo"));
106 setupiki("initial setup");
107 ok(! system("mv $srcdir/foo $srcdir/foo.mdwn"));
108 refreshiki("non-page file turned into page");
110 # What if a page renders to the same html file that a rawhtml file provides?
111 # Added when refreshing
113 ok(! system("touch $srcdir/foo.mdwn"));
114 setupiki("initial setup");
115 ok(! system("mkdir -p $srcdir/foo"));
116 ok(! system("touch $srcdir/foo/index.html"));
117 refreshiki("rawhtml file rendered same as existing page in refresh");
118 # Moved when refreshing
120 ok(! system("touch $srcdir/foo.mdwn"));
121 setupiki("initial setup");
122 ok(! system("mkdir -p $srcdir/foo"));
123 ok(! system("mv $srcdir/foo.mdwn $srcdir/foo/index.html"));
124 refreshiki("existing page moved to rawhtml file in refresh");
125 # Inverse added when refreshing
127 ok(! system("mkdir -p $srcdir/foo"));
128 ok(! system("touch $srcdir/foo/index.html"));
129 setupiki("initial setup");
130 ok(! system("touch $srcdir/foo.mdwn"));
131 refreshiki("page rendered same as existing rawhtml file in refresh");
132 # Inverse moved when refreshing
134 ok(! system("mkdir -p $srcdir/foo"));
135 ok(! system("touch $srcdir/foo/index.html"));
136 setupiki("initial setup");
137 ok(! system("mv $srcdir/foo/index.html $srcdir/foo.mdwn"));
138 refreshiki("rawhtml file moved to page in refresh");
139 # Present during setup
141 ok(! system("touch $srcdir/foo.mdwn"));
142 ok(! system("mkdir -p $srcdir/foo"));
143 ok(! system("touch $srcdir/foo/index.html"));
144 setupiki("rawhtml file rendered same as existing page in setup");
147 ok(! system("rm -rf t/tmp"));