List:Commits« Previous MessageNext Message »
From:Magnus Blåudd Date:September 22 2009 5:37pm
Subject:bzr commit into mysql-5.1-telco-7.0 branch (magnus.blaudd:3028)
Bug#47526
View as plain text  
#At file:///home/msvensson/mysql/7.0/ based on revid:jonas@strippeduz3v

 3028 Magnus Blåudd	2009-09-22
      Bug#47526 unit.pl fails to execute binaries when using Test::Harness 3.10
       - Rewrite unit.pl so it prefers to use TAP::Harness directly.

    modified:
      unittest/unit.pl
=== modified file 'unittest/unit.pl'
--- a/unittest/unit.pl	2009-05-29 10:05:41 +0000
+++ b/unittest/unit.pl	2009-09-22 17:37:35 +0000
@@ -15,7 +15,6 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
 
-use Test::Harness;
 use File::Find;
 use Getopt::Long;
 
@@ -38,10 +37,10 @@ unit - Run unit tests in directory
 =cut
 
 my $big= $ENV{'MYTAP_CONFIG'} eq 'big';
-
+my $opt_verbose;
 my $result = GetOptions (
   "big!"        => \$big,
-  "verbose!"    => \$Test::Harness::verbose,
+  "verbose!"    => \$opt_verbose,
 );
 
 $ENV{'MYTAP_CONFIG'} = $big ? 'big' : '';
@@ -61,6 +60,19 @@ Run all unit tests in the current direct
 
 =cut
 
+BEGIN {
+  # Test::Harness have been extensively rewritten in newer perl
+  # versions and is now just a backward compatibility wrapper
+  # (with a bug causing the HARNESS_PERL_SWITCHES to be mangled)
+  # Prefer to use TAP::Harness directly if available
+  if (eval "use TAP::Harness; 1") {
+    eval 'sub NEW_HARNESS { 1 }';
+    warn "using TAP::Harness";
+  } else {
+    eval "use Test::Harness; 1" or  die "couldn't find Test::Harness!";
+    eval 'sub NEW_HARNESS { 0 }';
+  }
+}
 
 sub _find_test_files (@) {
     my @dirs = @_;
@@ -72,6 +84,7 @@ sub _find_test_files (@) {
     return @files;
 }
 
+
 sub run_cmd (@) {
     my @files;
 
@@ -99,12 +112,22 @@ sub run_cmd (@) {
         push(@files, _find_test_files $name) if -d $name;
         push(@files, $name) if -f $name;
     }
-
     if (@files > 0) {
         # Removing the first './' from the file names
         foreach (@files) { s!^\./!! }
-        $ENV{'HARNESS_PERL_SWITCHES'} .= ' -e "exec @ARGV"';
-        runtests @files;
+
+	if (NEW_HARNESS())
+        {
+          my %args = ( exec => [ ], verbosity => $opt_verbose );
+          my $harness = TAP::Harness->new( \%args );
+          $harness->runtests(@files);
+        }
+	else
+	{
+	  $ENV{'HARNESS_VERBOSE'} =  $opt_verbose;
+          $ENV{'HARNESS_PERL_SWITCHES'} .= ' -e "exec @ARGV"';
+          runtests(@files);
+        }
     }
 }
 

Attachment: [text/bzr-bundle] bzr/magnus.blaudd@sun.com-20090922173735-1ntbiqr025y4gcbj.bundle
Thread
bzr commit into mysql-5.1-telco-7.0 branch (magnus.blaudd:3028)Bug#47526Magnus Blåudd22 Sep