aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2019-01-31 20:14:51 +0000
committerSimon McVittie <smcv@debian.org>2019-01-31 20:37:07 +0000
commitdb54e632f4263e6b7f644c3060076079e1f350cd (patch)
treea7c67263ad1bf844059860eddcbdebcc23a2092c /t
parent2965846ef28e1be6f99e476d723a14fe98dd0977 (diff)
downloadikiwiki-db54e632f4263e6b7f644c3060076079e1f350cd.tar
ikiwiki-db54e632f4263e6b7f644c3060076079e1f350cd.tar.gz
Add a simple test for non-ASCII in tables
Signed-off-by: Simon McVittie <smcv@debian.org>
Diffstat (limited to 't')
-rwxr-xr-xt/table.t69
1 files changed, 69 insertions, 0 deletions
diff --git a/t/table.t b/t/table.t
new file mode 100755
index 000000000..d7e9e6ff0
--- /dev/null
+++ b/t/table.t
@@ -0,0 +1,69 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use Cwd qw(getcwd);
+use Test::More;
+use IkiWiki;
+
+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));
+}
+
+push @command, qw(--set usedirs=0 --plugin table
+ --url=http://example.com --cgiurl=http://example.com/ikiwiki.cgi
+ t/tmp/in t/tmp/out --verbose);
+
+my $blob;
+
+ok(! system("rm -rf t/tmp"));
+ok(! system("mkdir t/tmp"));
+
+sub write_old_file {
+ my $name = shift;
+ my $content = shift;
+
+ writefile($name, "t/tmp/in", $content);
+ ok(utime(333333333, 333333333, "t/tmp/in/$name"));
+}
+
+write_old_file("csv.mdwn",
+'[[!table format="csv" data="""
+Key,Value
+"ASCII","hello"
+"Not ASCII","¬"
+"""]]');
+write_old_file("dsv.mdwn",
+'[[!table format="dsv" data="""
+Key | Value
+ASCII | hello
+Not ASCII | ¬
+"""]]');
+
+ok(! system(@command));
+ok(! system(@command, "--refresh"));
+
+$blob = readfile("t/tmp/out/dsv.html");
+like($blob, qr{<th>\s*Key\s*</th>.*<th>\s*Value\s*</th>}s);
+like($blob, qr{<td>\s*ASCII\s*</td>.*<td>\s*hello\s*</td>}s);
+like($blob, qr{<td>\s*Not ASCII\s*</td>.*<td>\s*¬\s*</td>}s);
+
+SKIP: {
+ skip "Text::CSV unavailable", 0 unless eval q{use Text::CSV; 1};
+
+ $blob = readfile("t/tmp/out/csv.html");
+ like($blob, qr{<th>\s*Key\s*</th>.*<th>\s*Value\s*</th>}s);
+ like($blob, qr{<td>\s*ASCII\s*</td>.*<td>\s*hello\s*</td>}s);
+ like($blob, qr{<td>\s*Not ASCII\s*</td>.*<td>\s*¬\s*</td>}s);
+}
+
+done_testing;