aboutsummaryrefslogtreecommitdiff
path: root/t/replace.t
blob: 04791d9f74a6697f577506b462aa3e51f63350f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/perl
# Tests for bugs relating to replacing/renaming files in the srcdir.
use warnings;
use strict;
use Test::More 'no_plan';

# setup
my $srcdir="t/tmp/src";
my $destdir="t/tmp/dest";
ok(! system("make -s ikiwiki.out"));

# runs ikiwiki to build test site
sub runiki {
	ok(! system("perl -I. ./ikiwiki.out -plugin html -underlaydir=underlays/basewiki -set underlaydirbase=underlays -templatedir=templates $srcdir $destdir @_"));
}
sub refreshiki {
	runiki();
}
sub setupiki {
	ok(! system("rm -rf $srcdir/.ikiwiki $destdir"));
	runiki("--rebuild");
}
sub newsrcdir {
	ok(! system("rm -rf $srcdir $destdir"));
	ok(! system("mkdir -p $srcdir"));
}

# At one point, changing the extension of the source file of a page caused
# ikiwiki to fail.
newsrcdir();
ok(! system("touch $srcdir/foo.mdwn"));
setupiki();
ok(! system("mv $srcdir/foo.mdwn $srcdir/foo.html"));
refreshiki();
ok(! system("mv $srcdir/foo.html $srcdir/foo.mdwn"));
refreshiki();

# Changing a non-page file into a page could also cause ikiwiki to fail.
newsrcdir();
ok(! system("touch $srcdir/foo"));
setupiki();
ok(! system("mv $srcdir/foo $srcdir/foo.mdwn"));
refreshiki();

# Changing a page file into a non-page could also cause ikiwiki to fail.
newsrcdir();
ok(! system("touch $srcdir/foo.mdwn"));
setupiki();
ok(! system("mv $srcdir/foo.mdwn $srcdir/foo"));
refreshiki();

# cleanup
ok(! system("rm -rf t/tmp"));