Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

t/op/stat.t fails under Czech locale #12154

Closed
p5pRT opened this issue Jun 3, 2012 · 9 comments
Closed

t/op/stat.t fails under Czech locale #12154

p5pRT opened this issue Jun 3, 2012 · 9 comments

Comments

@p5pRT
Copy link

p5pRT commented Jun 3, 2012

Migrated from rt.perl.org#113472 (status was 'resolved')

Searchable as RT113472$

@p5pRT
Copy link
Author

p5pRT commented Jun 3, 2012

From @Corion

Hello Porters,

http​://perlmonks.org/?node=973257 contains a bugreport and bugfix by
mrthom for testing Perl on Czech locales.

The (tested?) fix invokes `tail +2`. Is that sane to assume for the tests?

The alternative would be to munge the results in Perl, removing the top
line unconditionally in the hope that the output of `ls -`l` always
contains the locale-equivalent of

  total 666

as its first line. I've attached the patch below [1] (instead of
applying it), as I'm not sure whether Perl shouldn't try instead to
clean out all locale settings and run its tests under locale "C" to
avoid such issues. The alternative would be to force the C locale, as
hinted at
in http​://perlmonks.org/?node=973418 and also used in t/op/exec.t and
t/op/groups.t [2]

  $ENV{LC_ALL} = 'C';

I can't test either, as I cannot replicate the environment.

If this patch goes in, I also nominate it for backporting into 5.16.1 ,
or at least a note to be made in the "Known Issues" about the locale.

-max

[1] 0001-Don-t-test-first-line-of-ls-l-output.patch
[2] 0001-Force-external-tools-to-speak-English.patch

@p5pRT
Copy link
Author

p5pRT commented Jun 3, 2012

From @Corion

0001-Don-t-test-first-line-of-ls-l-output.patch
From 0971c5c440700440cf1f5a0a02e730046e9325ba Mon Sep 17 00:00:00 2001
From: Max Maischein <corion@corion.net>
Date: Sun, 3 Jun 2012 12:06:11 +0200
Subject: [PATCH] Don't test first line of `ls -l` output

This fixes t/op/stat.t failing under Czech locale due to misparsing
    celkem 0
as a character device.

Reported by mrthom via http://perlmonks.org/?node=973257
---
 t/op/stat.t |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/t/op/stat.t b/t/op/stat.t
index af1fa5e..94cad29 100644
--- a/t/op/stat.t
+++ b/t/op/stat.t
@@ -250,7 +250,7 @@ SKIP: {
       if $Is_VMS;
 
     my $LS  = $Config{d_readlink} ? "ls -lL" : "ls -l";
-    my $CMD = "$LS /dev 2>/dev/null";
+    my $CMD = "$LS /dev 2>/dev/null | tail -n +2";
     my $DEV = qx($CMD);
 
     skip "$CMD failed", 6 if $DEV eq '';
-- 
1.6.5.1.1367.gcd48

@p5pRT
Copy link
Author

p5pRT commented Jun 3, 2012

From @Corion

0001-Force-external-tools-to-speak-English.patch
From 89589d5e8909f9321a44c28484cfef518e7c22a7 Mon Sep 17 00:00:00 2001
From: Max Maischein <corion@corion.net>
Date: Sun, 3 Jun 2012 12:28:03 +0200
Subject: [PATCH] Force external tools to speak English

This fixes the build issue on a Czech locale reported in http://perlmonks.org/?node=973257
by trying to convince external tools to speak English.
---
 t/op/stat.t |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/t/op/stat.t b/t/op/stat.t
index af1fa5e..3b7a906 100644
--- a/t/op/stat.t
+++ b/t/op/stat.t
@@ -1,6 +1,8 @@
 #!./perl
 
 BEGIN {
+    $ENV{LC_ALL} = "C"; # so that external utilities speak English
+    $ENV{LANGUAGE} = 'C'; # GNU locale extension
     chdir 't' if -d 't';
     @INC = '../lib';
     require './test.pl';	# for which_perl() etc
-- 
1.6.5.1.1367.gcd48

@p5pRT
Copy link
Author

p5pRT commented Jun 3, 2012

From @nwc10

On Sun, Jun 03, 2012 at 03​:30​:16AM -0700, Max Maischein wrote​:

The (tested?) fix invokes `tail +2`. Is that sane to assume for the tests?

It seems so, in that it worked on both the AIX and HP-UX machines I have
access to, so it doesn't seem to be a recent non-standard flag.

as its first line. I've attached the patch below [1] (instead of
applying it), as I'm not sure whether Perl shouldn't try instead to
clean out all locale settings and run its tests under locale "C" to
avoid such issues. The alternative would be to force the C locale, as
hinted at
in http​://perlmonks.org/?node=973418 and also used in t/op/exec.t and
t/op/groups.t [2]

 $ENV\{LC\_ALL\}   = 'C';

I can't test either, as I cannot replicate the environment.

I think it would be better to clean out the environment. It seems less
fragile, and it's how we're already dealing with this sort of problem.

Frustratingly, it seems that I can't test this *either*, as both the
systems that I have access to that have a Czech locale available show the
first line as "Total". (One being current Ubuntu - I'm surprised that they
aren't up to date)

Personally, I wouldn't put it in the BEGIN block, although I see that
t/op/groups.t does. (t/op/exec.t doesn't). I guess I have this gut feeling
that BEGIN blocks are special, and should only contain things that really
need to be done at begin time.

diff --git a/t/op/stat.t b/t/op/stat.t
index af1fa5e..3b7a906 100644
--- a/t/op/stat.t
+++ b/t/op/stat.t
@​@​ -1,6 +1,8 @​@​
#!./perl

BEGIN {
+ $ENV{LC_ALL} = "C"; # so that external utilities speak English
+ $ENV{LANGUAGE} = 'C'; # GNU locale extension
chdir 't' if -d 't';
@​INC = '../lib';
require './test.pl'; # for which_perl() etc
--
1.6.5.1.1367.gcd48

Nicholas Clark

@p5pRT
Copy link
Author

p5pRT commented Jun 3, 2012

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jun 3, 2012

From @Tux

On Sun, 3 Jun 2012 20​:49​:33 +0100, Nicholas Clark <nick@​ccl4.org> wrote​:

On Sun, Jun 03, 2012 at 03​:30​:16AM -0700, Max Maischein wrote​:

The (tested?) fix invokes `tail +2`. Is that sane to assume for the tests?

It seems so, in that it worked on both the AIX and HP-UX machines I have
access to, so it doesn't seem to be a recent non-standard flag.

Also works on HP-UX 10.20

as its first line. I've attached the patch below [1] (instead of
applying it), as I'm not sure whether Perl shouldn't try instead to
clean out all locale settings and run its tests under locale "C" to
avoid such issues. The alternative would be to force the C locale, as
hinted at
in http​://perlmonks.org/?node=973418 and also used in t/op/exec.t and
t/op/groups.t [2]

 $ENV\{LC\_ALL\}   = 'C';

I can't test either, as I cannot replicate the environment.

I think it would be better to clean out the environment. It seems less
fragile, and it's how we're already dealing with this sort of problem.

Frustratingly, it seems that I can't test this *either*, as both the
systems that I have access to that have a Czech locale available show the
first line as "Total". (One being current Ubuntu - I'm surprised that they
aren't up to date)

Personally, I wouldn't put it in the BEGIN block, although I see that
t/op/groups.t does. (t/op/exec.t doesn't). I guess I have this gut feeling
that BEGIN blocks are special, and should only contain things that really
need to be done at begin time.

diff --git a/t/op/stat.t b/t/op/stat.t
index af1fa5e..3b7a906 100644
--- a/t/op/stat.t
+++ b/t/op/stat.t
@​@​ -1,6 +1,8 @​@​
#!./perl

BEGIN {
+ $ENV{LC_ALL} = "C"; # so that external utilities speak English
+ $ENV{LANGUAGE} = 'C'; # GNU locale extension
chdir 't' if -d 't';
@​INC = '../lib';
require './test.pl'; # for which_perl() etc

--
H.Merijn Brand http​://tux.nl Perl Monger http​://amsterdam.pm.org/
using perl5.00307 .. 5.14 porting perl5 on HP-UX, AIX, and openSUSE
http​://mirrors.develooper.com/hpux/ http​://www.test-smoke.org/
http​://qa.perl.org http​://www.goldmark.org/jeff/stupid-disclaimers/

@p5pRT
Copy link
Author

p5pRT commented Jun 3, 2012

From @dmcbride

On Sunday June 3 2012 9​:59​:53 PM H.Merijn Brand wrote​:

On Sun, 3 Jun 2012 20​:49​:33 +0100, Nicholas Clark <nick@​ccl4.org> wrote​:

On Sun, Jun 03, 2012 at 03​:30​:16AM -0700, Max Maischein wrote​:

The (tested?) fix invokes `tail +2`. Is that sane to assume for the
tests?

It seems so, in that it worked on both the AIX and HP-UX machines I have
access to, so it doesn't seem to be a recent non-standard flag.

Also works on HP-UX 10.20

I recall having to move from "tail <num>" to "tail -n <num>" a number of years
ago when some Linux distros decided to use a version of tail that gave a
warning about the former. This should also work on AIX, Sun, HP, and Linux.

@p5pRT
Copy link
Author

p5pRT commented Jun 26, 2012

From @nwc10

On Sun Jun 03 12​:50​:09 2012, nicholas wrote​:

On Sun, Jun 03, 2012 at 03​:30​:16AM -0700, Max Maischein wrote​:

I can't test either, as I cannot replicate the environment.

Frustratingly, it seems that I can't test this *either*, as both the
systems that I have access to that have a Czech locale available show the
first line as "Total". (One being current Ubuntu - I'm surprised that they
aren't up to date)

I now have access to a machine with Wheezy, and can replicate it.
Fixed in d4046c4

Nicholas Clark

@p5pRT
Copy link
Author

p5pRT commented Jun 26, 2012

@nwc10 - Status changed from 'open' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant