Subject: | PATCH: check for previous tests before running run_compare() |
If I understood the documentation correctly here:
NOTE: If you do not specify either a plan, or run any tests, the
run_compare function will automatically be run.
then I assume that running any tests in my file will cause Test::Base to
not run run_compare. However, I recently wrote a test file without a
plan but with tests, and Test::Base ran run_compare and as a result gave
me a bunch of difficult errors ("need two sections in first block"; it's
only really a difficult to understand error if you don't know that
run_compare is being run).
The patch I am attaching checks that no tests have been run before
running run_compare(). I am also attaching a MWE to show the bug. Just
unzip and run it with `perl -It t/tests.t` and you'll see some errors
output by Test::Base.
I'm sorry I can't submit a test for this functionality; I haven't the
slightest clue on how to check if a function was run without adding
another variable as a flag to the it.
Subject: | CheckForTests.patch |
diff --git a/lib/Test/Base.pm b/lib/Test/Base.pm
index fbd1cc2..7dc5ae7 100644
--- a/lib/Test/Base.pm
+++ b/lib/Test/Base.pm
@@ -290,7 +290,8 @@ sub _assert_plan {
}
sub END {
- run_compare() unless $Have_Plan or $DIED or not $import_called;
+ my $Test = Test::Builder->new;
+ run_compare() unless $Test->current_test() != 0 or $Have_Plan or $DIED or not $import_called;
}
sub run_compare() {
Subject: | t.zip |
Message body not shown because it is not plain text.