# New Ticket Created by  flusse...@gmail.com 
# Please include the string:  [perl #123678]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=123678 >


Hi,

I saw some LHF in the test harness code and had a go at improving it.
Doesn't add noticeable spectest speedups, sorry (just prettier code :)
>From 74a3d77b31d2449fb62c3968768a0e92591eb077 Mon Sep 17 00:00:00 2001
From: Anthony Parsons <flusse...@gmail.com>
Date: Mon, 26 Jan 2015 22:16:35 +0000
Subject: [PATCH] Switch to using TAP::Harness directly in t/harness

The previous code would "use Test::Harness" unconditionally and (using a runtime
eval) "require TAP::Harness" conditionally, preferring the latter if present.

However, Test::Harness has been a wrapper around TAP::Harness for about 8 years
now, so the former was getting loaded and subsequently ignored completely, while
the latter was getting eval'ed and always used.

This makes TAP::Harness the default, only using eval when TAP::Harness::Archive
is requested using --archive. It also simplifies things by placing
TAP::Harness::Archive setup code in a single if-statement, in close proximity to
the other "use" lines.
---
 t/harness | 57 ++++++++++++++++++++++++---------------------------------
 1 file changed, 24 insertions(+), 33 deletions(-)

diff --git a/t/harness b/t/harness
index ed3715e384b4..4c66ea2ed727 100644
--- a/t/harness
+++ b/t/harness
@@ -10,14 +10,12 @@ use FindBin;
 use File::Spec;
 use Getopt::Long qw(:config pass_through);
 use Pod::Usage;
-
-use Test::Harness;
-$Test::Harness::switches = '';
+use TAP::Harness;
 
 GetOptions(
     'tests-from-file=s' => \my $list_file,
     'fudge'             => \my $do_fudge,
-    'verbosity=i'       => \$Test::Harness::verbose,
+    'verbosity=i'       => \my $verbosity,
     'jobs:1'            => \my $jobs,
     'icu:1'             => \my $do_icu,
     'long:1'            => \my $do_long,
@@ -29,6 +27,18 @@ GetOptions(
     'help|h' => sub { pod2usage(1); },
 ) or pod2usage(2);
 
+my $tap_harness_class = 'TAP::Harness';
+my $extra_properties;
+
+if ($archive) {
+    $tap_harness_class .= '::Archive';
+    eval "require $tap_harness_class;"
+        or die "Can't load $tap_harness_class, which is needed for smolder 
submissions: $@";
+
+    $extra_properties->{'Parrot Revision'} = $parrot_revision  if 
$parrot_revision;
+    $extra_properties->{'Submitter'} = $ENV{SMOLDER_SUBMITTER} if 
$ENV{SMOLDER_SUBMITTER};
+}
+
 $do_long = 1 unless defined $do_long;
 $do_stress = 0 unless defined $do_stress;
 
@@ -74,17 +84,6 @@ if ($do_fudge) {
     @tfiles = fudge(@tfiles);
 }
 
-my $tap_harness_class = 'TAP::Harness';
-$tap_harness_class .= '::Archive' if $archive;
-
-my $extra_properties;
-if ($archive) {
-    $extra_properties->{'Parrot Revision'} = $parrot_revision
-    if $parrot_revision;
-    $extra_properties->{'Submitter'} = $ENV{SMOLDER_SUBMITTER}
-    if $ENV{SMOLDER_SUBMITTER};
-}
-
 if ($jvm) {
     unlink("TESTTOKEN");
     $ENV{HARNESS_PERL} = "$^X .${slash}eval-client.pl TESTTOKEN run";
@@ -95,24 +94,16 @@ if ($jvm) {
     sleep 1;
 }
 
-if (eval "require $tap_harness_class;") {
-    my %harness_options = (
-        exec        => $jvm ? [$^X, "./eval-client.pl", "TESTTOKEN", "run"] : 
[$ENV{HARNESS_PERL}],
-        verbosity   => 0+$Test::Harness::verbose,
-        jobs        => $jobs || $ENV{TEST_JOBS} || 1,
-        ignore_exit => 1,
-        merge       => 1,
-        $archive ? ( archive => $archive ) : (),
-        $extra_properties ? ( extra_properties => $extra_properties ) : (),
-    );
-    $tap_harness_class->new( \%harness_options )->runtests(@tfiles);
-}
-elsif ($archive) {
-    die "Can't load $tap_harness_class, which is needed for smolder 
submissions: $@";
-}
-else {
-    runtests(@tfiles);
-}
+my %harness_options = (
+    exec        => $jvm ? [$^X, "./eval-client.pl", "TESTTOKEN", "run"] : 
[$ENV{HARNESS_PERL}],
+    verbosity   => $verbosity,
+    jobs        => $jobs || $ENV{TEST_JOBS} || 1,
+    ignore_exit => 1,
+    merge       => 1,
+    $archive ? ( archive => $archive ) : (),
+    $extra_properties ? ( extra_properties => $extra_properties ) : (),
+);
+$tap_harness_class->new( \%harness_options )->runtests(@tfiles);
 
 # adapted to return only files ending in '.t'
 sub all_in {
-- 
2.2.1

Reply via email to