Front page | perl.perl5.porters |
Postings from September 2010
Re: Test counts
Thread Previous
From:
Ben Morrow
Date:
September 5, 2010 15:06
Subject:
Re: Test counts
Message ID:
20100905220621.GA34827@osiris.mauzo.dyndns.org
Quoth sprout@cpan.org (Father Chrysostomos):
> Currently, if a patch adjusts a test count, it�s very likely going to
> conflict with any other patch modifying the same test file.
>
> There�s a test-counting technique I came up with, which I think I first
> used in CSS::DOM. It is to put an entry in %INC and create a
> tests::VERSION sub so that one can write
>
> use tests 2;
>
> before a block containing 2 tests. Then a CHECK routine calls plan()
> with the number of tests that has accumulated.
>
> Would it be good to add something like this to test.pl, or are we trying
> to avoid using too many Perl features in that script?
I would be wary of using something as relatively obscure as ->VERSION,
but there's no need at all to go that far. Before Schwern invented
done_testing, I used to routinely write my test scripts along the lines
of
require "test.pl";
my $tests;
plan($tests);
BEGIN { $tests += 3 }
# 3 tests
which may not be quite as neat but relies on far less Perl.
Is there some good reason why done_testing can't be added to test.pl
(and presumably the harnesses would need updating, too)? It's often Good
Enough, and *much* easier than tracking test counts.
Ben
Thread Previous