~ubuntu-branches/ubuntu/natty/liblocale-gettext-perl/natty

« back to all changes in this revision

Viewing changes to test_data/gen_test_data.pl

  • Committer: Bazaar Package Importer
  • Author(s): Raphael Hertzog
  • Date: 2005-06-22 14:29:20 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050622142920-rksd3kezrzi5y6mn
Tags: 1.05-1
* New upstream release
* Conforms to policy 3.6.2.
* Move ${perl:Depends} to Pre-Depends instead of Depends to avoid duplicate
  dependency. Fixes a lintian warning.

Show diffs side-by-side

added added

removed removed

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