aboutsummaryrefslogtreecommitdiffstats
path: root/tests/findlang.pl
diff options
context:
space:
mode:
Diffstat (limited to 'tests/findlang.pl')
-rw-r--r--tests/findlang.pl34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/findlang.pl b/tests/findlang.pl
new file mode 100644
index 0000000..58dfa52
--- /dev/null
+++ b/tests/findlang.pl
@@ -0,0 +1,34 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More qw(no_plan);
+
+my $pwd = `pwd`;
+chomp($pwd);
+my $testarbo = "$pwd/find-lang-root";
+
+
+my %files = (
+ # file => [ lang, is_dir ]
+ '/usr/share/man/fr' => [ 'fr', 1 ],
+ '/usr/share/man/fr/man1' => [ 'fr', 1 ],
+ '/usr/share/man/fr/man1/lang.1.*' => [ 'fr', 0 ],
+);
+
+system("/usr/bin/perl find-lang.pl $testarbo lang --with-man") and die "can't run find-lang $@";
+
+open(my $h, '<', 'lang.lang') or die "can't open lang.lang";
+
+while (my $line = <$h>) {
+ chomp($line);
+ my ($file) = $line =~ / ([^ ]+)$/;
+ my ($lang) = $line =~ /%lang\(([^\)]+)\)/;
+ $lang ||= '';
+ my $dir = $line =~ /%dir/;
+ $dir ||= 0;
+ is($lang, $files{$file}[0], "lang is find");
+ is($dir, $files{$file}[1], "%dir is properly set if need");
+}
+