Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests, Appveyor, Solve the problem of hanging Appveyor tests. #67

Merged
merged 9 commits into from
Oct 28, 2016
7 changes: 4 additions & 3 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use strict;
use warnings;
our $VERSION = 0.004_100;
our $VERSION = 0.004_500;
use ExtUtils::MakeMaker;

BEGIN { use English; }
Expand All @@ -22,7 +22,7 @@ WriteMakefile(
PREREQ_PM => {
# RPERL USER DEPENDENCIES
'ExtUtils::MakeMaker' => 7.04, # for compatibility with Inline::C >= v0.75
'Test::Exception' => 0.32,
'Test::Exception' => 0.43, # 0.43 needed because Appveyor testing required it
'Test::CPAN::Changes' => 0.400002,
'Test::Number::Delta' => 1.06, # for compatibility with Perls compiled using -Duselongdouble
'Perl::Critic' => 1.121,
Expand All @@ -46,7 +46,8 @@ WriteMakefile(
'App::Pod2CpanHtml' => 0.04, # Learning RPerl; used by pod2rperlhtml.pl, provides pod2cpanhtml
'Date::Format' => 2.24, # Learning RPerl; used by pod2rperlhtml.pl
'Pod::PseudoPod' => 0.18, # Learning RPerl; provides ppodchecker, ppod2txt, ppod2html, ppod2docbook
'Text::ASCIITable' => 0.20 # Learning RPerl; used by pod2text & ppod2txt
'Text::ASCIITable' => 0.20, # Learning RPerl; used by pod2text & ppod2txt
'IPC::Run3' => 0.048 # RPerl Compiler; used for internals (subcompile, testing)
},
META_MERGE => {
'meta-spec' => {
Expand Down
73 changes: 40 additions & 33 deletions lib/RPerl/Compiler.pm
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ use List::MoreUtils qw(uniq);
use File::Spec;
use Config;
use Config qw(config_re);
use IPC::Open3;
use IO::Select;
#use IPC::Open3; ## 93r
#use IO::Select; ## 93r
use IPC::Run3 qw(run3);
use Cwd;
use File::Copy; # for move()

Expand Down Expand Up @@ -1223,25 +1224,29 @@ our void $cpp_to_openmp_cpp = sub {
RPerl::diag( 'in Compiler::cpp_to_openmp_cpp(), have $polycc_command =' . "\n\n" . $polycc_command . "\n" );

# ACTUALLY RUN POLYCC COMMAND
my $pid = open3( 0, \*POLYCC_STDOUT, \*POLYCC_STDERR, $polycc_command ); # disable STDIN w/ 0

my $stdout_select;
my $stderr_select;
if ( $OSNAME ne 'MSWin32' ) {
$stdout_select = IO::Select->new();
$stderr_select = IO::Select->new();
$stdout_select->add( \*POLYCC_STDOUT );
$stderr_select->add( \*POLYCC_STDERR );
}
# my $pid = open3( 0, \*POLYCC_STDOUT, \*POLYCC_STDERR, $polycc_command ); # disable STDIN w/ 0
#
# my $stdout_select;
# my $stderr_select;
# if ( $OSNAME ne 'MSWin32' ) {
# $stdout_select = IO::Select->new();
# $stderr_select = IO::Select->new();
# $stdout_select->add( \*POLYCC_STDOUT );
# $stderr_select->add( \*POLYCC_STDERR );
# }
#

my string $polycc_command_stdout = q{};
my string $polycc_command_stderr = q{};

if ( $OSNAME eq 'MSWin32' || $stdout_select->can_read(0) ) { sysread POLYCC_STDOUT, $polycc_command_stdout, 4096; }
if ( $OSNAME eq 'MSWin32' || $stderr_select->can_read(0) ) { sysread POLYCC_STDERR, $polycc_command_stderr, 4096; }
waitpid $pid, 0;
if ( $OSNAME eq 'MSWin32' || $stdout_select->can_read(0) ) { my $s; sysread POLYCC_STDOUT, $s, 4096; $polycc_command_stdout .= $s; }
if ( $OSNAME eq 'MSWin32' || $stderr_select->can_read(0) ) { my $s; sysread POLYCC_STDERR, $s, 4096; $polycc_command_stderr .= $s; }
#if ( $OSNAME eq 'MSWin32' || $stdout_select->can_read(0) ) { sysread POLYCC_STDOUT, $polycc_command_stdout, 4096; }
# if ( $OSNAME eq 'MSWin32' || $stderr_select->can_read(0) ) { sysread POLYCC_STDERR, $polycc_command_stderr, 4096; }
# waitpid $pid, 0;
# if ( $OSNAME eq 'MSWin32' || $stdout_select->can_read(0) ) { my $s; sysread POLYCC_STDOUT, $s, 4096; $polycc_command_stdout .= $s; }
# if ( $OSNAME eq 'MSWin32' || $stderr_select->can_read(0) ) { my $s; sysread POLYCC_STDERR, $s, 4096; $polycc_command_stderr .= $s; }

#my $pid = open3( 0, \*POLYCC_STDOUT, \*POLYCC_STDERR, $polycc_command ); # disable STDIN w/ 0
run3( $polycc_command, \undef, \$polycc_command_stdout, \$polycc_command_stderr );

my $test_exit_status = $CHILD_ERROR >> 8;

Expand Down Expand Up @@ -1443,29 +1448,31 @@ our void $cpp_to_xsbinary__subcompile = sub {
if ( $OSNAME eq 'MSWin32' ) { $subcompile_command .= q{ } . ' > nul'; }
else { $subcompile_command .= q{ } . ' > /dev/null'; }
}
# my $pid = open3( 0, \*SUBCOMPILE_STDOUT, \*SUBCOMPILE_STDERR, $subcompile_command ); # disable STDIN w/ 0
#
# my $stdout_select;
# my $stderr_select;
# if ( $OSNAME ne 'MSWin32' ) {
# $stdout_select = IO::Select->new();
# $stderr_select = IO::Select->new();
# $stdout_select->add( \*SUBCOMPILE_STDOUT );
# $stderr_select->add( \*SUBCOMPILE_STDERR );
# }
#

RPerl::diag( 'in Compiler::cpp_to_xsbinary__subcompile(), have $subcompile_command =' . "\n\n" . $subcompile_command . "\n" );
# if ( $OSNAME eq 'MSWin32' || $stdout_select->can_read(0) ) { sysread SUBCOMPILE_STDOUT, $subcompile_command_stdout, 4096; }
# if ( $OSNAME eq 'MSWin32' || $stderr_select->can_read(0) ) { sysread SUBCOMPILE_STDERR, $subcompile_command_stderr, 4096; }
# waitpid $pid, 0;
# if ( $OSNAME eq 'MSWin32' || $stdout_select->can_read(0) ) { my $s; sysread SUBCOMPILE_STDOUT, $s, 4096; $subcompile_command_stdout .= $s; }
# if ( $OSNAME eq 'MSWin32' || $stderr_select->can_read(0) ) { my $s; sysread SUBCOMPILE_STDERR, $s, 4096; $subcompile_command_stderr .= $s; }

# ACTUALLY RUN SUBCOMPILE COMMAND
my $pid = open3( 0, \*SUBCOMPILE_STDOUT, \*SUBCOMPILE_STDERR, $subcompile_command ); # disable STDIN w/ 0

my $stdout_select;
my $stderr_select;
if ( $OSNAME ne 'MSWin32' ) {
$stdout_select = IO::Select->new();
$stderr_select = IO::Select->new();
$stdout_select->add( \*SUBCOMPILE_STDOUT );
$stderr_select->add( \*SUBCOMPILE_STDERR );
}

my string $subcompile_command_stdout = q{};
my string $subcompile_command_stderr = q{};

if ( $OSNAME eq 'MSWin32' || $stdout_select->can_read(0) ) { sysread SUBCOMPILE_STDOUT, $subcompile_command_stdout, 4096; }
if ( $OSNAME eq 'MSWin32' || $stderr_select->can_read(0) ) { sysread SUBCOMPILE_STDERR, $subcompile_command_stderr, 4096; }
waitpid $pid, 0;
if ( $OSNAME eq 'MSWin32' || $stdout_select->can_read(0) ) { my $s; sysread SUBCOMPILE_STDOUT, $s, 4096; $subcompile_command_stdout .= $s; }
if ( $OSNAME eq 'MSWin32' || $stderr_select->can_read(0) ) { my $s; sysread SUBCOMPILE_STDERR, $s, 4096; $subcompile_command_stderr .= $s; }
#my $pid = open3( 0, \*SUBCOMPILE_STDOUT, \*SUBCOMPILE_STDERR, $subcompile_command ); # disable STDIN w/ 0
run3( $subcompile_command, \undef, \$subcompile_command_stdout, \$subcompile_command_stderr );

my $test_exit_status = $CHILD_ERROR >> 8;

Expand Down
116 changes: 61 additions & 55 deletions t/09_interpret_execute.t
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ use RPerl::Compiler;
use Test::More;
use Test::Exception;
use File::Find qw(find);
use IPC::Open3;
use IO::Select;
#use IPC::Open3;
#use IO::Select;
use IPC::Run3 qw(run3);

# [[[ CONSTANTS ]]]
use constant PATH_TESTS => my string $TYPED_PATH_TESTS = $RPerl::INCLUDE_PATH . '/RPerl/Test';
Expand Down Expand Up @@ -135,77 +136,82 @@ foreach my $test_file ( sort keys %{$test_files} ) {
}

# RPerl::diag( 'in 09_interpret_execute.t, have $test_file = ' . $test_file . "\n" );
my $pid;
#my $pid;
my $stdout_generated = q{};
my $stderr_generated = q{};
if ( $RPerl::INCLUDE_PATH =~ /blib/ ) {
#$pid = open3( 0, \*STDOUT_TEST, \*STDERR_TEST, $test_file_execute_command ); # disable STDIN w/ 0
my string $test_file_execute_command = $EXECUTABLE_NAME . ' -Mblib=' . $RPerl::INCLUDE_PATH . ' ' . $test_file;
# RPerl::diag( 'in 09_interpret_execute.t, yes blib INCLUDE_PATH, have $test_file_execute_command = ' . $test_file_execute_command . "\n" );
# RPerl::diag( 'in 09_interpret_execute.t, yes blib INCLUDE_PATH, about to call open3()...' . "\n" );
$pid = open3( 0, \*STDOUT_TEST, \*STDERR_TEST, $test_file_execute_command ); # disable STDIN w/ 0
run3( $test_file_execute_command, \undef, \$stdout_generated, \$stderr_generated );
#$pid = open3( 0, \*STDOUT_TEST, \*STDERR_TEST, $test_file_execute_command ); # disable STDIN w/ 0
# RPerl::diag( 'in 09_interpret_execute.t, yes blib INCLUDE_PATH, returned from open3(), have $pid = ' . $pid . "\n" );
}
else {
my string $test_file_execute_command = $EXECUTABLE_NAME . ' -I' . $RPerl::INCLUDE_PATH . ' ' . $test_file;
# RPerl::diag( 'in 09_interpret_execute.t, not blib INCLUDE_PATH, have $test_file_execute_command = ' . $test_file_execute_command . "\n" );
# RPerl::diag( 'in 09_interpret_execute.t, not blib INCLUDE_PATH, about to call open3()...' . "\n" );
$pid = open3( 0, \*STDOUT_TEST, \*STDERR_TEST, $test_file_execute_command ); # disable STDIN w/ 0
# my $stdout_select;
# my $stderr_select;
# if ( $OSNAME ne 'MSWin32' ) {
## RPerl::diag( 'in 09_interpret_execute.t, no MSWin32, about to call IO::Select->new()...' . "\n" );
# $stdout_select = IO::Select->new();
# $stderr_select = IO::Select->new();
## RPerl::diag( 'in 09_interpret_execute.t, no MSWin32, about to call $stdout_select->add( \*STDOUT_TEST )...' . "\n" );
# $stdout_select->add( \*STDOUT_TEST );
# $stderr_select->add( \*STDERR_TEST );
## RPerl::diag( 'in 09_interpret_execute.t, no MSWin32, returned from $stdout_select->add( \*STDOUT_TEST )' . "\n" );
# }
#
# my $stdout_generated = q{};
# my $stderr_generated = q{};
#
run3( $test_file_execute_command, \undef, \$stdout_generated, \$stderr_generated );
#$pid = open3( 0, \*STDOUT_TEST, \*STDERR_TEST, $test_file_execute_command ); # disable STDIN w/ 0
# RPerl::diag( 'in 09_interpret_execute.t, not blib INCLUDE_PATH, returned from open3(), have $pid = ' . $pid . "\n" );
}

my $stdout_select;
my $stderr_select;
if ( $OSNAME ne 'MSWin32' ) {
# RPerl::diag( 'in 09_interpret_execute.t, no MSWin32, about to call IO::Select->new()...' . "\n" );
$stdout_select = IO::Select->new();
$stderr_select = IO::Select->new();
# RPerl::diag( 'in 09_interpret_execute.t, no MSWin32, about to call $stdout_select->add( \*STDOUT_TEST )...' . "\n" );
$stdout_select->add( \*STDOUT_TEST );
$stderr_select->add( \*STDERR_TEST );
# RPerl::diag( 'in 09_interpret_execute.t, no MSWin32, returned from $stdout_select->add( \*STDOUT_TEST )' . "\n" );
}

my $stdout_generated = q{};
my $stderr_generated = q{};

# DISABLED: no user input accepted
# while (1) {
# print "Enter input\n";
# chomp( my $stdin_received = <STDIN_TEST> );
# print STDIN_TEST "$stdin_received\n";

# select( undef, undef, undef, 0.1 ); # allow time for output to be generated; not needed with waitpid() before sysread() calls below

# if ( $stdout_select->can_read(0) ) { RPerl::diag('in 09_interpret_execute.t, can read STDOUT_TEST for $test_file = ' . $test_file . "\n"); }
# if ( $stderr_select->can_read(0) ) { RPerl::diag('in 09_interpret_execute.t, can read STDERR_TEST for $test_file = ' . $test_file . "\n"); }

if ( $OSNAME eq 'MSWin32' || $stdout_select->can_read(0) ) {
# RPerl::diag( 'in 09_interpret_execute.t, yes MSWin32 or $stdout_select->can_read(0), about to call sysread STDOUT_TEST...' . "\n" );
sysread STDOUT_TEST, $stdout_generated, 4096;
# RPerl::diag( 'in 09_interpret_execute.t, yes MSWin32 or $stdout_select->can_read(0), returned from sysread STDOUT_TEST, have $stdout_generated = ' . "\n" . '[BEGIN STDOUT]' . "\n" . $stdout_generated . '[END STDOUT]' . "\n" );
}
if ( $OSNAME eq 'MSWin32' || $stderr_select->can_read(0) ) {
# RPerl::diag( 'in 09_interpret_execute.t, yes MSWin32 or $stderr_select->can_read(0), about to call sysread STDERR_TEST...' . "\n" );
sysread STDERR_TEST, $stderr_generated, 4096;
# RPerl::diag( 'in 09_interpret_execute.t, yes MSWin32 or $stderr_select->can_read(0), returned from sysread STDERR_TEST, have $stderr_generated = ' . "\n" . '[BEGIN STDERR]' . "\n" . $stderr_generated . '[END STDERR]' . "\n" );
}

# RPerl::diag( 'in 09_interpret_execute.t, have $pid = ' . $pid . ', about to call waitpid...' . "\n" );
waitpid $pid, 0;
# RPerl::diag( 'in 09_interpret_execute.t, have $pid = ' . $pid . ', returned from waitpid...' . "\n" );

if ( $OSNAME eq 'MSWin32' || $stdout_select->can_read(0) ) {
# RPerl::diag( 'in 09_interpret_execute.t, yes MSWin32 or $stdout_select->can_read(0), about to call sysread STDOUT_TEST...' . "\n" );
my string $stdout_generated_continued;
sysread STDOUT_TEST, $stdout_generated_continued, 4096;
$stdout_generated .= $stdout_generated_continued;
# RPerl::diag( 'in 09_interpret_execute.t, yes MSWin32 or $stdout_select->can_read(0), returned from sysread STDOUT_TEST, have $stdout_generated_continued = ' . "\n" . '[BEGIN STDOUT]' . "\n" . $stdout_generated_continued . '[END STDOUT]' . "\n" );
}
if ( $OSNAME eq 'MSWin32' || $stderr_select->can_read(0) ) {
# RPerl::diag( 'in 09_interpret_execute.t, yes MSWin32 or $stderr_select->can_read(0), about to call sysread STDERR_TEST...' . "\n" );
my string $stderr_generated_continued;
sysread STDERR_TEST, $stderr_generated_continued, 4096;
$stderr_generated .= $stderr_generated_continued;
# RPerl::diag( 'in 09_interpret_execute.t, yes MSWin32 or $stderr_select->can_read(0), returned from sysread STDERR_TEST, have $stderr_generated_continued = ' . "\n" . '[BEGIN STDERR]' . "\n" . $stderr_generated_continued . '[END STDERR]' . "\n" );
}
# select( undef, undef, undef, 0.1 ); # allow time for output to be generated; not needed with waitpid() before sysread() calls below
#
# # if ( $stdout_select->can_read(0) ) { RPerl::diag('in 09_interpret_execute.t, can read STDOUT_TEST for $test_file = ' . $test_file . "\n"); }
# # if ( $stderr_select->can_read(0) ) { RPerl::diag('in 09_interpret_execute.t, can read STDERR_TEST for $test_file = ' . $test_file . "\n"); }
#
# if ( $OSNAME eq 'MSWin32' || $stdout_select->can_read(0) ) {
## RPerl::diag( 'in 09_interpret_execute.t, yes MSWin32 or $stdout_select->can_read(0), about to call sysread STDOUT_TEST...' . "\n" );
# sysread STDOUT_TEST, $stdout_generated, 4096;
## RPerl::diag( 'in 09_interpret_execute.t, yes MSWin32 or $stdout_select->can_read(0), returned from sysread STDOUT_TEST, have $stdout_generated = ' . "\n" . '[BEGIN STDOUT]' . "\n" . $stdout_generated . '[END STDOUT]' . "\n" );
# }
# if ( $OSNAME eq 'MSWin32' || $stderr_select->can_read(0) ) {
## RPerl::diag( 'in 09_interpret_execute.t, yes MSWin32 or $stderr_select->can_read(0), about to call sysread STDERR_TEST...' . "\n" );
# sysread STDERR_TEST, $stderr_generated, 4096;
## RPerl::diag( 'in 09_interpret_execute.t, yes MSWin32 or $stderr_select->can_read(0), returned from sysread STDERR_TEST, have $stderr_generated = ' . "\n" . '[BEGIN STDERR]' . "\n" . $stderr_generated . '[END STDERR]' . "\n" );
# }
#
## RPerl::diag( 'in 09_interpret_execute.t, have $pid = ' . $pid . ', about to call waitpid...' . "\n" );
# waitpid $pid, 0;
## RPerl::diag( 'in 09_interpret_execute.t, have $pid = ' . $pid . ', returned from waitpid...' . "\n" );
#
# if ( $OSNAME eq 'MSWin32' || $stdout_select->can_read(0) ) {
## RPerl::diag( 'in 09_interpret_execute.t, yes MSWin32 or $stdout_select->can_read(0), about to call sysread STDOUT_TEST...' . "\n" );
# my string $stdout_generated_continued;
# sysread STDOUT_TEST, $stdout_generated_continued, 4096;
# $stdout_generated .= $stdout_generated_continued;
## RPerl::diag( 'in 09_interpret_execute.t, yes MSWin32 or $stdout_select->can_read(0), returned from sysread STDOUT_TEST, have $stdout_generated_continued = ' . "\n" . '[BEGIN STDOUT]' . "\n" . $stdout_generated_continued . '[END STDOUT]' . "\n" );
# }
# if ( $OSNAME eq 'MSWin32' || $stderr_select->can_read(0) ) {
## RPerl::diag( 'in 09_interpret_execute.t, yes MSWin32 or $stderr_select->can_read(0), about to call sysread STDERR_TEST...' . "\n" );
# my string $stderr_generated_continued;
# sysread STDERR_TEST, $stderr_generated_continued, 4096;
# $stderr_generated .= $stderr_generated_continued;
## RPerl::diag( 'in 09_interpret_execute.t, yes MSWin32 or $stderr_select->can_read(0), returned from sysread STDERR_TEST, have $stderr_generated_continued = ' . "\n" . '[BEGIN STDERR]' . "\n" . $stderr_generated_continued . '[END STDERR]' . "\n" );
# }


# DISABLED: no user input accepted
# $stdout_generated = q{};
Expand Down
2 changes: 2 additions & 0 deletions t/13_generate.t
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ find(
);

# locate all *.*OPS_*TYPES pre-compiled files in PATH_PRECOMPILED directory
if ( not defined $ARGV[0] ) { ## bugfix, needed because so you can use t/13 with args and it will work.
find(
sub {
my $file = $File::Find::name;
Expand Down Expand Up @@ -136,6 +137,7 @@ find(
},
PATH_PRECOMPILED()
);
}

#=cut

Expand Down