From 50a749afc844fba13ab8ab1a7d844e76b71c1ac9 Mon Sep 17 00:00:00 2001 From: brian d foy Date: Mon, 19 Jun 2023 06:41:12 -0400 Subject: [PATCH] Not using IPC::Open3 here --- t/bc/ipc-open3.t | 53 +++++++++++++----------------------------------- 1 file changed, 14 insertions(+), 39 deletions(-) diff --git a/t/bc/ipc-open3.t b/t/bc/ipc-open3.t index 749e7172..d1781166 100644 --- a/t/bc/ipc-open3.t +++ b/t/bc/ipc-open3.t @@ -4,7 +4,6 @@ use warnings; use lib qw(./t/lib); use Test::More; -use IPC::Open3 (); use Symbol (); use FileHandle; use Time::HiRes qw(usleep); @@ -12,7 +11,7 @@ use IO::Select; my $program = 'bin/bc'; -foreach my $table ( operator_table(), precedence_table(), special_expr_table(), statement_table() ) { +foreach my $table ( special_expr_table() ) {# operator_table(), precedence_table(), special_expr_table(), statement_table() ) { my $label = shift @$table; subtest $label => sub { foreach my $tuple ( @$table ) { @@ -26,47 +25,23 @@ sub run_bc { # https://www.perlmonks.org/?node_id=419919 my( $input ) = @_; - my $child_in = Symbol::gensym(); - # https://github.com/perl/perl5/issues/14533 - if ($^O eq 'MSWin32') { - no strict 'subs'; - require Win32API::File; - Win32API::File->import( qw(:Func :HANDLE_FLAG_) ); - my $wh = FdGetOsFHandle(fileno $child_in); - SetHandleInformation($wh, HANDLE_FLAG_INHERIT(), 0); - die "Can't turn off HANDLE_FLAG_INHERIT: $@"; - } - - my $pid = IPC::Open3::open3( - $child_in, - my $child_out, - my $child_err = Symbol::gensym(), - $^X, $program, '-' - ); - - my $select_out = IO::Select->new($child_out); - my $select_err = IO::Select->new($child_err); + my $class = require './bin/bc'; + print "Class is <$class>\n"; - my %hash; - foreach my $line ( split /\n/, $input ) { - print {$child_in} $line, "\n"; + chomp($input); $input .= "\n"; - # give the child process a chance to work, otherwise we - # will check its filehandles too soon. - select(undef,undef,undef,0.4); + my %hash = ( input => $input ); + print STDERR Dumper(\%hash); use Data::Dumper; + open $PerlPowerTools::bc::INPUT_FH, '>', \ $hash{info}; + open $PerlPowerTools::bc::ERROR_FH, '>', \ $hash{error}; + open $PerlPowerTools::bc::DEBUG_FH, '>', \ $hash{debug}; + open $PerlPowerTools::bc::VALUE_FH, '>', \ $hash{value}; - if( $select_err->can_read(0.1) ) { - sysread $child_err, my $error, 4096; - $hash{error} .= $error; - } - if( $select_out->can_read(0.1) ) { - sysread $child_out, my $output, 4096; - $hash{output} .= $output; - } - } + print "About to run\n"; + eval { $class->run('-d', '-') }; + print "Already ran\n"; - close $child_in; - waitpid $pid, 1; + print STDERR Dumper(\%hash); use Data::Dumper; return \%hash; }