PATCH: t/lib/common.pl localized $/ setting; allow input 'no_plan'
authorkarl williamson (via RT) <perlbug-followup@perl.org>
Tue, 6 Jul 2010 15:27:34 +0000 (08:27 -0700)
committerH.Merijn Brand <h.m.brand@xs4all.nl>
Thu, 8 Jul 2010 08:33:10 +0000 (10:33 +0200)
# New Ticket Created by  karl williamson
# Please include the string:  [perl #76398]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=76398 >

See attached patches

>From 275169a8df5851331669da2dd791483379c3fc5e Mon Sep 17 00:00:00 2001
From: Karl Williamson <khw@khw-desktop.(none)>
Date: Tue, 6 Jul 2010 09:20:42 -0600
Subject: [PATCH] t/lib/common.pl: localize changing $/

$/ changes should not affect callers.

Signed-off-by: H.Merijn Brand <h.m.brand@xs4all.nl>
t/lib/common.pl

index e5c9af4..e68a351 100644 (file)
@@ -1,5 +1,9 @@
 # This code is used by lib/charnames.t, lib/feature.t, lib/subs.t,
 # lib/strict.t and lib/warnings.t
+#
+# On input, $::local_tests is the number of tests in the caller; or
+# 'no_plan' if unknown, in which case it is the caller's responsibility
+# to call cur_test() to find out how many this executed
 
 BEGIN {
     require './test.pl';
@@ -51,9 +55,11 @@ foreach my $file (@w_files) {
     close F ;
 }
 
-undef $/;
+local $/ = undef;
 
-plan tests => (scalar(@prgs)-$files + ($::local_tests || 0));
+my $tests = $::local_tests || 0;
+$tests = scalar(@prgs)-$files + $tests if $tests !~ /\D/;
+plan $tests;    # If input is 'no_plan', pass it on unchanged
 
 for (@prgs){
     unless (/\n/)