From: Jarkko Hietaniemi Date: Wed, 30 May 2001 22:52:41 +0000 (+0000) Subject: [PATCH perl.c t/run/runenv.t] (was Re: [[ID 20010514.042] Perl v5.6.1 mangles PERL5OPT]) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=659ca9ea8f57ee52a52802839584b7208ad161b7;p=p5sagit%2Fp5-mst-13.2.git [PATCH perl.c t/run/runenv.t] (was Re: [[ID 20010514.042] Perl v5.6.1 mangles PERL5OPT]) From: Michael G Schwern Date: Wed, 30 May 2001 17:10:38 +0100 Message-ID: <20010530171038.L670@blackrider.blackstar.co.uk> Subject: Re: [PATCH perl.c t/run/runenv.t] (was Re: [ID 20010514.042] Perl v5.6.1 mangles PERL5OPT]) From: Abhijit Menon-Sen Date: Wed, 30 May 2001 23:16:13 +0530 Message-ID: <20010530231613.A31933@lustre.linux.in> p4raw-id: //depot/perl@10334 --- diff --git a/perl.c b/perl.c index 11dfd2b..63c2744 100644 --- a/perl.c +++ b/perl.c @@ -965,7 +965,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) AV* comppadlist; register SV *sv; register char *s; - char *cddir = Nullch; + char *popts, *cddir = Nullch; sv_setpvn(PL_linestr,"",0); sv = newSVpvn("",0); /* first used for -I flags */ @@ -1190,8 +1190,9 @@ print \" \\@INC:\\n @INC\\n\";"); #ifndef SECURE_INTERNAL_GETENV !PL_tainting && #endif - (s = PerlEnv_getenv("PERL5OPT"))) + (popts = PerlEnv_getenv("PERL5OPT"))) { + s = savepv(popts); while (isSPACE(*s)) s++; if (*s == '-' && *(s+1) == 'T') diff --git a/t/run/runenv.t b/t/run/runenv.t index a59ad26..55c48f0 100644 --- a/t/run/runenv.t +++ b/t/run/runenv.t @@ -14,13 +14,15 @@ BEGIN { } } +use Test; + +plan tests => 10; + my $STDOUT = './results-0'; my $STDERR = './results-1'; my $PERL = './perl'; my $FAILURE_CODE = 119; -print "1..9\n"; - # Run perl with specified environment and arguments returns a list. # First element is true iff Perl's stdout and stderr match the # supplied $stdout and $stderr argument strings exactly. @@ -70,14 +72,9 @@ sub it_didnt_work { } sub try { - my $testno = shift; my ($success, $reason) = runperl(@_); - if ($success) { - print "ok $testno\n"; - } else { - $reason =~ s/\n/\\n/g; - print "not ok $testno # $reason\n"; - } + $reason =~ s/\n/\\n/g if defined $reason; + ok( !!$success, 1, $reason ); } # PERL5OPT Command-line options (switches). Switches in @@ -90,25 +87,24 @@ sub try { # -T, tainting will be enabled, and any # subsequent options ignored. -my $T = 1; -try($T++, {PERL5OPT => '-w'}, ['-e', 'print $::x'], +try({PERL5OPT => '-w'}, ['-e', 'print $::x'], "", qq{Name "main::x" used only once: possible typo at -e line 1.\nUse of uninitialized value in print at -e line 1.\n}); -try($T++, {PERL5OPT => '-Mstrict'}, ['-e', 'print $::x'], +try({PERL5OPT => '-Mstrict'}, ['-e', 'print $::x'], "", ""); -try($T++, {PERL5OPT => '-Mstrict'}, ['-e', 'print $x'], +try({PERL5OPT => '-Mstrict'}, ['-e', 'print $x'], "", qq{Global symbol "\$x" requires explicit package name at -e line 1.\nExecution of -e aborted due to compilation errors.\n}); # Fails in 5.6.0 -try($T++, {PERL5OPT => '-Mstrict -w'}, ['-e', 'print $x'], +try({PERL5OPT => '-Mstrict -w'}, ['-e', 'print $x'], "", qq{Global symbol "\$x" requires explicit package name at -e line 1.\nExecution of -e aborted due to compilation errors.\n}); # Fails in 5.6.0 -try($T++, {PERL5OPT => '-w -Mstrict'}, ['-e', 'print $::x'], +try({PERL5OPT => '-w -Mstrict'}, ['-e', 'print $::x'], "", < '-w -Mstrict'}, ['-e', 'print $::x'], +try({PERL5OPT => '-w -Mstrict'}, ['-e', 'print $::x'], "", < '-MExporter'}, ['-e0'], +try({PERL5OPT => '-MExporter'}, ['-e0'], "", ""); # Fails in 5.6.0 -try($T++, {PERL5OPT => '-MExporter -MExporter'}, ['-e0'], +try({PERL5OPT => '-MExporter -MExporter'}, ['-e0'], "", ""); -try($T++, {PERL5OPT => '-Mstrict -Mwarnings'}, +try({PERL5OPT => '-Mstrict -Mwarnings'}, ['-e', 'print "ok" if $INC{"strict.pm"} and $INC{"warnings.pm"}'], "ok", ""); -print "# ", $T-1, " tests total.\n"; +try({PERL5OPT => '-w -w'}, + ['-e', 'print $ENV{PERL5OPT}'], + '-w -w', + ''); END { 1 while unlink $STDOUT;