Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.98k stars 559 forks source link

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

Closed p5pRT closed 12 years ago

p5pRT commented 12 years ago

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

Searchable as RT113472$

p5pRT commented 12 years ago

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 commented 12 years ago

From @Corion

0001-Don-t-test-first-line-of-ls-l-output.patch ```diff From 0971c5c440700440cf1f5a0a02e730046e9325ba Mon Sep 17 00:00:00 2001 From: Max Maischein 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 commented 12 years ago

From @Corion

0001-Force-external-tools-to-speak-English.patch ```diff From 89589d5e8909f9321a44c28484cfef518e7c22a7 Mon Sep 17 00:00:00 2001 From: Max Maischein 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 commented 12 years ago

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 commented 12 years ago

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

p5pRT commented 12 years ago

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 commented 12 years ago

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 \" to "tail -n \" 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 commented 12 years ago

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 d4046c4813b1f4af

Nicholas Clark

p5pRT commented 12 years ago

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