Merge the file parsing code for run_multiple_progs() into _setup_one_file().
authorNicholas Clark <nick@ccl4.org>
Sun, 14 Jul 2013 18:44:50 +0000 (20:44 +0200)
committerNicholas Clark <nick@ccl4.org>
Mon, 22 Jul 2013 08:04:48 +0000 (10:04 +0200)
setup_multiple_progs() calls _setup_one_file() to parse each file in turn,
and run_multiple_progs() calls it once if passed a file handle.

t/test.pl

index 39c083d..b160287 100644 (file)
--- a/t/test.pl
+++ b/t/test.pl
@@ -969,6 +969,13 @@ sub fresh_perl_like {
 # If the global variable $FATAL is true then OPTION fatal is the
 # default.
 
+sub _setup_one_file {
+    my $fh = shift;
+    local $/;
+    my @these = split "\n########\n", <$fh>;
+    ((scalar @these), @these);
+}
+
 sub setup_multiple_progs {
     my ($tests, @prgs);
     foreach my $file (@_) {
@@ -996,12 +1003,9 @@ sub setup_multiple_progs {
         die "Could not find '__END__' in $file"
             unless $found;
 
-        {
-            local $/ = undef;
-            my @these = split "\n########\n", <$fh>;
-            $tests += @these;
-            push @prgs, $file, @these;
-        }
+        my ($t, @p) = _setup_one_file($fh);
+        $tests += $t;
+        push @prgs, $file, @p;
 
         close $fh
             or die "Cannot close $file: $!\n";
@@ -1018,9 +1022,9 @@ sub run_multiple_progs {
        @prgs = @_;
     } else {
        # The tests below t run in t and pass in a file handle.
-       my $fh = shift;
-       local $/;
-       @prgs = split "\n########\n", <$fh>;
+        # Not going to rely on undef in list assignment.
+        my $dummy;
+        ($dummy, @prgs) = _setup_one_file(shift);
     }
 
     my $tmpfile = tempfile();