randyk 2003/06/05 07:49:37
Modified: t/response/TestApache subprocess.pm Log: Reviewed by: stas fixes for benefit of Win32 to - use Perl to run scripts - handle line endings Revision Changes Path 1.14 +18 -14 modperl-2.0/t/response/TestApache/subprocess.pm Index: subprocess.pm =================================================================== RCS file: /home/cvs/modperl-2.0/t/response/TestApache/subprocess.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- subprocess.pm 8 Apr 2003 02:05:34 -0000 1.13 +++ subprocess.pm 5 Jun 2003 14:49:37 -0000 1.14 @@ -5,6 +5,7 @@ use Apache::Test; use Apache::TestUtil; +use Apache::Build; use File::Spec::Functions qw(catfile catdir); use IO::Select (); @@ -14,6 +15,8 @@ use Config; use constant PERLIO_5_8_IS_ENABLED => $Config{useperlio} && $] >= 5.007; +my $perl = Apache::Build->build_config()->perl_config('perlpath'); + my %scripts = ( argv => 'print STDOUT "@ARGV";', env => 'print STDOUT $ENV{SubProcess}', @@ -46,9 +49,10 @@ { # test: passing argv + scalar context - my $command = catfile $target_dir, "argv.pl"; + my $script = catfile $target_dir, "argv.pl"; my @argv = qw(foo bar); - my $out_fh = Apache::SubProcess::spawn_proc_prog($r, $command, [EMAIL PROTECTED]); + my $out_fh = + Apache::SubProcess::spawn_proc_prog($r, $perl, [$script, @argv]); my $output = read_data($out_fh); ok t_cmp([EMAIL PROTECTED], [split / /, $output], @@ -58,10 +62,10 @@ { # test: passing env to subprocess through subprocess_env - my $command = catfile $target_dir, "env.pl"; + my $script = catfile $target_dir, "env.pl"; my $value = "my cool proc"; $r->subprocess_env->set(SubProcess => $value); - my $out_fh = Apache::SubProcess::spawn_proc_prog($r, $command); + my $out_fh = Apache::SubProcess::spawn_proc_prog($r, $perl, [$script]); my $output = read_data($out_fh); ok t_cmp($value, $output, @@ -71,12 +75,12 @@ { # test: subproc's stdin -> stdout + list context - my $command = catfile $target_dir, "in_out.pl"; - my $value = "my cool proc\n"; # must have \n for <IN> - my ($in_fh, $out_fh, $err_fh) = - Apache::SubProcess::spawn_proc_prog($r, $command); + my $script = catfile $target_dir, "in_out.pl"; + my $value = "my cool proc\r\n"; # must have \n for <IN> + my ($in_fh, $out_fh, $err_fh) = + Apache::SubProcess::spawn_proc_prog($r, $perl, [$script]); print $in_fh $value; - my $output = read_data($out_fh); + (my $output = read_data($out_fh)) =~ s/[\r\n]{1,2}/\r\n/; ok t_cmp($value, $output, "testing subproc's stdin -> stdout + list context" @@ -85,12 +89,12 @@ { # test: subproc's stdin -> stderr + list context - my $command = catfile $target_dir, "in_err.pl"; - my $value = "my stderr\n"; # must have \n for <IN> - my ($in_fh, $out_fh, $err_fh) = - Apache::SubProcess::spawn_proc_prog($r, $command); + my $script = catfile $target_dir, "in_err.pl"; + my $value = "my stderr\r\n"; # must have \n for <IN> + my ($in_fh, $out_fh, $err_fh) = + Apache::SubProcess::spawn_proc_prog($r, $perl, [$script]); print $in_fh $value; - my $output = read_data($err_fh); + (my $output = read_data($err_fh)) =~ s/[\r\n]{1,2}/\r\n/; ok t_cmp($value, $output, "testing subproc's stdin -> stderr + list context"