1#!/usr/bin/perl 2use warnings; 3use strict; 4use Cwd qw(getcwd); 5use Test::More; 6use IkiWiki; 7 8my $installed = $ENV{INSTALLED_TESTS}; 9 10my @command; 11if ($installed) { 12 @command = qw(ikiwiki); 13} 14else { 15 ok(! system("make -s ikiwiki.out")); 16 @command = ("perl", "-I".getcwd, qw(./ikiwiki.out 17 --underlaydir=underlays/basewiki 18 --set underlaydirbase=underlays 19 --templatedir=templates)); 20} 21 22push @command, qw(--set usedirs=0 --plugin table 23 --url=http://example.com --cgiurl=http://example.com/ikiwiki.cgi 24 t/tmp/in t/tmp/out --verbose); 25 26my $blob; 27 28ok(! system("rm -rf t/tmp")); 29ok(! system("mkdir t/tmp")); 30 31sub write_old_file { 32 my $name = shift; 33 my $content = shift; 34 35 writefile($name, "t/tmp/in", $content); 36 ok(utime(333333333, 333333333, "t/tmp/in/$name")); 37} 38 39write_old_file("csv.mdwn", 40'[[!table format="csv" data=""" 41Key,Value 42"ASCII","hello" 43"Not ASCII","¬" 44"""]]'); 45write_old_file("dsv.mdwn", 46'[[!table format="dsv" data=""" 47Key | Value 48ASCII | hello 49Not ASCII | ¬ 50"""]]'); 51write_old_file("jon.mdwn", 52'(See doc/bugs/table_can_not_deal_with_Chinese.mdwn) 53 54[[!table class=fullwidth_table delimiter=" " data=""" 55Number Title Own? Read? 56I (HB1), 70 (PB1), 5 (PB50) Dune O ✓"""]]'); 57 58ok(! system(@command)); 59ok(! system(@command, "--refresh")); 60 61$blob = readfile("t/tmp/out/dsv.html"); 62like($blob, qr{<th>\s*Key\s*</th>.*<th>\s*Value\s*</th>}s); 63like($blob, qr{<td>\s*ASCII\s*</td>.*<td>\s*hello\s*</td>}s); 64like($blob, qr{<td>\s*Not ASCII\s*</td>.*<td>\s*¬\s*</td>}s); 65 66SKIP: { 67 skip "Text::CSV unavailable", 0 unless eval q{use Text::CSV; 1}; 68 69 $blob = readfile("t/tmp/out/jon.html"); 70 like($blob, qr{<th>\s*Number\s*</th>\s*<th>\s*Title\s*</th>\s*<th>\s*Own\?\s*</th>\s*<th>\s*Read\?\s*</th>}s); 71 like($blob, qr{<td>\s*I \(HB1\), 70 \(PB1\), 5 \(PB50\)\s*</td>\s*<td>\s*Dune\s*</td>\s*<td>\s*O\s*</td>\s*<td>\s*✓\s*</td>}s); 72 73 $blob = readfile("t/tmp/out/csv.html"); 74 like($blob, qr{<th>\s*Key\s*</th>.*<th>\s*Value\s*</th>}s); 75 like($blob, qr{<td>\s*ASCII\s*</td>.*<td>\s*hello\s*</td>}s); 76 like($blob, qr{<td>\s*Not ASCII\s*</td>.*<td>\s*¬\s*</td>}s); 77} 78 79done_testing; 80