develooper Front page | perl.perl5.porters | Postings from February 2011

Re: First pass at Test::PerlRun

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
February 5, 2011 06:09
Subject:
Re: First pass at Test::PerlRun
Message ID:
20110205140915.GT24189@plum.flirble.org
On Thu, Feb 03, 2011 at 09:18:52AM -0600, Dave Rolsky wrote:
> On Wed, 2 Feb 2011, Nicholas Clark wrote:
> 
> >You've provided more *_is() and *_like functions than test.pl - is this a 
> >good
> >thing?
> 
> I think so. One of the benefits of moving code out of lib/ext should be 
> that we can write nicer test code.

Seems reasonable.

> >Also, dist/threads/t/exit.t wants to run something and both test the error
> >status and stdout - would it be viable to create a public perlrun() (or
> >somesuch) function which returns stdout, stderr and exit status [the latter
> >with the unfortunate hack that perlrun_exit_status_is() uses, until such
> >time as we can encourage IPC::Cmd to provide it cleanly]
> 
> I've added this.

Thanks.

> >As I think Jesse said on IRC, I also feel that the code from which_perl()
> >should have copyright attribution. git blame log says that it's
> >Schwern, Jarkko, Craig Berry, Paul Green, and me.
> 
> Done.
> 
> I've attached a new tarball.

Houston, we have a problem.

Specifically, it seems that IPC::Cmd::run doesn't support capturing buffers
on Win32 unless using IPC::Run. As IPC::Run isn't in the core, it's falling
back on IPC::Open3, which can do it on Unix, but not Win32. (No, I don't
fully know why this is, but there's a comment in IPC::Run:

    helper processes
        IPC::Run uses helper processes, one per redirected file, to adapt
        between the anonymous pipe connected to the child and the TCP socket
        connected to the parent. This is a waste of resources and will
        change in the future to either use threads (instead of helper
        processes) or a WaitForMultipleObjects call (instead of select).
        Please contact me if you can help with the WaitForMultipleObjects()
        approach; I haven't figured out how to get at it without C code.

Your code is using capturing buffers. I don't really understand all of this,
but I think that IPC::Open3 and temporary files would be portable with the
modules in core. (Or only do temporary files on Win32, assuming that VMS is
sane)

I pushed a branch with your code as smoke-me/runperl, and George Greer's
Win32 smoker ran it. The logs (14M, so probably not worth downloading)

http://m-l.org/~perl/smoke/perl/win32/smoke-me/Nicholas%20Clark/log15e44c8d2976def00cb94784d75922be26f0234c.log

show

../cpan/Test-Harness/t/source_tests/source.t ...................... ok
Could not find or check module 'IPC::Run' [THIS MAY BE A PROBLEM!] at ../../lib/IPC/Cmd.pm line 126
Can't use an undefined value as an ARRAY reference at ../../lib/Test/PerlRun.pm line 108.
../cpan/Test-PerlRun/t/PerlRun.t .................................. 
Dubious, test returned 25 (wstat 6400, 0x1900)
No subtests run 

Line 108 is @{$stderr} here:

    return (
        ( join q{}, @{$stdout} ),
        ( join q{}, @{$stderr} ),
        $err
    );

Nicholas Clark

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About