This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[inseparable changes from match from perl-5.003_97 to perl-5.003_97a]
[perl5.git] / t / op / runlevel.t
index ca6aac5..2be2eec 100755 (executable)
@@ -16,7 +16,9 @@
 
 chdir 't' if -d 't';
 @INC = "../lib";
 
 chdir 't' if -d 't';
 @INC = "../lib";
-$ENV{PERL5LIB} = "../lib";
+$Is_VMS = $^O eq 'VMS';
+$Is_MSWin32 = $^O eq 'MSWin32';
+$ENV{PERL5LIB} = "../lib" unless $Is_VMS;
 
 $|=1;
 
 
 $|=1;
 
@@ -26,22 +28,29 @@ print "1..", scalar @prgs, "\n";
 
 $tmpfile = "runltmp000";
 1 while -f ++$tmpfile;
 
 $tmpfile = "runltmp000";
 1 while -f ++$tmpfile;
-END { unlink $tmpfile if $tmpfile; }
+END { if ($tmpfile) { 1 while unlink $tmpfile; } }
 
 for (@prgs){
     my $switch;
 
 for (@prgs){
     my $switch;
-    if (s/^\s*-\w+//){
-       $switch = $&;
+    if (s/^\s*(-\w+)//){
+       $switch = $1;
     }
     my($prog,$expected) = split(/\nEXPECT\n/, $_);
     }
     my($prog,$expected) = split(/\nEXPECT\n/, $_);
-    open TEST, "| sh -c './perl $switch' >$tmpfile 2>&1";
-    print TEST $prog, "\n";
+    open TEST, ">$tmpfile";
+    print TEST "$prog\n";
     close TEST;
     close TEST;
-    $status = $?;
-    $results = `cat $tmpfile`;
+    my $results = $Is_VMS ?
+                 `MCR $^X "-I[-.lib]" $switch $tmpfile` :
+                     $Is_MSWin32 ?  
+                         `.\\perl -I../lib $switch $tmpfile 2>&1` :
+                             `sh -c './perl $switch $tmpfile' 2>&1`;
+    my $status = $?;
     $results =~ s/\n+$//;
     $results =~ s/\n+$//;
+    # allow expected output to be written as if $prog is on STDIN
+    $results =~ s/runltmp\d+/-/g;
+    $results =~ s/\n%[A-Z]+-[SIWEF]-.*$// if $Is_VMS;  # clip off DCL status msg
     $expected =~ s/\n+$//;
     $expected =~ s/\n+$//;
-    if ( $results ne $expected){
+    if ($results ne $expected) {
        print STDERR "PROG: $switch\n$prog\n";
        print STDERR "EXPECTED:\n$expected\n";
        print STDERR "GOT:\n$results\n";
        print STDERR "PROG: $switch\n$prog\n";
        print STDERR "EXPECTED:\n$expected\n";
        print STDERR "GOT:\n$results\n";
@@ -249,7 +258,7 @@ package main;
 open FH, ">&STDOUT";
 tie *FH, TEST;
 print FH "OK\n";
 open FH, ">&STDOUT";
 tie *FH, TEST;
 print FH "OK\n";
-print "DONE\n";
+print STDERR "DONE\n";
 EXPECT
 PRINT CALLED
 DONE
 EXPECT
 PRINT CALLED
 DONE