Further Byteloader tweaks from Enache.
[p5sagit/p5-mst-13.2.git] / t / TEST
diff --git a/t/TEST b/t/TEST
index ec388a9..3e6e408 100755 (executable)
--- a/t/TEST
+++ b/t/TEST
@@ -19,8 +19,9 @@ if ($#ARGV >= 0) {
        push( @argv, $ARGV[$idx] ), next unless $ARGV[$idx] =~ /^-(\S+)$/;
        $core    = 1 if $1 eq 'core';
        $verbose = 1 if $1 eq 'v';
+       $torture = 1 if $1 eq 'torture';
        $with_utf= 1 if $1 eq 'utf8';
-        $byte_compile = 1 if $1 eq 'bytecompile';
+        $bytecompile = 1 if $1 eq 'bytecompile';
         $compile = 1 if $1 eq 'compile';
        if ($1 =~ /^deparse(,.+)?$/) {
            $deparse = 1;
@@ -96,7 +97,7 @@ unless (@ARGV) {
     my $mani = File::Spec->catfile($updir, "MANIFEST");
     if (open(MANI, $mani)) {
         while (<MANI>) { # similar code in t/harness
-           if (m!^(ext/\S+/?([^/]+\.t|test\.pl)|lib/\S+?(\.t|test\.pl))\s!) {
+           if (m!^(ext/\S+/?(?:[^/\s]+\.t|test\.pl)|lib/\S+?(?:\.t|test\.pl))\s!) {
                $t = $1;
                if (!$core || $t =~ m!^lib/[a-z]!)
                {
@@ -110,9 +111,11 @@ unless (@ARGV) {
     } else {
         warn "$0: cannot open $mani: $!\n";
     }
-    _find_tests('pod')  unless $core;
-    _find_tests('x2p')  unless $core;
-    _find_tests('japh') unless $core;
+    unless ($core) {
+       _find_tests('pod');  
+       _find_tests('x2p');
+       _find_tests('japh') if $torture;
+    }
 }
 
 # Tests known to cause infinite loops for the perlcc tests.
@@ -122,9 +125,11 @@ unless (@ARGV) {
 if ($deparse) {
     _testprogs('deparse', '',   @ARGV);
 }
-elsif( $compile || $byte_compile ) { 
-    _testprogs('compile', '',   @ARGV) if $compile;
-    _testprogs('compile', '-B', @ARGV) if $byte_compile;
+elsif( $compile ) { 
+    _testprogs('compile', '',   @ARGV);
+}
+elsif( $bytecompile ) {
+    _testprogs('bytecompile', '', @ARGV);
 }
 else {
     _testprogs('compile', '',   @ARGV) if -e "../testcompile";
@@ -148,6 +153,12 @@ TESTING DEPARSER
 ------------------------------------------------------------------------------
 EOT
 
+    print <<EOT if ($type eq 'bytecompile');
+------------------------------------------------------------------------------
+TESTING BYTECODE COMPILER
+------------------------------------------------------------------------------
+EOT
+
     $ENV{PERLCC_TIMEOUT} = 120
           if ($type eq 'compile' && !$ENV{PERLCC_TIMEOUT});
 
@@ -203,7 +214,7 @@ EOT
        open(SCRIPT,"<$test") or die "Can't run $test.\n";
        $_ = <SCRIPT>;
        close(SCRIPT) unless ($type eq 'deparse');
-       if (/#!.*\bperl.*-\w*([tT])/) {
+       if (/#!.*\bperl.*\s-\w*([tT])/) {
            $switch = qq{"-$1"};
        }
        else {
@@ -225,13 +236,30 @@ EOT
        my $testswitch = '-I. -MTestInit'; # -T will strict . from @INC
        if ($type eq 'deparse') {
            my $deparse =
-               "./perl $testswitch $switch -I../lib -MO=-qq,Deparse,".
+               "./perl $testswitch $switch -I../lib -MO=-qq,Deparse,-sv1.,".
                "-l$deparse_opts$file_opts ".
                "$test > $test.dp ".
                "&& ./perl $testswitch $switch -I../lib $test.dp |";
            open(RESULTS, $deparse)
                or print "can't deparse '$deparse': $!.\n";
        }
+       elsif ($type eq 'bytecompile') {
+           my $perl = $ENV{PERL} || './perl';
+           my $redir = ($^O eq 'VMS' ? '2>&1' : '');
+           my $bswitch = "-MO=Bytecode,-H,-TI,-s`pwd`/$test,";
+           $bswitch .= "-TF$test.plc,"
+               if $test =~ m(chdir|pod/|CGI/t/carp|lib/DB);
+           $bswitch .= "-k,"
+               if $test =~ m(deparse|terse|ext/Storable/t/code);
+           $bswitch .= "-b,"
+               if $test =~ m(op/getpid);
+           my $bytecompile =
+               "$perl $testswitch $switch -I../lib $bswitch". 
+               "-o$test.plc $test 2>/dev/null &&".
+               "$perl $testswitch $switch $utf $test.plc $redir|";
+           open(RESULTS,$bytecompile)
+               or print "can't byte-compile '$bytecompile': $!.\n";
+       }
        elsif ($type eq 'perl') {
            my $perl = $ENV{PERL} || './perl';
            my $redir = ($^O eq 'VMS' ? '2>&1' : '');
@@ -254,7 +282,7 @@ EOT
 
 open HACK, '.\\perl $pl2c $test_executable |';
 # cl.exe prints the name of the .c file on stdout (\%^\$^#)
-while(<HACK>) {m/^\w+\.[cC]\$/ && next;print}
+while(<HACK>) {m/^\\w+\\.[cC]\$/ && next;print}
 open HACK, '$test_executable |';
 while(<HACK>) {print}
 EOT
@@ -318,11 +346,11 @@ EOT
        }
        if ($ENV{PERL_3LOG}) {
            my $tpp = $test;
-           $tpp =~ s:^../::;
+           $tpp =~ s:^\.\./::;
            $tpp =~ s:/:_:g;
-           $tpp =~ s:\.t$::;
-           rename("perl.3log", "perl.3log.$tpp") ||
-               die "rename: perl3.log to perl.3log.$tpp: $!\n";
+           $tpp =~ s:\.t$:.3log:;
+           rename("perl.3log", $tpp) ||
+               die "rename: perl3.log to $tpp: $!\n";
        }
        $next = $next - 1;
         # test if the compiler compiled something