This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
do not count tests, instead use done_testing() 19256/head
authorMichiel Beijen <mb@x14.nl>
Fri, 3 Dec 2021 06:56:08 +0000 (07:56 +0100)
committerMichiel Beijen <mb@x14.nl>
Sat, 4 Dec 2021 14:55:55 +0000 (15:55 +0100)
Having to count tests is annoying for maintainers.

Also, manually updating count tests is problematic when multiple people
are working on the same code; it causes merge conflicts and recounts.

done_testing() is available since Test::More 0.88 which was released in
2009.

This commit changes all tests under lib/ that use Test::More and were
planning the number of tests.

Michiel Beijen is now a Perl author

43 files changed:
AUTHORS
lib/B/Deparse-core.t
lib/B/Deparse-subclass.t
lib/Benchmark.t
lib/Config/Extensions.t
lib/DB.t
lib/DBM_Filter/t/01error.t
lib/DBM_Filter/t/02core.t
lib/DBM_Filter/t/compress.t
lib/DBM_Filter/t/encode.t
lib/DBM_Filter/t/int32.t
lib/DBM_Filter/t/null.t
lib/DBM_Filter/t/utf8.t
lib/DirHandle.t
lib/English.t
lib/File/Basename.t
lib/File/Compare.t
lib/File/Copy.t
lib/FileHandle.t
lib/Getopt/Std.t
lib/Internals.t
lib/Net/hostent.t
lib/Pod/t/Usage.t
lib/Symbol.t
lib/Thread.t
lib/Tie/ExtraHash.t
lib/Tie/Handle/stdhandle.t
lib/Tie/Handle/stdhandle_from_handle.t
lib/Tie/Hash.t
lib/Tie/Scalar.t
lib/Time/gmtime.t
lib/Time/localtime.t
lib/User/grent.t
lib/blib.t
lib/dumpvar.t
lib/filetest.t
lib/h2xs.t
lib/integer.t
lib/less.t
lib/overload64.t
lib/overloading.t
lib/sort.t
lib/vmsish.t

diff --git a/AUTHORS b/AUTHORS
index 2f93a9b..59895f8 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -910,6 +910,7 @@ Michael Stevens                <mstevens@etla.org>
 Michael van Elst               <mlelstv@serpens.de>
 Michael Witten                 <mfwitten@gmail.com>
 Michele Sardo
+Michiel Beijen                 <mb@x14.nl>
 Mik Firestone                  <fireston@lexmark.com>
 Mike Doherty                   <mike@mikedoherty.ca>
 Mike Fletcher                  <fletch@phydeaux.org>
index 7d8613f..2b6e6a5 100644 (file)
@@ -36,7 +36,6 @@ BEGIN {
 
 use strict;
 use Test::More;
-plan tests => 3904;
 
 use feature (sprintf(":%vd", $^V)); # to avoid relying on the feature
                                     # logic to add CORE::
@@ -435,6 +434,8 @@ SKIP:
     ok($pass, "sanity checks");
 }
 
+done_testing();
+
 __DATA__
 #
 # format:
index c1484aa..80292fc 100644 (file)
@@ -4,7 +4,7 @@
 # publicise an API for subclassing B::Deparse they can prevent us from
 # gratuitously breaking conventions that CPAN modules already use.
 
-use Test::More tests => 2;
+use Test::More;
 
 use B::Deparse;
 
@@ -22,3 +22,5 @@ like  $nm->coderef2text(sub { my($a, $b, $c) }),
 like  $nm->coderef2text(sub { my $c; /(??{ $c })/; }),
       qr/\Q(??{\E \$c_groovy/,
      'overriding padname works for renaming lexicals in regexp blocks';
+
+done_testing();
index 523618f..0f3d297 100644 (file)
@@ -8,7 +8,7 @@ BEGIN {
 use warnings;
 use strict;
 our ($foo, $bar, $baz, $ballast);
-use Test::More tests => 213;
+use Test::More;
 
 use Benchmark qw(:all);
 
@@ -634,6 +634,7 @@ is_deeply ([keys %Benchmark::Cache], \@before_keys,
     }
 }
 
+done_testing();
 
 package TieOut;
 
index 1d730b0..88dd496 100644 (file)
@@ -6,7 +6,7 @@ BEGIN {
     }
 }
 use strict;
-use Test::More 'no_plan';
+use Test::More;
 
 BEGIN {use_ok 'Config::Extensions', '%Extensions'};
 
@@ -31,3 +31,5 @@ while (my ($key, $val) = each %Extensions) {
     my $type = $val . '_ext';
     like($Config{$type}, $re, "$key is $type");
 }
+
+done_testing();
index e4ee074..8bb4413 100644 (file)
--- a/lib/DB.t
+++ b/lib/DB.t
@@ -18,7 +18,7 @@ use Scalar::Util qw( dualvar );
 my $dualfalse = dualvar(0, 'false');
 my $dualtrue = dualvar(1, 'true');
 
-use Test::More tests => 106;
+use Test::More;
 
 # must happen at compile time for DB:: package variable localizations to work
 BEGIN {
@@ -498,6 +498,8 @@ for my $method (qw( cprestop cpoststop awaken init stop idle cleanup output )) {
         ok( defined &{ "DB::$method" }, "DB::$method() should be defined" );
 }
 
+done_testing();
+
 # DB::skippkg() uses lexical
 # DB::ready() uses lexical
 
index 33173f3..bd691aa 100644 (file)
@@ -45,7 +45,7 @@ print "# runFilter $name\n" ;
     return $@;
 }
 
-use Test::More tests => 21;
+use Test::More;
 
 BEGIN { use_ok('DBM_Filter') };
 my $db_file;
@@ -249,3 +249,4 @@ undef $db;
     is $@, '', "untie without inner references" ;
 }
 
+done_testing();
index 1f5fef9..e2d865a 100644 (file)
@@ -30,7 +30,7 @@ sub writeFile
 
 END { unlink keys %files if keys %files }
 
-use Test::More tests => 189;
+use Test::More;
 
 BEGIN { use_ok('DBM_Filter') };
 my $db_file;
@@ -728,3 +728,4 @@ sub checkRaw
 
 }
 
+done_testing();
index f9b1fe1..e16d7dc 100644 (file)
@@ -14,7 +14,7 @@ print "# $@\n";
 }
 require "dbm_filter_util.pl";
 
-use Test::More tests => 23;
+use Test::More;
 
 BEGIN { use_ok('DBM_Filter') };
 my $db_file;
@@ -119,3 +119,4 @@ undef $db2;
     is $@, '', "untie without inner references" ;
 }
 
+done_testing();
index c7ef604..e8c9a8c 100644 (file)
@@ -19,7 +19,7 @@ BEGIN
 
 require "dbm_filter_util.pl";
 
-use Test::More tests => 26;
+use Test::More;
 
 BEGIN { use_ok('DBM_Filter') };
 my $db_file;
@@ -122,3 +122,5 @@ undef $db2;
 }
 
 }
+
+done_testing();
index a74d49d..90b209b 100644 (file)
@@ -5,7 +5,7 @@ use Carp;
 
 require "dbm_filter_util.pl";
 
-use Test::More tests => 22;
+use Test::More;
 
 BEGIN { use_ok('DBM_Filter') };
 my $db_file;
@@ -97,3 +97,4 @@ undef $db2;
     is $@, '', "untie without inner references" ;
 }
 
+done_testing();
index 8846183..0b32766 100644 (file)
@@ -5,7 +5,7 @@ use Carp;
 
 require "dbm_filter_util.pl";
 
-use Test::More tests => 26;
+use Test::More;
 
 BEGIN { use_ok('DBM_Filter') };
 my $db_file;
@@ -94,3 +94,4 @@ undef $db2;
     is $@, '', "untie without inner references" ;
 }
 
+done_testing();
index fb290e9..e322049 100644 (file)
@@ -18,7 +18,7 @@ BEGIN
 
 require "dbm_filter_util.pl";
 
-use Test::More tests => 20;
+use Test::More;
 
 BEGIN { use_ok('DBM_Filter') };
 my $db_file;
@@ -96,3 +96,4 @@ undef $db2;
     is $@, '', "untie without inner references" ;
 }
 
+done_testing();
index 2a131e6..21a39f1 100644 (file)
@@ -11,7 +11,7 @@ BEGIN {
 }
 
 use DirHandle;
-use Test::More tests => 31;
+use Test::More;
 
 # Fetching the list of files in two different ways and expecting them 
 # to be the same is a race condition when tests are running in parallel.
@@ -133,3 +133,5 @@ ok(! $bbdot->close(),
 if ($chdir) {
   chdir "..";
 }
+
+done_testing();
index f568d43..dc15926 100644 (file)
@@ -6,7 +6,7 @@ BEGIN {
     @INC = '../lib';
 }
 
-use Test::More tests => 58;
+use Test::More;
 
 use English qw( -no_match_vars ) ;
 use Config;
@@ -164,6 +164,9 @@ main::ok( !$POSTMATCH, '$POSTMATCH disabled' );
     ::is $LIST_SEPARATOR, 'frooble';
 }
 
+# because of the 'package' statements above, we have to prefix Test::More::
+Test::More::done_testing();
+
 __END__
 This is a line.
 This is a paragraph.
index 29d7d25..785e03d 100644 (file)
@@ -5,7 +5,7 @@ BEGIN {
     @INC = '../lib';
 }
 
-use Test::More tests => 65;
+use Test::More;
 
 BEGIN { use_ok 'File::Basename' }
 
@@ -184,3 +184,5 @@ SKIP: {
     ok tainted(dirname($TAINT.'/perl/lib//'));
     ok all_tainted(fileparse($TAINT.'/dir/draft.book7','\.book\d+'));
 }
+
+done_testing();
index b7c9d9f..640b181 100644 (file)
@@ -17,7 +17,7 @@ BEGIN {
   }
 }
 
-use Test::More ( tests => 16 );
+use Test::More;
 use File::Compare qw(compare compare_text);
 
 # Upon success, compare() and compare_text() return a Unix-ish 0
@@ -132,6 +132,8 @@ SKIP: {
         "compare() fails: second argument undefined");
 }
 
+done_testing();
+
 sub get_valid_whitespace {
     return ' ' unless $^O eq 'VMS';
     return (exists $ENV{'DECC$EFS_CHARSET'} && $ENV{'DECC$EFS_CHARSET'} =~ /^[ET1]/i)
index f21c871..57b86c1 100644 (file)
@@ -14,8 +14,6 @@ use Test::More;
 
 my $TB = Test::More->builder;
 
-plan tests => 466;
-
 # We are going to override rename() later on but Perl has to see an override
 # at compile time to honor it.
 BEGIN { *CORE::GLOBAL::rename = sub { CORE::rename($_[0], $_[1]) }; }
@@ -521,6 +519,7 @@ SKIP: {
     "copy with buffer above normal size";
 }
 
+done_testing();
 
 END {
     1 while unlink "copy-$$";
index c13e772..aa82b57 100644 (file)
@@ -13,7 +13,7 @@ BEGIN {
 use strict;
 use FileHandle;
 autoflush STDOUT 1;
-use Test::More (tests => 12);
+use Test::More;
 my $TB = Test::More->builder;
 
 my $mystdout = new_from_fd FileHandle 1,"w";
@@ -91,3 +91,5 @@ ok($|, "handle auto-flushing current output channel");
 }
 
 ok(!FileHandle->new('', 'r'), "Can't open empty filename");
+
+done_testing();
index 746d5de..b03f07b 100644 (file)
@@ -8,7 +8,7 @@ BEGIN {
 use strict;
 use warnings;
 
-use Test::More tests => 22;
+use Test::More;
 use Getopt::Std;
 
 our ($warning, $opt_f, $opt_i, $opt_o, $opt_x, $opt_y, %opt);
@@ -92,3 +92,5 @@ my $expected;
         "getopt: single switch; switch expected argument, none provided; value undef");
     undef %opt;
 }
+
+done_testing();
index 8af04af..89d3948 100644 (file)
@@ -7,7 +7,7 @@ BEGIN {
     }
 }
 
-use Test::More tests => 82;
+use Test::More;
 
 my $ro_err = qr/^Modification of a read-only value attempted/;
 
@@ -188,3 +188,5 @@ is( Internals::SvREFCNT($foo), $big_count, "reference count unsigned");
     eval { &Internals::SvREFCNT($foo, 0..3);};
     like($@, qr/\Q$usage\E/);
 }
+
+done_testing();
index 0f9dca0..3ee1980 100644 (file)
@@ -19,7 +19,7 @@ BEGIN {
     }
 }
 
-use Test::More tests => 10;
+use Test::More;
 
 BEGIN { use_ok 'Net::hostent' }
 
@@ -102,3 +102,5 @@ SKIP: {
     }
 }
 }
+
+done_testing();
index e626acb..94c1518 100644 (file)
@@ -8,7 +8,6 @@ BEGIN {
 use File::Basename;
 use File::Spec;
 use Test::More;
-plan tests => 8;
 
 use_ok( 'Pod::Usage' );
 
@@ -97,6 +96,7 @@ my $pod2usage = $$fake_out;
 
 is( $pod2usage, $pod2text, 'Verbose level >= 2 eq pod2text' );
 
+done_testing();
 
 package CatchOut;
 sub TIEHANDLE { bless \( my $self ), shift }
index d2d032d..45c441c 100644 (file)
@@ -8,7 +8,7 @@ BEGIN {
     @INC = '../lib';
 }
 
-use Test::More tests => 31;
+use Test::More;
 
 BEGIN { $_ = 'foo'; }  # because Symbol used to clobber $_
 
@@ -111,3 +111,5 @@ ok( exists $::{'Bar::'}, 'third transient stash exists' );
 ok( defined $Bar::{variable}, 'third transient variable in stash' );
 ok( ! defined(Symbol::delete_package('Bar::Bar::')),
     'delete_package() returns undef due to undefined leaf');
+
+done_testing();
index 18694c5..4f487a8 100644 (file)
@@ -14,7 +14,7 @@ BEGIN {
 
 use Thread qw(:DEFAULT async yield);
 
-use Test::More tests => 13;
+use Test::More;
 
 my $lock;
 {
@@ -93,4 +93,4 @@ COND_:
     is($thr->join(), 3, "->join returned thread's tid");
 }
 
-# EOF
+done_testing();
index bbaf64f..18a2e46 100644 (file)
@@ -2,7 +2,7 @@
 
 use strict;
 use warnings;
-use Test::More tests => 11;
+use Test::More;
 use_ok('Tie::Hash');
 
 tie my %tied, 'Tie::ExtraHash';
@@ -39,3 +39,4 @@ is_deeply(\%tied, \%hash, "CLEAR");
 # SCALAR
 is(scalar(%tied), scalar(%hash), "SCALAR");
 
+done_testing();
index 6c20d90..6f0848c 100644 (file)
@@ -5,7 +5,7 @@ BEGIN {
     @INC = '../lib';
 }
 
-use Test::More tests => 29;
+use Test::More;
 
 use_ok('Tie::StdHandle');
 
@@ -87,3 +87,5 @@ ok(eof($f), "eof");
 ok(close($f), "close");
 
 unlink("afile");
+
+done_testing();
index 0e95e5c..9de923f 100644 (file)
@@ -5,7 +5,7 @@ BEGIN {
     @INC = '../lib';
 }
 
-use Test::More tests => 1;
+use Test::More;
 
 use Tie::Handle;
 
@@ -16,3 +16,5 @@ use Tie::Handle;
 
 # For backwards compatibility with 5.8.x
 ok( Foo->can("TIEHANDLE"), "loading Tie::Handle loads TieStdHandle" );
+
+done_testing();
index c7b4ebe..fe43849 100644 (file)
@@ -2,7 +2,7 @@
 
 # These tests are not complete. Patches welcome.
 
-use Test::More tests => 3;
+use Test::More;
 
 BEGIN {use_ok( 'Tie::Hash' )};
 
@@ -11,3 +11,5 @@ for my $method (qw( TIEHASH EXISTS )) {
        eval { Tie::Hash->$method() };
        like( $@, qr/doesn't define an? $method/, "croaks on inherited $method()" );
 }
+
+done_testing();
index 4a6fcfa..3b860df 100644 (file)
@@ -16,7 +16,7 @@ sub new { 'Fooled you.' }
 package main;
 
 our $flag;
-use Test::More tests => 16;
+use Test::More;
 
 use_ok( 'Tie::Scalar' );
 
@@ -118,3 +118,5 @@ my $r2 = eval {tie my $foo => "InheritHasMethod2"; 1};
 
 ok $r1 && $called1, "inheriting new() does not croak";
 ok $r2 && $called2, "inheriting TIESCALAR() does not croak";
+
+done_testing();
index 54f6435..2ed85b8 100644 (file)
@@ -7,8 +7,6 @@ BEGIN {
     @times   = (-2**55, -2**50, -2**33, -2**31-1, -1, 0, 1, 2**31-1, 2**33, 2**50, 2**55, time);
     @methods = qw(sec min hour mday mon year wday yday isdst);
 
-    plan tests => (@times * (@methods + 1)) + 1;
-
     use_ok Time::gmtime;
 }
 
@@ -21,3 +19,5 @@ for my $time (@times) {
         is $gmtime->$method, shift @gmtime, "gmtime($time)->$method";
     }
 }
+
+done_testing();
index 0d75dcb..afafa6f 100644 (file)
@@ -7,8 +7,6 @@ BEGIN {
     @times   = (-2**55, -2**50, -2**33, -2**31-1, -1, 0, 1, 2**31-1, 2**33, 2**50, 2**55, time);
     @methods = qw(sec min hour mday mon year wday yday isdst);
 
-    plan tests => (@times * (@methods + 1)) + 1;
-
     use_ok Time::localtime;
 }
 
@@ -21,3 +19,5 @@ for my $time (@times) {
         is $localtime->$method, shift @localtime, "localtime($time)->$method";
     }
 }
+
+done_testing();
index 3002b6e..8f34762 100644 (file)
@@ -24,7 +24,6 @@ BEGIN {
 }
 
 BEGIN {
-    plan tests => 5;
     use_ok('User::grent');
 }
 
@@ -41,3 +40,4 @@ is( $grent->gid, $grent[2],     '   gid' );
 
 # Testing pretty much anything else is unportable.
 
+done_testing();
index 2ad9827..0da2447 100644 (file)
@@ -48,7 +48,7 @@ BEGIN {
     _cleanup( @blib_dirs );
 }
 
-use Test::More tests => 7;
+use Test::More;
 
 eval 'use blib;';
 ok( $@ =~ /Cannot find blib/, 'Fails if blib directory not found' );
@@ -81,4 +81,6 @@ else
 ok( grep(m|\Q$blib_lib\E$|, @INC[0,1])  == 1,     "  $blib_lib in \@INC");
 ok( grep(m|\Q$blib_arch\E$|, @INC[0,1]) == 1,     "  $blib_arch in \@INC");
 
+done_testing();
+
 END { _cleanup( @blib_dirs ); }
index 3e48b17..2cc4a52 100644 (file)
@@ -23,8 +23,6 @@ my @prgs;
 
 use Test::More;
 
-plan tests => scalar @prgs;
-
 require "dumpvar.pl";
 
 sub unctrl    { print dumpvar::unctrl($_[0]), "\n" }
@@ -84,6 +82,8 @@ for (@prgs) {
     }
 }
 
+done_testing();
+
 package TieOut;
 
 sub TIEHANDLE {
index 5088611..1a7074d 100644 (file)
@@ -6,7 +6,7 @@ BEGIN {
 }
 
 use Config;
-use Test::More tests => 15;
+use Test::More;
 
 # these two should be kept in sync with the pragma itself
 # if hint bits are changed there, other things *will* break
@@ -98,3 +98,5 @@ SKIP: {
     unlink $tstfile;
     warn "Can't remove $tstfile: $!" if -e $tstfile;
 }
+
+done_testing();
index 69746a5..426a7bc 100644 (file)
@@ -154,19 +154,6 @@ Writing $name/MANIFEST
 EOXSFILES
 );
 
-my $total_tests = 3; # opening, closing and deleting the header file.
-for (my $i = $#tests; $i > 0; $i-=3) {
-  # 1 test for running it, 1 test for the expected result, and 1 for each file
-  # plus 1 to open and 1 to check for the use in lib/$name.pm and Makefile.PL
-  # And 1 more for our check for "bonus" files, 2 more for ExtUtil::Manifest.
-  # And 1 more to examine const-c.inc contents in tests that use $header.
-  # use the () to force list context and hence count the number of matches.
-  $total_tests += 9 + (() = $tests[$i] =~ /(Writing)/sg);
-  $total_tests++ if $tests[$i-2] =~ / \Q$header\E$/;
-}
-
-plan tests => $total_tests;
-
 ok (open (HEADER, '>', $header), "open '$header'");
 print HEADER <<HEADER or die $!;
 #define Camel 2
@@ -253,3 +240,5 @@ while (my ($args, $version, $expectation) = splice @tests, 0, 3) {
 }
 
 cmp_ok (unlink ($header), "==", 1, "unlink '$header'") or die "\$! is $!";
+
+done_testing();
index c1bb4d0..7ad97b6 100644 (file)
@@ -7,7 +7,7 @@ BEGIN {
 
 use integer;
 
-use Test::More tests => 15;
+use Test::More;
 use Config;
 
 my $x = 4.5;
@@ -67,3 +67,5 @@ SKIP: {
     is($@, '', 'IV_MIN % -1 succeeds');
     is($biff, 0, 'IV_MIN % -1 == 0');
 }
+
+done_testing();
index 7713eb6..1d05961 100644 (file)
@@ -5,7 +5,7 @@ BEGIN {
     push @INC, '../lib';
 }
 
-use Test::More tests => 12;
+use Test::More;
 
 BEGIN {
     use_ok( 'less' );
@@ -34,3 +34,5 @@ use less 'random acts';
 is_deeply([sort less->of],[sort qw(random acts)],'less random acts');
 
 is(scalar less->of('random'),1,'less random');
+
+done_testing();
index f11f859..d95bc27 100644 (file)
@@ -11,7 +11,7 @@ BEGIN {
 }
 
 $| = 1;
-use Test::More 'tests' => 140;
+use Test::More;
 
 
 my $ii = 36028797018963971;  # 2^55 + 3
@@ -273,4 +273,4 @@ is($$oo, $cnt++, 'overload called once');
     }
 }
 
-# EOF
+done_testing();
index 85fc7e2..692d158 100644 (file)
@@ -1,6 +1,6 @@
 #./perl
 
-use Test::More tests => 50;
+use Test::More;
 
 use Scalar::Util qw(refaddr);
 
@@ -114,3 +114,5 @@ is( cos($x), "far side of overload table", "cosinusfies" );
 
     BEGIN { ok(!exists($^H{overloading}), "overloading hint removed") }
 }
+
+done_testing();
index 0e56bd0..1ba0664 100644 (file)
@@ -25,9 +25,7 @@ BEGIN {
 use strict;
 use warnings;
 
-use Test::More tests => @TestSizes * 2 # sort() tests
-                       * 3             # number of pragmas to test
-                       + 10;           # tests for sort::current
+use Test::More;
 
 # Generate array of specified size for testing sort.
 #
@@ -213,3 +211,5 @@ main(sub { sort {&{$_[0]}} @{$_[1]} }, 0);
     }
     is($sort_current, 'stable', 'sort::current for stable');
 }
+
+done_testing();
index 7681f07..dac97b6 100644 (file)
@@ -10,7 +10,7 @@ $perl = VMS::Filespec::vmsify($perl) if $^O eq 'VMS';
 
 my $Invoke_Perl = qq(MCR $perl "-I[-.lib]");
 
-use Test::More tests => 29;
+use Test::More;
 
 SKIP: {
     skip("tests for non-VMS only", 1) if $^O eq 'VMS';
@@ -183,6 +183,8 @@ is($?,0,"outer lex scope of vmsish [POSIX status]");
 }
 }
 
+done_testing();
+
 #====== need this to make sure error messages come out, even if
 #       they were turned off in invoking procedure
 sub do_a_perl {