summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2008-11-07 21:24:00 +0100
committerintrigeri <intrigeri@boum.org>2008-11-07 21:24:00 +0100
commit14415a2b67f94691572028d2e0f2c99a2e3244fc (patch)
tree7eac2ec3cc064fc09ac92b0d84de5798759d3925 /t
parent3e341e64c2bcb0c6ae4deba8b4b27a24e90c9db6 (diff)
po: implemented linking specification in testcase
Signed-off-by: intrigeri <intrigeri@boum.org>
Diffstat (limited to 't')
-rwxr-xr-xt/po.t55
1 files changed, 46 insertions, 9 deletions
diff --git a/t/po.t b/t/po.t
index 232c98c81..8608855d4 100755
--- a/t/po.t
+++ b/t/po.t
@@ -2,7 +2,7 @@
# -*- cperl-indent-level: 8; -*-
use warnings;
use strict;
-use File::Temp;
+use File::Temp qw{tempdir};
BEGIN {
unless (eval { require Locale::Po4a::Chooser }) {
@@ -17,18 +17,21 @@ BEGIN {
}
}
-use Test::More tests => 34;
+use Test::More tests => 45;
BEGIN { use_ok("IkiWiki"); }
my $msgprefix;
+my $dir = tempdir("ikiwiki-test-po.XXXXXXXXXX",
+ DIR => File::Spec->tmpdir,
+ CLEANUP => 1);
+
### Init
%config=IkiWiki::defaultconfig();
-$config{srcdir}=$config{destdir}="/dev/null";
-## will need this when more thorough tests are written
-# $config{srcdir} = "t/po/src";
-# $config{destdir} = File::Temp->newdir("ikiwiki-test-po.XXXXXXXXXX", TMPDIR => 1)->dirname;
+$config{srcdir} = "$dir/src";
+$config{destdir} = "$dir/dst";
+$config{discussion} = 0;
$config{po_master_language} = { code => 'en',
name => 'English'
};
@@ -36,7 +39,7 @@ $config{po_slave_languages} = {
es => 'Castellano',
fr => "Français"
};
-$config{po_translatable_pages}='index or test1 or test2';
+$config{po_translatable_pages}='index or test1 or test2 or translatable';
$config{po_link_to}='negotiated';
IkiWiki::loadplugins();
IkiWiki::checkconfig();
@@ -45,6 +48,7 @@ ok(IkiWiki::loadplugin('po'), "po plugin loaded");
### seed %pagesources and %pagecase
$pagesources{'index'}='index.mdwn';
$pagesources{'index.fr'}='index.fr.po';
+$pagesources{'index.es'}='index.es.po';
$pagesources{'test1'}='test1.mdwn';
$pagesources{'test1.fr'}='test1.fr.po';
$pagesources{'test2'}='test2.mdwn';
@@ -52,6 +56,10 @@ $pagesources{'test2.es'}='test2.es.po';
$pagesources{'test2.fr'}='test2.fr.po';
$pagesources{'test3'}='test3.mdwn';
$pagesources{'test3.es'}='test3.es.mdwn';
+$pagesources{'translatable'}='translatable.mdwn';
+$pagesources{'translatable.fr'}='translatable.fr.po';
+$pagesources{'translatable.es'}='translatable.es.po';
+$pagesources{'nontranslatable'}='nontranslatable.mdwn';
foreach my $page (keys %pagesources) {
$IkiWiki::pagecase{lc $page}=$page;
}
@@ -61,12 +69,16 @@ foreach my $page (keys %pagesources) {
# succeed once every two tries...
ok(IkiWiki::Plugin::po::istranslatable('index'), "index is translatable");
ok(IkiWiki::Plugin::po::istranslatable('index'), "index is translatable");
-ok(! IkiWiki::Plugin::po::istranslatable('index.fr'), "index is not translatable");
-ok(! IkiWiki::Plugin::po::istranslatable('index.fr'), "index is not translatable");
+ok(! IkiWiki::Plugin::po::istranslatable('index.fr'), "index.fr is not translatable");
+ok(! IkiWiki::Plugin::po::istranslatable('index.fr'), "index.fr is not translatable");
+ok(! IkiWiki::Plugin::po::istranslatable('index.es'), "index.es is not translatable");
+ok(! IkiWiki::Plugin::po::istranslatable('index.es'), "index.es is not translatable");
ok(! IkiWiki::Plugin::po::istranslation('index'), "index is not a translation");
ok(! IkiWiki::Plugin::po::istranslation('index'), "index is not a translation");
ok(IkiWiki::Plugin::po::istranslation('index.fr'), "index.fr is a translation");
ok(IkiWiki::Plugin::po::istranslation('index.fr'), "index.fr is a translation");
+ok(IkiWiki::Plugin::po::istranslation('index.es'), "index.es is a translation");
+ok(IkiWiki::Plugin::po::istranslation('index.es'), "index.es is a translation");
ok(IkiWiki::Plugin::po::istranslatable('test2'), "test2 is translatable");
ok(IkiWiki::Plugin::po::istranslatable('test2'), "test2 is translatable");
ok(! IkiWiki::Plugin::po::istranslation('test2'), "test2 is not a translation");
@@ -76,6 +88,31 @@ ok(! IkiWiki::Plugin::po::istranslatable('test3'), "test3 is not translatable");
ok(! IkiWiki::Plugin::po::istranslation('test3'), "test3 is not a translation");
ok(! IkiWiki::Plugin::po::istranslation('test3'), "test3 is not a translation");
+### links
+writefile('index.mdwn', $config{srcdir}, '[[translatable]] [[nontranslatable]]');
+writefile('translatable.mdwn', $config{srcdir}, '[[nontranslatable]]');
+writefile('nontranslatable.mdwn', $config{srcdir}, '[[/]] [[translatable]]');
+map IkiWiki::Plugin::po::refreshpot(srcfile($_)), ('index.mdwn', 'translatable.mdwn');
+require IkiWiki::Render;
+foreach my $masterfile_rel ('index.mdwn', 'translatable.mdwn') {
+ my $masterfile=srcfile($masterfile_rel);
+ my @pofiles=IkiWiki::Plugin::po::pofiles($masterfile);
+ IkiWiki::Plugin::po::refreshpot($masterfile);
+ IkiWiki::Plugin::po::refreshpofiles($masterfile, @pofiles);
+ IkiWiki::scan($masterfile_rel);
+ map IkiWiki::scan(IkiWiki::abs2rel($_, $config{srcdir})), @pofiles;
+}
+IkiWiki::scan('nontranslatable.mdwn');
+use Data::Dumper;
+print Dumper(%links);
+is_deeply(\@{$links{'index'}}, ['translatable', 'nontranslatable'], 'index');
+is_deeply(\@{$links{'index.es'}}, ['translatable.es', 'nontranslatable'], 'index.es');
+is_deeply(\@{$links{'index.fr'}}, ['translatable.fr', 'nontranslatable'], 'index.fr');
+is_deeply(\@{$links{'translatable'}}, ['nontranslatable'], 'translatable');
+is_deeply(\@{$links{'translatable.es'}}, ['nontranslatable'], 'translatable.es');
+is_deeply(\@{$links{'translatable.fr'}}, ['nontranslatable'], 'translatable.fr');
+is_deeply(\@{$links{'nontranslatable'}}, ['/', 'translatable', 'translatable.fr', 'translatable.es'], 'nontranslatable');
+
### targetpage
$config{usedirs}=0;
$msgprefix="targetpage (usedirs=0)";