Jim Cromie wrote:

>Steve Hay wrote:
>  
>
>>Failures:
>>[default] -DDEBUGGING -DINST_TOP=$(INST_DRV)\Smoke\doesntexist -Duseithreads 
>>-Duselargefiles -Dusemymalloc
>>   ../ext/B/t/optree_specials.t............FAILED 2-6
>>    
>>
>
>Steve also sent me (off-list) the output from that failing test,
>which I summarize rather than paste.
>
>1. require-ok - always passes
>2. BEGIN - should render 3 BEGIN blocks, but only gives 2 on Steves box.
>3. END - no output/rendering
>4. CHECK - no output
>5. INIT - no output
>6. all of them. - no output.
>
>test 2 is the interesting result - that it gives output disproves
>the naive 'blame runperl' theory, since output is obtained at least once.
>
Well I still think it's something to do with runperl(), and specifically 
with using -e "..." one-liners in which the source code contains newlines.

Take a moment to look at the output of the following test program.

cmd2 and cmd4 are the sort of command-lines in question, the first with 
newlines in the -e "..." string, the second without.
cmd1 and cmd3 are the same but using -MO=Deparse instead of -MO=Concise 
to try to see what is being run.

=====
my $cmd1 = qq[.\\perl "-I..\\lib" -w -MO=Deparse -e "\n    our (\$beg, 
\$chk, \$init, \$end);\n    BEGIN { \$beg++ }\n    CHECK { \$chk++ 
}\n    INIT  { \$init++ }\n    END   { \$end++ }\n"  2>&1];

print "RUNNING:\n$cmd1\nOUTPUT:\n";
system $cmd1;

my $cmd2 = qq[.\\perl "-I..\\lib" -w -MO=Concise,BEGIN -e "\n    our 
(\$beg, \$chk, \$init, \$end);\n    BEGIN { \$beg++ }\n    CHECK { 
\$chk++ }\n    INIT  { \$init++ }\n    END   { \$end++ }\n"  2>&1];

print "RUNNING:\n$cmd2\nOUTPUT:\n";
system $cmd2;

my $cmd3 = qq[.\\perl "-I..\\lib" -w -MO=Deparse -e "our (\$beg, \$chk, 
\$init, \$end); BEGIN { \$beg++ } CHECK { \$chk++ } INIT  { \$init++ } 
END   { \$end++ }"  2>&1];

print "RUNNING:\n$cmd3\nOUTPUT:\n";
system $cmd3;

my $cmd4 = qq[.\\perl "-I..\\lib" -w -MO=Concise,BEGIN -e "our (\$beg, 
\$chk, \$init, \$end); BEGIN { \$beg++ } CHECK { \$chk++ } INIT  { 
\$init++ } END   { \$end++ }"  2>&1];

print "RUNNING:\n$cmd4\nOUTPUT:\n";
system $cmd4;
=====

Here's the output that I get on Win32:

=====
RUNNING:
.\perl "-I..\lib" -w -MO=Deparse -e "
    our ($beg, $chk, $init, $end);
    BEGIN { $beg++ }
    CHECK { $chk++ }
    INIT  { $init++ }
    END   { $end++ }
"  2>&1
OUTPUT:
BEGIN { $^W = 1; }
-e syntax OK
RUNNING:
.\perl "-I..\lib" -w -MO=Concise,BEGIN -e "
    our ($beg, $chk, $init, $end);
    BEGIN { $beg++ }
    CHECK { $chk++ }
    INIT  { $init++ }
    END   { $end++ }
"  2>&1
OUTPUT:
BEGIN 1:
b  <1> leavesub[1 ref] K/REFC,1 ->(end)
-     <@> lineseq KP ->b
1        <;> nextstate(B::Concise -242 Concise.pm:304) v/2 ->2
3        <1> require sK/1 ->4
2           <$> const[PV "strict.pm"] s/BARE ->3
4        <;> nextstate(B::Concise -242 Concise.pm:304) v/2 ->5
-        <@> lineseq K ->-
5           <;> nextstate(B::Concise -242 Concise.pm:304) /2 ->6
a           <1> entersub[t1] KS*/TARG,2 ->b
6              <0> pushmark s ->7
7              <$> const[PV "strict"] sM ->8
8              <$> const[PV "refs"] sM ->9
9              <$> method_named[PVIV 1520340202] ->a
BEGIN 2:
m  <1> leavesub[1 ref] K/REFC,1 ->(end)
-     <@> lineseq KP ->m
c        <;> nextstate(B::Concise -227 Concise.pm:327) v/2 ->d
e        <1> require sK/1 ->f
d           <$> const[PV "warnings.pm"] s/BARE ->e
f        <;> nextstate(B::Concise -227 Concise.pm:327) v/2 ->g
-        <@> lineseq K ->-
g           <;> nextstate(B::Concise -227 Concise.pm:327) /2 ->h
l           <1> entersub[t1] KS*/TARG,2 ->m
h              <0> pushmark s ->i
i              <$> const[PV "warnings"] sM ->j
j              <$> const[PV "qw"] sM ->k
k              <$> method_named[PVIV 1520340202] ->l
-e syntax OK
RUNNING:
.\perl "-I..\lib" -w -MO=Deparse -e "our ($beg, $chk, $init, $end); 
BEGIN { $beg++ } CHECK { $chk++ } INIT  { $init++ } END   { $end++ }"  2>&1
OUTPUT:
BEGIN { $^W = 1; }
our($beg, $chk, $init, $end);
sub BEGIN {
    $beg++;
}
sub CHECK {
    $chk++;
}
sub INIT {
    $init++;
}
sub END {
    $end++;
}
-e syntax OK
RUNNING:
.\perl "-I..\lib" -w -MO=Concise,BEGIN -e "our ($beg, $chk, $init, 
$end); BEGIN { $beg++ } CHECK { $chk++ } INIT  { $init++ } END   { 
$end++ }"  2>&1
OUTPUT:
BEGIN 1:
b  <1> leavesub[1 ref] K/REFC,1 ->(end)
-     <@> lineseq KP ->b
1        <;> nextstate(B::Concise -242 Concise.pm:304) v/2 ->2
3        <1> require sK/1 ->4
2           <$> const[PV "strict.pm"] s/BARE ->3
4        <;> nextstate(B::Concise -242 Concise.pm:304) v/2 ->5
-        <@> lineseq K ->-
5           <;> nextstate(B::Concise -242 Concise.pm:304) /2 ->6
a           <1> entersub[t1] KS*/TARG,2 ->b
6              <0> pushmark s ->7
7              <$> const[PV "strict"] sM ->8
8              <$> const[PV "refs"] sM ->9
9              <$> method_named[PVIV 1520340202] ->a
BEGIN 2:
m  <1> leavesub[1 ref] K/REFC,1 ->(end)
-     <@> lineseq KP ->m
c        <;> nextstate(B::Concise -227 Concise.pm:327) v/2 ->d
e        <1> require sK/1 ->f
d           <$> const[PV "warnings.pm"] s/BARE ->e
f        <;> nextstate(B::Concise -227 Concise.pm:327) v/2 ->g
-        <@> lineseq K ->-
g           <;> nextstate(B::Concise -227 Concise.pm:327) /2 ->h
l           <1> entersub[t1] KS*/TARG,2 ->m
h              <0> pushmark s ->i
i              <$> const[PV "warnings"] sM ->j
j              <$> const[PV "qw"] sM ->k
k              <$> method_named[PVIV 1520340202] ->l
BEGIN 3:
q  <1> leavesub[1 ref] K/REFC,1 ->(end)
-     <@> lineseq KP ->q
n        <;> nextstate(main 2 -e:1) v ->o
p        <1> postinc[t3] sK/1 ->q
-           <1> ex-rv2sv sKRM/1 ->p
o              <#> gvsv[*beg] s ->p
-e syntax OK
=====

So as you can see, cmd1 shows that -e "..." with newlines gets deparsed 
rather oddly to say the least; I'm not sure there isn't something wrong 
there too.  And when the -MO=Concise version is run (cmd2) we only get 
two BEGINs coming out (which is more than cmd1 suggested we'd get :-s).

But cmd3 shows that the version without newlines in the -e "..." is 
altogether happier, and indeed cmd4 produces the output that we expect.

In short, I don't think the fact that optree_specials.t test 2 gives 
some output disproves the theory that runperl() is at fault.  There is 
indeed some output, but it is wrong because the program actually being 
run by perl is not what it was intended to be due to problems handling 
that -e command-line.

I can think of three resolutions to this:

- use the patch that I posted the other day 
(http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2004-05/msg00362.html) 
to remove newlines from the -e prog;
- do what t/op/closure.t does and write the prog out to a temp file 
rather than using -e;
- fix runperl() to accept -e progs with newlines in them (maybe by 
having *it* do one of the above for you).

Steve



------------------------------------------------
Radan Computational Ltd.

The information contained in this message and any files transmitted with it are 
confidential and intended for the addressee(s) only.  If you have received this 
message in error or there are any problems, please notify the sender immediately.  The 
unauthorized use, disclosure, copying or alteration of this message is strictly 
forbidden.  Note that any views or opinions presented in this email are solely those 
of the author and do not necessarily represent those of Radan Computational Ltd.  The 
recipient(s) of this message should check it and any attached files for viruses: Radan 
Computational will accept no liability for any damage caused by any virus transmitted 
by this email.

Reply via email to