File Coverage

test_data/gen_test_data.pl
Criterion Covered Total %
statement 16 29 55.1
branch 7 20 35.0
condition n/a
subroutine 2 3 66.6
pod n/a
total 25 52 48.0


line stmt bran cond sub pod time code
1 3     3   1693 use strict;
  3         7  
  3         886  
2              
3             sub gen {
4 3     3   13 my ($domain) = @_;
5              
6 3         5 my $messages;
7 3 50       374397 unless (open(LOCALE, "locale|")) {
8 0         0 doskip();
9             }
10 3         31496 while () {
11 24 100       198 if (/^LC_MESSAGES=\"(.*)\"$/) {
    50          
12 3         48 $messages = $1;
13 3         14 last;
14             } elsif (/^LC_MESSAGES=(.*)$/) {
15 0         0 $messages = $1;
16             }
17             }
18 3         275 close LOCALE;
19 3 50       31 if ($? != 0) {
20 0         0 doskip();
21             }
22              
23 3 50       28 if ($messages eq 'C') {
24 0         0 skip("cannot run test in the C locale", 0);
25 0         0 exit 0;
26             }
27 3 50       17 if ($messages eq 'POSIX') {
28 3         72 skip("cannot run test in the POSIX locale", 0);
29 3         1301 exit 0;
30             }
31              
32 0 0         mkdir "test_data/" . $messages, 0755 unless (-d "test_data/" . $messages);
33 0 0         mkdir "test_data/" . $messages . "/LC_MESSAGES", 0755
34             unless (-d "test_data/" . $messages . "/LC_MESSAGES");
35 0 0         unless (-r ("test_data/" . $messages . "/LC_MESSAGES/" . $domain . ".mo")) {
36 0           system "msgfmt", "-o", "test_data/" . $messages . "/LC_MESSAGES/" .
37             $domain . ".mo",
38             "test_data/" . $domain . ".po";
39 0 0         if ($? != 0) {
40 0           doskip();
41             }
42             }
43             }
44              
45             sub doskip {
46 0     0     skip("could not generate test data, skipping test", 0);
47 0           exit 0;
48             }
49              
50             1;