aboutsummaryrefslogtreecommitdiffstats
path: root/tests/findlang.pl
blob: fa6dbaee2eb19875fe11ec469c326d1b2a7413ad (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
#!/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', 0 ],
    '/usr/share/locale/pt_BR' => [ 'pt_BR', 0 ],
    '/usr/share/gnome/help/lang/pt_BR' => [ 'pt_BR', 0 ],
    '/usr/share/gnome/help/lang/en_GB' => [ 'en_GB', 0 ],
    '/usr/share/gnome/help/lang' => [ '', 1 ],
);

system("/usr/bin/perl find-lang.pl $testarbo lang --with-man --with-gnome") 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);
    $line =~ /svn/ and next;
    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");
}