tests: skip numfmt grouping tests on some systems
authorPádraig Brady <P@draigBrady.com>
Fri, 8 Feb 2013 16:05:25 +0000 (16:05 +0000)
committerPádraig Brady <P@draigBrady.com>
Sun, 10 Feb 2013 05:04:09 +0000 (05:04 +0000)
* tests/misc/numfmt.pl: When the system locale grouping doesn't
match our expected format for grouping 1234 in the fr_FR locale,
reset the locale to 'C' so as to skip all locale tests.

tests/misc/numfmt.pl

index c542483..b46e4d5 100644 (file)
@@ -883,7 +883,21 @@ my @Locale_Tests =
              {ENV=>"LC_ALL=$locale"}],
 
   );
-push @Tests, @Locale_Tests if $locale ne "C";
+if ($locale ne 'C')
+  {
+    # Reset locale to 'C' if LOCALE_FR_UTF8 doesn't output as expected
+    # as determined by the separate printf program.
+    open(LOC_NUM, "LC_ALL=$locale printf \"%'d\" 1234|")
+      or die "Can't fork command: $!";
+    my $loc_num = <LOC_NUM>;
+    close(LOC_NUM) || die "Failed to read grouped number from printf";
+    if ($loc_num ne '1 234')
+      {
+        warn "skipping locale grouping tests as 1234 groups like $loc_num\n";
+        $locale = 'C';
+      }
+  }
+push @Tests, @Locale_Tests if $locale ne 'C';
 
 ## Check all valid/invalid suffixes
 foreach my $suf ( 'A' .. 'Z', 'a' .. 'z' ) {