From: Ken Youens-Clark Date: Fri, 12 Mar 2004 01:48:49 +0000 (+0000) Subject: Used code found http://www.mail-archive.com/perl-documentation@perl.org/msg00380... X-Git-Tag: v0.06~133 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c401ac4b74e6cf42f6dae66961d7cb18c9e4fa0a;p=dbsrgits%2FSQL-Translator.git Used code found mail-archive.com/perl-documentation@perl.org/msg00380.html to fix reading of STDERR (?). --- diff --git a/t/31dumper.t b/t/31dumper.t index de39d5d..8c59d62 100644 --- a/t/31dumper.t +++ b/t/31dumper.t @@ -4,11 +4,14 @@ use strict; use Config; -use FindBin qw/$Bin/; -use Test::More; use File::Temp 'tempfile'; +use File::Spec; +use FindBin qw/$Bin/; +use IPC::Open3; use SQL::Translator; +use Test::More; use Test::SQL::Translator qw(maybe_plan); +use Symbol qw(gensym); BEGIN { maybe_plan( @@ -44,8 +47,12 @@ print $fh $output; close $fh or die "Can't close file '$filename': $!"; my $perl = $Config{'perlpath'}; -my $cmd = "$perl -cw $filename"; -my $res = `$cmd 2>&1`; +open( NULL, ">", File::Spec->devnull ); +my $pid = open3( gensym, ">&NULL", \*PH, "$perl -cw $filename" ); +my $res; +while( ) { $res .= $_; } +waitpid($pid, 0); + like( $res, qr/syntax OK/, 'Generated script syntax is OK' ); like( $output, qr{DBI->connect\(\s*'$dsn',\s*'$db_user',\s*'$db_pass',},