This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
t/run/locale.t: Skip some tests for some shells
authorKarl Williamson <khw@cpan.org>
Tue, 13 May 2014 23:31:39 +0000 (17:31 -0600)
committerKarl Williamson <khw@cpan.org>
Fri, 30 May 2014 01:28:40 +0000 (19:28 -0600)
Some sh programs don't accept changes of environment variables like
LC_ALL to invalid values.  For these the tests aren't testing what they
think they are, so change them to just return the expected value, so
they will pass.  This effectively skips the tests when run on these
shells.  See http://nntp.perl.org/group/perl.perl5.porters/214503

t/run/locale.t

index 097563f..0c58a63 100644 (file)
@@ -215,12 +215,17 @@ EOF
             local $ENV{LANG} = $different;
 
             # Can't turn off the warnings, so send them to /dev/null
-            fresh_perl_is(<<'EOF', "$difference", { stderr => "devnull" },
+            fresh_perl_is(<<"EOF", "$difference", { stderr => "devnull" },
+                if (\$ENV{LC_ALL} ne "invalid") {
+                    # Make the test pass if the sh didn't accept the ENV set
+                    print "$difference\n";
+                    exit 0;
+                }
                 use locale;
                 use POSIX qw(locale_h);
                 setlocale(LC_NUMERIC, "");
-                my $in = 4.2;
-                printf("%g", $in);
+                my \$in = 4.2;
+                printf("%g", \$in);
 EOF
             "LANG is used if LC_ALL, LC_NUMERIC are invalid");
         }
@@ -237,12 +242,16 @@ EOF
                     local $ENV{LANG} = "invalid";
 
                     # Can't turn off the warnings, so send them to /dev/null
-                    fresh_perl_is(<<'EOF', 4.2, { stderr => "devnull" },
+                    fresh_perl_is(<<"EOF", 4.2, { stderr => "devnull" },
+                        if (\$ENV{LC_ALL} ne "invalid") {
+                            print "$difference\n";
+                            exit 0;
+                        }
                         use locale;
                         use POSIX qw(locale_h);
                         setlocale(LC_NUMERIC, "");
-                        my $in = 4.2;
-                        printf("%g", $in);
+                        my \$in = 4.2;
+                        printf("%g", \$in);
 EOF
                     'C locale is used if LC_ALL, LC_NUMERIC, LANG are invalid');
                 }