In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/a80e93c2ac4ef033b7aff53be0a697746e09f7ea?hp=98b4ddd60241e805202ea45b0e3e203be7a46e05>

- Log -----------------------------------------------------------------
commit a80e93c2ac4ef033b7aff53be0a697746e09f7ea
Author: Nicholas Clark <[email protected]>
Date:   Thu Jul 1 20:41:21 2010 +0100

    t/lib/common.pl can use caller to infer the name of the pragma under test.
    
    This avoids needing to use a variable in package main to pass in 
information.
    Also, remove an unnecessary $ENV{PERL5LIB} assignment cargo-culted into most
    users of t/lib/common,pl, and remove the BEGIN block as the code it 
contained
    doesn't need to run at BEGIN time.
-----------------------------------------------------------------------

Summary of changes:
 lib/charnames.t |    1 -
 lib/feature.t   |    9 ++-------
 lib/strict.t    |    8 ++------
 lib/subs.t      |    8 ++------
 lib/warnings.t  |    8 ++------
 t/lib/common.pl |    4 +++-
 6 files changed, 11 insertions(+), 27 deletions(-)

diff --git a/lib/charnames.t b/lib/charnames.t
index f50076c..50c9837 100644
--- a/lib/charnames.t
+++ b/lib/charnames.t
@@ -11,7 +11,6 @@ BEGIN {
     $SIG{__WARN__} = sub { push @WARN, @_ };
 }
 
-our $pragma_name = "charnames";
 our $local_tests = 58;
 
 # ---- For the alias extensions
diff --git a/lib/feature.t b/lib/feature.t
index a60644f..0818f37 100644
--- a/lib/feature.t
+++ b/lib/feature.t
@@ -1,10 +1,5 @@
 #!./perl
 
-BEGIN {
-    chdir 't' if -d 't';
-    @INC = '../lib';
-    $ENV{PERL5LIB} = '../lib';
-}
-
-our $pragma_name = "feature";
+chdir 't' if -d 't';
+...@inc = '../lib';
 require "../t/lib/common.pl";
diff --git a/lib/strict.t b/lib/strict.t
index 51e9b73..e067793 100644
--- a/lib/strict.t
+++ b/lib/strict.t
@@ -1,12 +1,8 @@
 #!./perl
 
-BEGIN {
-    chdir 't' if -d 't';
-    @INC = '../lib';
-    $ENV{PERL5LIB} = '../lib';
-}
+chdir 't' if -d 't';
+...@inc = '../lib';
 
-our $pragma_name = "strict";
 our $local_tests = 4;
 require "../t/lib/common.pl";
 
diff --git a/lib/subs.t b/lib/subs.t
index 1f719c7..4ad4f8f 100644
--- a/lib/subs.t
+++ b/lib/subs.t
@@ -1,10 +1,6 @@
 #!./perl
 
-BEGIN {
-    chdir 't' if -d 't';
-    @INC = '../lib';
-    $ENV{PERL5LIB} = '../lib';
-}
+chdir 't' if -d 't';
+...@inc = '../lib';
 
-our $pragma_name = "subs";
 require "../t/lib/common.pl";
diff --git a/lib/warnings.t b/lib/warnings.t
index d03b8c5..ee696fe 100644
--- a/lib/warnings.t
+++ b/lib/warnings.t
@@ -1,11 +1,7 @@
 #!./perl
 
-BEGIN {
-    chdir 't' if -d 't';
-    @INC = '../lib';
-    $ENV{PERL5LIB} = '../lib';
-}
+chdir 't' if -d 't';
+...@inc = '../lib';
 
-our $pragma_name = "warnings";
 our $UTF8 = (${^OPEN} || "") =~ /:utf8/;
 require "../t/lib/common.pl";
diff --git a/t/lib/common.pl b/t/lib/common.pl
index d3bf149..e5c9af4 100644
--- a/t/lib/common.pl
+++ b/t/lib/common.pl
@@ -11,7 +11,9 @@ use File::Spec::Functions;
 
 use strict;
 use warnings;
-our $pragma_name;
+my (undef, $file) = caller;
+my ($pragma_name) = $file =~ /([A-Za-z_0-9]+)\.t$/
+    or die "Can't identify pragama to test from file name '$file'";
 
 $| = 1;
 

--
Perl5 Master Repository

Reply via email to