In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/6bdb88770f849c47b5c09e733ac460ce3e9dbc97?hp=7d16fb5f4895e672484c0b7490722d46df82b099>
- Log ----------------------------------------------------------------- commit 6bdb88770f849c47b5c09e733ac460ce3e9dbc97 Author: Chad Granum <[email protected]> Date: Fri Aug 15 08:40:10 2014 -0700 Update to include latest Test::Builder alpha Also updated some tests that the new builder broke ----------------------------------------------------------------------- Summary of changes: MANIFEST | 340 ++- Makefile.SH | 4 +- cpan/Test-Simple/lib/Test/Builder.pm | 3196 +++++++++----------- cpan/Test-Simple/lib/Test/Builder/ExitMagic.pm | 194 ++ cpan/Test-Simple/lib/Test/Builder/Fork.pm | 171 ++ cpan/Test-Simple/lib/Test/Builder/Formatter.pm | 180 ++ .../lib/Test/Builder/Formatter/LegacyResults.pm | 166 + cpan/Test-Simple/lib/Test/Builder/Formatter/TAP.pm | 447 +++ cpan/Test-Simple/lib/Test/Builder/Module.pm | 61 +- cpan/Test-Simple/lib/Test/Builder/Provider.pm | 463 +++ cpan/Test-Simple/lib/Test/Builder/Result.pm | 134 + cpan/Test-Simple/lib/Test/Builder/Result/Bail.pm | 116 + cpan/Test-Simple/lib/Test/Builder/Result/Child.pm | 146 + cpan/Test-Simple/lib/Test/Builder/Result/Diag.pm | 156 + cpan/Test-Simple/lib/Test/Builder/Result/Finish.pm | 111 + cpan/Test-Simple/lib/Test/Builder/Result/Note.pm | 120 + cpan/Test-Simple/lib/Test/Builder/Result/Ok.pm | 268 ++ cpan/Test-Simple/lib/Test/Builder/Result/Plan.pm | 135 + cpan/Test-Simple/lib/Test/Builder/Stream.pm | 684 +++++ cpan/Test-Simple/lib/Test/Builder/Tester.pm | 120 +- cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm | 3 +- cpan/Test-Simple/lib/Test/Builder/Threads.pm | 107 + cpan/Test-Simple/lib/Test/Builder/Trace.pm | 277 ++ cpan/Test-Simple/lib/Test/Builder/Trace/Frame.pm | 252 ++ cpan/Test-Simple/lib/Test/Builder/Util.pm | 443 +++ cpan/Test-Simple/lib/Test/FAQ.pod | 379 +++ cpan/Test-Simple/lib/Test/More.pm | 2030 +++++++------ cpan/Test-Simple/lib/Test/Simple.pm | 111 +- cpan/Test-Simple/lib/Test/Tester.pm | 642 ++++ cpan/Test-Simple/lib/Test/Tester/Capture.pm | 233 ++ cpan/Test-Simple/lib/Test/Tester/CaptureRunner.pm | 75 + cpan/Test-Simple/lib/Test/Tester/Delegate.pm | 32 + cpan/Test-Simple/lib/Test/Tester2.pm | 882 ++++++ cpan/Test-Simple/lib/Test/Tutorial.pod | 38 +- cpan/Test-Simple/lib/Test/use/ok.pm | 67 + cpan/Test-Simple/lib/ok.pm | 61 + cpan/Test-Simple/t/00test_harness_check.t | 2 +- cpan/Test-Simple/t/Builder/carp.t | 11 +- .../Test-Simple/t/Builder/done_testing_with_plan.t | 2 +- cpan/Test-Simple/t/Builder/fork_with_new_stdout.t | 44 +- cpan/Test-Simple/t/Builder/is_fh.t | 2 +- cpan/Test-Simple/t/Builder/maybe_regex.t | 2 +- cpan/Test-Simple/t/Builder/reset.t | 4 +- cpan/Test-Simple/t/Builder/reset_outputs.t | 35 + cpan/Test-Simple/t/Modern/Builder.t | 8 + cpan/Test-Simple/t/Modern/Builder_Fork.t | 41 + cpan/Test-Simple/t/Modern/Builder_Formatter.t | 32 + cpan/Test-Simple/t/Modern/Builder_Formatter_TAP.t | 20 + cpan/Test-Simple/t/Modern/Builder_Module.t | 15 + cpan/Test-Simple/t/Modern/Builder_Provider.t | 75 + cpan/Test-Simple/t/Modern/Builder_Result.t | 31 + cpan/Test-Simple/t/Modern/Builder_Result_Child.t | 22 + cpan/Test-Simple/t/Modern/Builder_Result_Diag.t | 37 + cpan/Test-Simple/t/Modern/Builder_Result_Finish.t | 15 + cpan/Test-Simple/t/Modern/Builder_Result_Note.t | 17 + cpan/Test-Simple/t/Modern/Builder_Result_Ok.t | 106 + cpan/Test-Simple/t/Modern/Builder_Result_Plan.t | 24 + cpan/Test-Simple/t/Modern/Builder_Stream.t | 8 + cpan/Test-Simple/t/Modern/Builder_Tester.t | 15 + cpan/Test-Simple/t/Modern/Builder_Trace.t | 16 + cpan/Test-Simple/t/Modern/Builder_Trace_Frame.t | 120 + cpan/Test-Simple/t/Modern/Builder_Util.t | 159 + cpan/Test-Simple/t/Modern/More.t | 149 + cpan/Test-Simple/t/Modern/NotTB15.t | 46 + cpan/Test-Simple/t/Modern/Simple.t | 17 + cpan/Test-Simple/t/Modern/Tester2.t | 273 ++ cpan/Test-Simple/t/Modern/Tester2_subtest.t | 66 + cpan/Test-Simple/t/Modern/encoding_test.t | 66 + cpan/Test-Simple/t/Modern/tracing.t | 222 ++ cpan/Test-Simple/t/More.t | 6 +- cpan/Test-Simple/t/PerlIO.t | 11 + cpan/Test-Simple/t/TTLegacy/auto.t | 34 + cpan/Test-Simple/t/TTLegacy/capture.t | 32 + cpan/Test-Simple/t/TTLegacy/check_tests.t | 117 + cpan/Test-Simple/t/TTLegacy/depth.t | 38 + cpan/Test-Simple/t/TTLegacy/run_test.t | 144 + cpan/Test-Simple/t/Tester/tbt_01basic.t | 2 +- cpan/Test-Simple/t/Tester/tbt_02fhrestore.t | 4 +- cpan/Test-Simple/t/Tester/tbt_06errormess.t | 2 +- cpan/Test-Simple/t/Tester/tbt_07args.t | 2 +- cpan/Test-Simple/t/Tester/tbt_is_bug.t | 31 + cpan/Test-Simple/t/circular_data.t | 2 +- cpan/Test-Simple/t/cmp_ok.t | 4 +- cpan/Test-Simple/t/died.t | 1 + cpan/Test-Simple/t/dont_overwrite_die_handler.t | 2 + cpan/Test-Simple/t/eq_set.t | 2 +- cpan/Test-Simple/t/exit.t | 5 +- cpan/Test-Simple/t/fail-like.t | 8 +- cpan/Test-Simple/t/fork.t | 2 +- cpan/Test-Simple/t/harness_active.t | 2 +- cpan/Test-Simple/t/is_deeply_fail.t | 4 +- cpan/Test-Simple/t/is_deeply_with_threads.t | 17 +- cpan/Test-Simple/t/lib/MyTest.pm | 15 + cpan/Test-Simple/t/lib/SmallTest.pm | 35 + cpan/Test-Simple/t/lib/Test/Builder/NoOutput.pm | 8 +- cpan/Test-Simple/t/no_tests.t | 1 + cpan/Test-Simple/t/overload.t | 2 +- cpan/Test-Simple/t/plan_no_plan.t | 4 + cpan/Test-Simple/t/pod-coverage.t | 29 + cpan/Test-Simple/t/pod.t | 7 + cpan/Test-Simple/t/ribasushi_diag.t | 54 + cpan/Test-Simple/t/ribasushi_threads.t | 75 + cpan/Test-Simple/t/skip.t | 13 +- cpan/Test-Simple/t/skipall.t | 2 +- cpan/Test-Simple/t/strays.t | 27 + cpan/Test-Simple/t/subtest/args.t | 19 + cpan/Test-Simple/t/subtest/bail_out.t | 4 +- cpan/Test-Simple/t/subtest/basic.t | 2 +- cpan/Test-Simple/t/subtest/fork.t | 12 +- cpan/Test-Simple/t/subtest/line_numbers.t | 16 +- cpan/Test-Simple/t/subtest/predicate.t | 12 +- cpan/Test-Simple/t/subtest/threads.t | 4 +- cpan/Test-Simple/t/subtest/todo.t | 5 +- cpan/Test-Simple/t/test_use_ok.t | 40 + cpan/Test-Simple/t/threads.t | 26 +- cpan/Test-Simple/t/todo.t | 12 +- cpan/Test-Simple/t/undef.t | 13 +- cpan/Test-Simple/t/utf8.t | 6 +- cpan/Test-Simple/t/versions.t | 13 +- dist/Carp/t/Carp.t | 19 +- ext/DynaLoader/t/DynaLoader.t | 16 +- lib/.gitignore | 1 + 122 files changed, 12530 insertions(+), 2980 deletions(-) create mode 100644 cpan/Test-Simple/lib/Test/Builder/ExitMagic.pm create mode 100644 cpan/Test-Simple/lib/Test/Builder/Fork.pm create mode 100644 cpan/Test-Simple/lib/Test/Builder/Formatter.pm create mode 100644 cpan/Test-Simple/lib/Test/Builder/Formatter/LegacyResults.pm create mode 100644 cpan/Test-Simple/lib/Test/Builder/Formatter/TAP.pm create mode 100644 cpan/Test-Simple/lib/Test/Builder/Provider.pm create mode 100644 cpan/Test-Simple/lib/Test/Builder/Result.pm create mode 100644 cpan/Test-Simple/lib/Test/Builder/Result/Bail.pm create mode 100644 cpan/Test-Simple/lib/Test/Builder/Result/Child.pm create mode 100644 cpan/Test-Simple/lib/Test/Builder/Result/Diag.pm create mode 100644 cpan/Test-Simple/lib/Test/Builder/Result/Finish.pm create mode 100644 cpan/Test-Simple/lib/Test/Builder/Result/Note.pm create mode 100644 cpan/Test-Simple/lib/Test/Builder/Result/Ok.pm create mode 100644 cpan/Test-Simple/lib/Test/Builder/Result/Plan.pm create mode 100644 cpan/Test-Simple/lib/Test/Builder/Stream.pm create mode 100644 cpan/Test-Simple/lib/Test/Builder/Threads.pm create mode 100644 cpan/Test-Simple/lib/Test/Builder/Trace.pm create mode 100644 cpan/Test-Simple/lib/Test/Builder/Trace/Frame.pm create mode 100644 cpan/Test-Simple/lib/Test/Builder/Util.pm create mode 100644 cpan/Test-Simple/lib/Test/FAQ.pod create mode 100644 cpan/Test-Simple/lib/Test/Tester.pm create mode 100644 cpan/Test-Simple/lib/Test/Tester/Capture.pm create mode 100644 cpan/Test-Simple/lib/Test/Tester/CaptureRunner.pm create mode 100644 cpan/Test-Simple/lib/Test/Tester/Delegate.pm create mode 100644 cpan/Test-Simple/lib/Test/Tester2.pm create mode 100644 cpan/Test-Simple/lib/Test/use/ok.pm create mode 100644 cpan/Test-Simple/lib/ok.pm create mode 100644 cpan/Test-Simple/t/Builder/reset_outputs.t create mode 100644 cpan/Test-Simple/t/Modern/Builder.t create mode 100644 cpan/Test-Simple/t/Modern/Builder_Fork.t create mode 100644 cpan/Test-Simple/t/Modern/Builder_Formatter.t create mode 100644 cpan/Test-Simple/t/Modern/Builder_Formatter_TAP.t create mode 100644 cpan/Test-Simple/t/Modern/Builder_Module.t create mode 100644 cpan/Test-Simple/t/Modern/Builder_Provider.t create mode 100644 cpan/Test-Simple/t/Modern/Builder_Result.t create mode 100644 cpan/Test-Simple/t/Modern/Builder_Result_Child.t create mode 100644 cpan/Test-Simple/t/Modern/Builder_Result_Diag.t create mode 100644 cpan/Test-Simple/t/Modern/Builder_Result_Finish.t create mode 100644 cpan/Test-Simple/t/Modern/Builder_Result_Note.t create mode 100644 cpan/Test-Simple/t/Modern/Builder_Result_Ok.t create mode 100644 cpan/Test-Simple/t/Modern/Builder_Result_Plan.t create mode 100644 cpan/Test-Simple/t/Modern/Builder_Stream.t create mode 100644 cpan/Test-Simple/t/Modern/Builder_Tester.t create mode 100644 cpan/Test-Simple/t/Modern/Builder_Trace.t create mode 100644 cpan/Test-Simple/t/Modern/Builder_Trace_Frame.t create mode 100644 cpan/Test-Simple/t/Modern/Builder_Util.t create mode 100644 cpan/Test-Simple/t/Modern/More.t create mode 100644 cpan/Test-Simple/t/Modern/NotTB15.t create mode 100644 cpan/Test-Simple/t/Modern/Simple.t create mode 100644 cpan/Test-Simple/t/Modern/Tester2.t create mode 100644 cpan/Test-Simple/t/Modern/Tester2_subtest.t create mode 100644 cpan/Test-Simple/t/Modern/encoding_test.t create mode 100644 cpan/Test-Simple/t/Modern/tracing.t create mode 100644 cpan/Test-Simple/t/PerlIO.t create mode 100644 cpan/Test-Simple/t/TTLegacy/auto.t create mode 100644 cpan/Test-Simple/t/TTLegacy/capture.t create mode 100644 cpan/Test-Simple/t/TTLegacy/check_tests.t create mode 100644 cpan/Test-Simple/t/TTLegacy/depth.t create mode 100644 cpan/Test-Simple/t/TTLegacy/run_test.t create mode 100644 cpan/Test-Simple/t/Tester/tbt_is_bug.t create mode 100644 cpan/Test-Simple/t/lib/MyTest.pm create mode 100644 cpan/Test-Simple/t/lib/SmallTest.pm create mode 100644 cpan/Test-Simple/t/pod-coverage.t create mode 100644 cpan/Test-Simple/t/pod.t create mode 100644 cpan/Test-Simple/t/ribasushi_diag.t create mode 100644 cpan/Test-Simple/t/ribasushi_threads.t create mode 100644 cpan/Test-Simple/t/strays.t create mode 100644 cpan/Test-Simple/t/test_use_ok.t diff --git a/MANIFEST b/MANIFEST index 8479f03..4ef6fda 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2233,146 +2233,214 @@ cpan/Test-Harness/t/yamlish-output.t Test::Harness test cpan/Test-Harness/t/yamlish.t Test::Harness test cpan/Test-Harness/t/yamlish-writer.t Test::Harness test cpan/Test/lib/Test.pm A simple framework for writing test scripts -cpan/Test-Simple/lib/Test/Builder/Module.pm Base class for test modules -cpan/Test-Simple/lib/Test/Builder.pm For writing new test libraries -cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm Turn on color in Test::Builder::Tester -cpan/Test-Simple/lib/Test/Builder/Tester.pm For testing Test::Builder based classes -cpan/Test-Simple/lib/Test/More.pm More utilities for writing tests -cpan/Test-Simple/lib/Test/Simple.pm Basic utility for writing tests -cpan/Test-Simple/lib/Test/Tutorial.pod A tutorial on writing tests -cpan/Test-Simple/t/00test_harness_check.t Test::Simple test -cpan/Test-Simple/t/bad_plan.t Test::Builder plan() test -cpan/Test-Simple/t/bail_out.t Test::Builder BAIL_OUT test -cpan/Test-Simple/t/BEGIN_require_ok.t Test::More require_ok() testing -cpan/Test-Simple/t/BEGIN_use_ok.t Test::More use_ok() testing -cpan/Test-Simple/t/buffer.t Test::Builder buffering test -cpan/Test-Simple/t/Builder/Builder.t Test::Builder tests -cpan/Test-Simple/t/Builder/carp.t Test::Builder test -cpan/Test-Simple/t/Builder/create.t Test::Builder test -cpan/Test-Simple/t/Builder/current_test.t Test::Builder tests -cpan/Test-Simple/t/Builder/current_test_without_plan.t Test::Builder tests -cpan/Test-Simple/t/Builder/details.t Test::Builder tests -cpan/Test-Simple/t/Builder/done_testing_double.t Test::Builder tests -cpan/Test-Simple/t/Builder/done_testing_plan_mismatch.t Test::Builder tests -cpan/Test-Simple/t/Builder/done_testing.t Test::Builder tests -cpan/Test-Simple/t/Builder/done_testing_with_no_plan.t Test::Builder tests -cpan/Test-Simple/t/Builder/done_testing_with_number.t Test::Builder tests -cpan/Test-Simple/t/Builder/done_testing_with_plan.t Test::Builder tests -cpan/Test-Simple/t/Builder/fork_with_new_stdout.t Test::Builder tests -cpan/Test-Simple/t/Builder/has_plan2.t Test::Builder tests -cpan/Test-Simple/t/Builder/has_plan.t Test::Builder tests -cpan/Test-Simple/t/Builder/is_fh.t Test::Builder tests -cpan/Test-Simple/t/Builder/is_passing.t Test::Builder tests -cpan/Test-Simple/t/Builder/maybe_regex.t Test::Builder tests -cpan/Test-Simple/t/Builder/no_diag.t Test::Builder tests -cpan/Test-Simple/t/Builder/no_ending.t Test::Builder tests -cpan/Test-Simple/t/Builder/no_header.t Test::Builder tests -cpan/Test-Simple/t/Builder/no_plan_at_all.t Test::Builder tests -cpan/Test-Simple/t/Builder/ok_obj.t Test::Builder tests -cpan/Test-Simple/t/Builder/output.t Test::Builder tests -cpan/Test-Simple/t/Builder/reset.t Test::Builder tests -cpan/Test-Simple/t/Builder/try.t Test::Builder tests -cpan/Test-Simple/t/c_flag.t Test::Simple test -cpan/Test-Simple/t/circular_data.t Test::Simple test -cpan/Test-Simple/t/cmp_ok.t Test::More test -cpan/Test-Simple/t/dependents.t Test::More test -cpan/Test-Simple/t/diag.t Test::More diag() test -cpan/Test-Simple/t/died.t Test::Simple test -cpan/Test-Simple/t/dont_overwrite_die_handler.t Test::More tests -cpan/Test-Simple/t/eq_set.t Test::Simple test -cpan/Test-Simple/t/exit.t Test::Simple test, exit codes -cpan/Test-Simple/t/explain.t Test::Simple test -cpan/Test-Simple/t/extra_one.t Test::Simple test -cpan/Test-Simple/t/extra.t Test::Simple test -cpan/Test-Simple/t/fail-like.t Test::More test, like() failures -cpan/Test-Simple/t/fail-more.t Test::More test, tests failing -cpan/Test-Simple/t/fail_one.t Test::Simple test -cpan/Test-Simple/t/fail.t Test::Simple test, test failures -cpan/Test-Simple/t/filehandles.t Test::Simple test, STDOUT can be played with -cpan/Test-Simple/t/fork.t Test::More fork tests -cpan/Test-Simple/t/harness_active.t Test::Simple test -cpan/Test-Simple/t/import.t Test::More test, importing functions -cpan/Test-Simple/t/is_deeply_dne_bug.t Test::More test -cpan/Test-Simple/t/is_deeply_fail.t Test::More test, is_deeply() -cpan/Test-Simple/t/is_deeply_with_threads.t Test::More test -cpan/Test-Simple/t/lib/Dev/Null.pm Test::More test module -cpan/Test-Simple/t/lib/Dummy.pm Test::More test module -cpan/Test-Simple/t/lib/MyOverload.pm Test::More test module -cpan/Test-Simple/t/lib/NoExporter.pm Test::Simple test module -cpan/Test-Simple/t/lib/SigDie.pm Test module for Test::More -cpan/Test-Simple/t/lib/Test/Builder/NoOutput.pm Utility module for testing Test::Builder -cpan/Test-Simple/t/lib/Test/Simple/Catch.pm Utility module for testing Test::Simple -cpan/Test-Simple/t/lib/Test/Simple/sample_tests/death_in_eval.plx for exit.t -cpan/Test-Simple/t/lib/Test/Simple/sample_tests/death.plx for exit.t -cpan/Test-Simple/t/lib/Test/Simple/sample_tests/death_with_handler.plx for exit.t -cpan/Test-Simple/t/lib/Test/Simple/sample_tests/exit.plx for exit.t -cpan/Test-Simple/t/lib/Test/Simple/sample_tests/extras.plx for exit.t -cpan/Test-Simple/t/lib/Test/Simple/sample_tests/five_fail.plx for exit.t -cpan/Test-Simple/t/lib/Test/Simple/sample_tests/last_minute_death.plx for exit.t -cpan/Test-Simple/t/lib/Test/Simple/sample_tests/missing_done_testing.plx for exit.t -cpan/Test-Simple/t/lib/Test/Simple/sample_tests/one_fail.plx for exit.t -cpan/Test-Simple/t/lib/Test/Simple/sample_tests/one_fail_without_plan.plx for exit.t -cpan/Test-Simple/t/lib/Test/Simple/sample_tests/pre_plan_death.plx for exit.t -cpan/Test-Simple/t/lib/Test/Simple/sample_tests/require.plx for exit.t -cpan/Test-Simple/t/lib/Test/Simple/sample_tests/success.plx for exit.t -cpan/Test-Simple/t/lib/Test/Simple/sample_tests/too_few_fail.plx for exit.t -cpan/Test-Simple/t/lib/Test/Simple/sample_tests/too_few.plx for exit.t -cpan/Test-Simple/t/lib/Test/Simple/sample_tests/two_fail.plx for exit.t -cpan/Test-Simple/t/lib/TieOut.pm Testing library to capture prints -cpan/Test-Simple/t/missing.t Test::Simple test, missing tests -cpan/Test-Simple/t/More.t Test::More test, basic stuff -cpan/Test-Simple/t/new_ok.t Test::More test -cpan/Test-Simple/t/no_plan.t Test::Simple test, forgot the plan -cpan/Test-Simple/t/no_tests.t Test::More test -cpan/Test-Simple/t/note.t Test::More test -cpan/Test-Simple/t/overload.t Test::Simple test -cpan/Test-Simple/t/overload_threads.t Test::Simple test -cpan/Test-Simple/t/plan_bad.t Test::Simple test -cpan/Test-Simple/t/plan_is_noplan.t Test::Simple test, no_plan -cpan/Test-Simple/t/plan_no_plan.t Test::More test, plan() w/no_plan -cpan/Test-Simple/t/plan_shouldnt_import.t Test::Simple test -cpan/Test-Simple/t/plan_skip_all.t Test::More test, plan() w/skip_all -cpan/Test-Simple/t/plan.t Test::More test, plan() -cpan/Test-Simple/t/require_ok.t Test::Simple test -cpan/Test-Simple/t/Simple/load.t Test::Builder tests -cpan/Test-Simple/t/simple.t Test::Simple test, basic stuff -cpan/Test-Simple/t/skipall.t Test::More test, skip all tests -cpan/Test-Simple/t/skip.t Test::More test, SKIP tests -cpan/Test-Simple/t/subtest/args.t Test::More test -cpan/Test-Simple/t/subtest/bail_out.t Test::More test -cpan/Test-Simple/t/subtest/basic.t Test::More test -cpan/Test-Simple/t/subtest/die.t Test::More test -cpan/Test-Simple/t/subtest/do.t Test::More test -cpan/Test-Simple/t/subtest/exceptions.t Test::More test -cpan/Test-Simple/t/subtest/for_do_t.test Test::More test -cpan/Test-Simple/t/subtest/fork.t Test::Builder tests -cpan/Test-Simple/t/subtest/implicit_done.t Test::Builder tests -cpan/Test-Simple/t/subtest/line_numbers.t Test::Builder tests -cpan/Test-Simple/t/subtest/plan.t Test::Builder tests -cpan/Test-Simple/t/subtest/predicate.t Test::Builder tests -cpan/Test-Simple/t/subtest/singleton.t Test::More test -cpan/Test-Simple/t/subtest/threads.t Test::More test -cpan/Test-Simple/t/subtest/todo.t Test::Builder tests -cpan/Test-Simple/t/subtest/wstat.t Test::More test -cpan/Test-Simple/t/tbm_doesnt_set_exported_to.t Test::Builder::Module test +cpan/Test-Simple/lib/ok.pm Tool for testing module loading +cpan/Test-Simple/lib/Test/Builder/ExitMagic.pm Handle $? when tests exit +cpan/Test-Simple/lib/Test/Builder/Fork.pm Forking support for Test::Builder +cpan/Test-Simple/lib/Test/Builder/Formatter/LegacyResults.pm Legacy support +cpan/Test-Simple/lib/Test/Builder/Formatter.pm Base class for formatters +cpan/Test-Simple/lib/Test/Builder/Formatter/TAP.pm TAP formatter +cpan/Test-Simple/lib/Test/Builder/Module.pm Deprecated tester base class +cpan/Test-Simple/lib/Test/Builder.pm The meat of Test::Builder +cpan/Test-Simple/lib/Test/Builder/Provider.pm Tool for building testers +cpan/Test-Simple/lib/Test/Builder/Result/Bail.pm Bail result +cpan/Test-Simple/lib/Test/Builder/Result/Child.pm Child result +cpan/Test-Simple/lib/Test/Builder/Result/Diag.pm Diag result +cpan/Test-Simple/lib/Test/Builder/Result/Finish.pm Finish result +cpan/Test-Simple/lib/Test/Builder/Result/Note.pm Note result +cpan/Test-Simple/lib/Test/Builder/Result/Ok.pm Ok result +cpan/Test-Simple/lib/Test/Builder/Result/Plan.pm Plan result +cpan/Test-Simple/lib/Test/Builder/Result.pm Result base class +cpan/Test-Simple/lib/Test/Builder/Stream.pm The test stream +cpan/Test-Simple/lib/Test/Builder/Tester/Color.pm Part of Test::Tester +cpan/Test-Simple/lib/Test/Builder/Tester.pm Tool for validating testers +cpan/Test-Simple/lib/Test/Builder/Threads.pm Thread utisl for Test::Builder +cpan/Test-Simple/lib/Test/Builder/Trace/Frame.pm Frame in a stack trace +cpan/Test-Simple/lib/Test/Builder/Trace.pm Tool for building and analyzing stack traces +cpan/Test-Simple/lib/Test/Builder/Util.pm Common utils used throughout Test::Builder +cpan/Test-Simple/lib/Test/FAQ.pod Frequently Asked Questions +cpan/Test-Simple/lib/Test/More.pm More tools for testing +cpan/Test-Simple/lib/Test/Simple.pm tools for testing +cpan/Test-Simple/lib/Test/Tester2.pm Tool for testing testers +cpan/Test-Simple/lib/Test/Tester/Capture.pm Part of Test::Tester +cpan/Test-Simple/lib/Test/Tester/CaptureRunner.pm Part of Test::Tester +cpan/Test-Simple/lib/Test/Tester/Delegate.pm Part of Test::Tester +cpan/Test-Simple/lib/Test/Tester.pm Tool for testing testers +cpan/Test-Simple/lib/Test/Tutorial.pod Testing Tutorial +cpan/Test-Simple/lib/Test/use/ok.pm Tool for testing module loading +cpan/Test-Simple/t/00test_harness_check.t Test::Builder legacy test +cpan/Test-Simple/t/bad_plan.t Test::Builder legacy test +cpan/Test-Simple/t/bail_out.t Test::Builder legacy test +cpan/Test-Simple/t/BEGIN_require_ok.t Test::Builder legacy test +cpan/Test-Simple/t/BEGIN_use_ok.t Test::Builder legacy test +cpan/Test-Simple/t/buffer.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/Builder.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/carp.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/create.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/current_test.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/current_test_without_plan.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/details.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/done_testing_double.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/done_testing_plan_mismatch.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/done_testing.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/done_testing_with_no_plan.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/done_testing_with_number.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/done_testing_with_plan.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/fork_with_new_stdout.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/has_plan2.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/has_plan.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/is_fh.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/is_passing.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/maybe_regex.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/no_diag.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/no_ending.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/no_header.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/no_plan_at_all.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/ok_obj.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/output.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/reset_outputs.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/reset.t Test::Builder legacy test +cpan/Test-Simple/t/Builder/try.t Test::Builder legacy test +cpan/Test-Simple/t/c_flag.t Test::Builder legacy test +cpan/Test-Simple/t/circular_data.t Test::Builder legacy test +cpan/Test-Simple/t/cmp_ok.t Test::Builder legacy test +cpan/Test-Simple/t/dependents.t Test::Builder legacy test +cpan/Test-Simple/t/diag.t Test::Builder legacy test +cpan/Test-Simple/t/died.t Test::Builder legacy test +cpan/Test-Simple/t/dont_overwrite_die_handler.t Test::Builder legacy test +cpan/Test-Simple/t/eq_set.t Test::Builder legacy test +cpan/Test-Simple/t/exit.t Test::Builder legacy test +cpan/Test-Simple/t/explain.t Test::Builder legacy test +cpan/Test-Simple/t/extra_one.t Test::Builder legacy test +cpan/Test-Simple/t/extra.t Test::Builder legacy test +cpan/Test-Simple/t/fail-like.t Test::Builder legacy test +cpan/Test-Simple/t/fail-more.t Test::Builder legacy test +cpan/Test-Simple/t/fail_one.t Test::Builder legacy test +cpan/Test-Simple/t/fail.t Test::Builder legacy test +cpan/Test-Simple/t/filehandles.t Test::Builder legacy test +cpan/Test-Simple/t/fork.t Test::Builder legacy test +cpan/Test-Simple/t/harness_active.t Test::Builder legacy test +cpan/Test-Simple/t/import.t Test::Builder legacy test +cpan/Test-Simple/t/is_deeply_dne_bug.t Test::Builder legacy test +cpan/Test-Simple/t/is_deeply_fail.t Test::Builder legacy test +cpan/Test-Simple/t/is_deeply_with_threads.t Test::Builder legacy test +cpan/Test-Simple/t/lib/Dev/Null.pm Test helper module +cpan/Test-Simple/t/lib/Dummy.pm Test helper module +cpan/Test-Simple/t/lib/MyOverload.pm Test helper module +cpan/Test-Simple/t/lib/MyTest.pm Test helper module +cpan/Test-Simple/t/lib/NoExporter.pm Test helper module +cpan/Test-Simple/t/lib/SigDie.pm Test helper module +cpan/Test-Simple/t/lib/SmallTest.pm Test helper module +cpan/Test-Simple/t/lib/Test/Builder/NoOutput.pm Test helper module +cpan/Test-Simple/t/lib/Test/Simple/Catch.pm Test helper module +cpan/Test-Simple/t/lib/Test/Simple/sample_tests/death_in_eval.plx Sample test used in tests +cpan/Test-Simple/t/lib/Test/Simple/sample_tests/death.plx Sample test used in tests +cpan/Test-Simple/t/lib/Test/Simple/sample_tests/death_with_handler.plx Sample test used in tests +cpan/Test-Simple/t/lib/Test/Simple/sample_tests/exit.plx Sample test used in tests +cpan/Test-Simple/t/lib/Test/Simple/sample_tests/extras.plx Sample test used in tests +cpan/Test-Simple/t/lib/Test/Simple/sample_tests/five_fail.plx Sample test used in tests +cpan/Test-Simple/t/lib/Test/Simple/sample_tests/last_minute_death.plx Sample test used in tests +cpan/Test-Simple/t/lib/Test/Simple/sample_tests/missing_done_testing.plx Sample test used in tests +cpan/Test-Simple/t/lib/Test/Simple/sample_tests/one_fail.plx Sample test used in tests +cpan/Test-Simple/t/lib/Test/Simple/sample_tests/one_fail_without_plan.plx Sample test used in tests +cpan/Test-Simple/t/lib/Test/Simple/sample_tests/pre_plan_death.plx Sample test used in tests +cpan/Test-Simple/t/lib/Test/Simple/sample_tests/require.plx Sample test used in tests +cpan/Test-Simple/t/lib/Test/Simple/sample_tests/success.plx Sample test used in tests +cpan/Test-Simple/t/lib/Test/Simple/sample_tests/too_few_fail.plx Sample test used in tests +cpan/Test-Simple/t/lib/Test/Simple/sample_tests/too_few.plx Sample test used in tests +cpan/Test-Simple/t/lib/Test/Simple/sample_tests/two_fail.plx Sample test used in tests +cpan/Test-Simple/t/lib/TieOut.pm Test helper module +cpan/Test-Simple/t/missing.t Test::Builder legacy test +cpan/Test-Simple/t/Modern/Builder_Fork.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/Builder_Formatter.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/Builder_Formatter_TAP.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/Builder_Module.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/Builder_Provider.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/Builder_Result_Child.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/Builder_Result_Diag.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/Builder_Result_Finish.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/Builder_Result_Note.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/Builder_Result_Ok.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/Builder_Result_Plan.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/Builder_Result.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/Builder_Stream.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/Builder.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/Builder_Tester.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/Builder_Trace_Frame.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/Builder_Trace.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/Builder_Util.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/encoding_test.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/More.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/NotTB15.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/Simple.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/Tester2_subtest.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/Tester2.t Test for modern Test::Builder features +cpan/Test-Simple/t/Modern/tracing.t Test for modern Test::Builder features +cpan/Test-Simple/t/More.t Legacy test for Test::Builder +cpan/Test-Simple/t/new_ok.t Legacy test for Test::Builder +cpan/Test-Simple/t/no_plan.t Legacy test for Test::Builder +cpan/Test-Simple/t/no_tests.t Legacy test for Test::Builder +cpan/Test-Simple/t/note.t Legacy test for Test::Builder +cpan/Test-Simple/t/overload.t Legacy test for Test::Builder +cpan/Test-Simple/t/overload_threads.t Legacy test for Test::Builder +cpan/Test-Simple/t/PerlIO.t Legacy test for Test::Builder +cpan/Test-Simple/t/plan_bad.t Legacy test for Test::Builder +cpan/Test-Simple/t/plan_is_noplan.t Legacy test for Test::Builder +cpan/Test-Simple/t/plan_no_plan.t Legacy test for Test::Builder +cpan/Test-Simple/t/plan_shouldnt_import.t Legacy test for Test::Builder +cpan/Test-Simple/t/plan_skip_all.t Legacy test for Test::Builder +cpan/Test-Simple/t/plan.t Legacy test for Test::Builder +cpan/Test-Simple/t/pod-coverage.t Legacy test for Test::Builder +cpan/Test-Simple/t/pod.t Legacy test for Test::Builder +cpan/Test-Simple/t/require_ok.t Legacy test for Test::Builder +cpan/Test-Simple/t/ribasushi_diag.t Legacy test for Test::Builder +cpan/Test-Simple/t/ribasushi_threads.t Legacy test for Test::Builder +cpan/Test-Simple/t/Simple/load.t Legacy test for Test::Builder +cpan/Test-Simple/t/simple.t Legacy test for Test::Builder +cpan/Test-Simple/t/skipall.t Legacy test for Test::Builder +cpan/Test-Simple/t/skip.t Legacy test for Test::Builder +cpan/Test-Simple/t/strays.t Legacy test for Test::Builder +cpan/Test-Simple/t/subtest/args.t Legacy subtest test +cpan/Test-Simple/t/subtest/bail_out.t Legacy subtest test +cpan/Test-Simple/t/subtest/basic.t Legacy subtest test +cpan/Test-Simple/t/subtest/die.t Legacy subtest test +cpan/Test-Simple/t/subtest/do.t Legacy subtest test +cpan/Test-Simple/t/subtest/exceptions.t Legacy subtest test +cpan/Test-Simple/t/subtest/for_do_t.test Legacy subtest test +cpan/Test-Simple/t/subtest/fork.t Legacy subtest test +cpan/Test-Simple/t/subtest/implicit_done.t Legacy subtest test +cpan/Test-Simple/t/subtest/line_numbers.t Legacy subtest test +cpan/Test-Simple/t/subtest/plan.t Legacy subtest test +cpan/Test-Simple/t/subtest/predicate.t Legacy subtest test +cpan/Test-Simple/t/subtest/singleton.t Legacy subtest test +cpan/Test-Simple/t/subtest/threads.t Legacy subtest test +cpan/Test-Simple/t/subtest/todo.t Legacy subtest test +cpan/Test-Simple/t/subtest/wstat.t Legacy subtest test +cpan/Test-Simple/t/tbm_doesnt_set_exported_to.t Legacy test cpan/Test-Simple/t/Tester/tbt_01basic.t Test::Builder::Tester test -cpan/Test-Simple/t/Tester/tbt_02fhrestore.t Test::Builder::Tester test +cpan/Test-Simple/t/Tester/tbt_02fhrestore.t Test::Builder::Tester test cpan/Test-Simple/t/Tester/tbt_03die.t Test::Builder::Tester test -cpan/Test-Simple/t/Tester/tbt_04line_num.t Test::Builder::Tester test -cpan/Test-Simple/t/Tester/tbt_05faildiag.t Test::Builder::Tester test -cpan/Test-Simple/t/Tester/tbt_06errormess.t Test::Builder::Tester test +cpan/Test-Simple/t/Tester/tbt_04line_num.t Test::Builder::Tester test +cpan/Test-Simple/t/Tester/tbt_05faildiag.t Test::Builder::Tester test +cpan/Test-Simple/t/Tester/tbt_06errormess.t Test::Builder::Tester test cpan/Test-Simple/t/Tester/tbt_07args.t Test::Builder::Tester test -cpan/Test-Simple/t/Tester/tbt_08subtest.t Test::Builder::Tester test -cpan/Test-Simple/t/Tester/tbt_09do_script.pl Test::Builder::Tester test +cpan/Test-Simple/t/Tester/tbt_08subtest.t Test::Builder::Tester test +cpan/Test-Simple/t/Tester/tbt_09do_script.pl Test::Builder::Tester test cpan/Test-Simple/t/Tester/tbt_09do.t Test::Builder::Tester test -cpan/Test-Simple/t/threads.t Test::Builder thread-safe checks -cpan/Test-Simple/t/thread_taint.t Test::Simple test -cpan/Test-Simple/t/todo.t Test::More test, TODO tests -cpan/Test-Simple/t/undef.t Test::More test, undefs don't cause warnings -cpan/Test-Simple/t/useing.t Test::More test, compile test -cpan/Test-Simple/t/use_ok.t Test::More test, use_ok() -cpan/Test-Simple/t/utf8.t Test::More test -cpan/Test-Simple/t/versions.t Test::More test +cpan/Test-Simple/t/Tester/tbt_is_bug.t Test::Builder::Tester test +cpan/Test-Simple/t/test_use_ok.t Legacy Test::Builder::Test +cpan/Test-Simple/t/threads.t Legacy Test::Builder::Test +cpan/Test-Simple/t/thread_taint.t Legacy Test::Builder::Test +cpan/Test-Simple/t/todo.t Legacy Test::Builder::Test +cpan/Test-Simple/t/TTLegacy/auto.t Test for old Test::Tester +cpan/Test-Simple/t/TTLegacy/capture.t Test for old Test::Tester +cpan/Test-Simple/t/TTLegacy/check_tests.t Test for old Test::Tester +cpan/Test-Simple/t/TTLegacy/depth.t Test for old Test::Tester +cpan/Test-Simple/t/TTLegacy/run_test.t Test for old Test::Tester +cpan/Test-Simple/t/undef.t Legacy Test::Builder test +cpan/Test-Simple/t/useing.t Legacy Test::Builder test +cpan/Test-Simple/t/use_ok.t Legacy Test::Builder test +cpan/Test-Simple/t/utf8.t Legacy Test::Builder test +cpan/Test-Simple/t/versions.t Test for Test::Builder version numbers cpan/Test/t/05_about_verbose.t See if Test works cpan/Test/t/fail.t See if Test works cpan/Test/t/mix.t See if Test works diff --git a/Makefile.SH b/Makefile.SH index 85fd312..f5e83ba 100755 --- a/Makefile.SH +++ b/Makefile.SH @@ -1297,7 +1297,9 @@ _cleaner2: -rmdir lib/autodie/Scope lib/autodie lib/XS lib/Win32API lib/VMS -rmdir lib/Unicode/Collate/Locale lib/Unicode/Collate/CJK -rmdir lib/Unicode/Collate lib/Tie/Hash lib/Thread lib/Text - -rmdir lib/Test/Builder/Tester lib/Test/Builder lib/Test lib/Term + -rmdir lib/Test/use lib/Test/Tester lib/Test/Builder/Trace + -rmdir lib/Test/Builder/Tester lib/Test/Builder/Result + -rmdir lib/Test/Builder/Formatter lib/Test/Builder lib/Test lib/Term -rmdir lib/TAP/Parser/YAMLish lib/TAP/Parser/SourceHandler -rmdir lib/TAP/Parser/Scheduler lib/TAP/Parser/Result -rmdir lib/TAP/Parser/Iterator lib/TAP/Parser lib/TAP/Harness diff --git a/cpan/Test-Simple/lib/Test/Builder.pm b/cpan/Test-Simple/lib/Test/Builder.pm index 00a3ec5..bc88477 100644 --- a/cpan/Test-Simple/lib/Test/Builder.pm +++ b/cpan/Test-Simple/lib/Test/Builder.pm @@ -1,153 +1,74 @@ package Test::Builder; -use 5.006; +use 5.008001; use strict; use warnings; -our $VERSION = '1.001003'; +use Test::Builder::Util qw/try protect/; +use Scalar::Util(); +use Test::Builder::Stream; +use Test::Builder::Result; +use Test::Builder::Result::Ok; +use Test::Builder::Result::Diag; +use Test::Builder::Result::Note; +use Test::Builder::Result::Plan; +use Test::Builder::Result::Bail; +use Test::Builder::Result::Child; +use Test::Builder::Trace; + +our $VERSION = '1.301001_034'; $VERSION = eval $VERSION; ## no critic (BuiltinFunctions::ProhibitStringyEval) -BEGIN { - if( $] < 5.008 ) { - require Test::Builder::IO::Scalar; - } -} - - -# Make Test::Builder thread-safe for ithreads. -BEGIN { - use Config; - # Load threads::shared when threads are turned on. - # 5.8.0's threads are so busted we no longer support them. - if( $] >= 5.008001 && $Config{useithreads} && $INC{'threads.pm'} ) { - require threads::shared; - - # Hack around YET ANOTHER threads::shared bug. It would - # occasionally forget the contents of the variable when sharing it. - # So we first copy the data, then share, then put our copy back. - *share = sub (\[$@%]) { - my $type = ref $_[0]; - my $data; - - if( $type eq 'HASH' ) { - %$data = %{ $_[0] }; - } - elsif( $type eq 'ARRAY' ) { - @$data = @{ $_[0] }; - } - elsif( $type eq 'SCALAR' ) { - $$data = ${ $_[0] }; - } - else { - die( "Unknown type: " . $type ); - } +# The mostly-singleton, and other package vars. +our $Test = Test::Builder->new; +our $Level = 1; +our $BLevel = 1; - $_[0] = &threads::shared::share( $_[0] ); - - if( $type eq 'HASH' ) { - %{ $_[0] } = %$data; - } - elsif( $type eq 'ARRAY' ) { - @{ $_[0] } = @$data; - } - elsif( $type eq 'SCALAR' ) { - ${ $_[0] } = $$data; - } - else { - die( "Unknown type: " . $type ); - } +#################### +# {{{ MAGIC things # +#################### - return $_[0]; - }; - } - # 5.8.0's threads::shared is busted when threads are off - # and earlier Perls just don't have that module at all. - else { - *share = sub { return $_[0] }; - *lock = sub { 0 }; +sub DESTROY { + my $self = shift; + if ( $self->parent and $$ == $self->{Original_Pid} ) { + my $name = $self->name; + $self->parent->{In_Destroy} = 1; + $self->parent->ok(0, $name, "Child ($name) exited without calling finalize()\n"); } } -=head1 NAME - -Test::Builder - Backend for building test libraries - -=head1 SYNOPSIS - - package My::Test::Module; - use base 'Test::Builder::Module'; - - my $CLASS = __PACKAGE__; - - sub ok { - my($test, $name) = @_; - my $tb = $CLASS->builder; - - $tb->ok($test, $name); - } - - -=head1 DESCRIPTION - -Test::Simple and Test::More have proven to be popular testing modules, -but they're not always flexible enough. Test::Builder provides a -building block upon which to write your own test libraries I<which can -work together>. - -=head2 Construction - -=over 4 - -=item B<new> - - my $Test = Test::Builder->new; - -Returns a Test::Builder object representing the current state of the -test. - -Since you only run one test per program C<new> always returns the same -Test::Builder object. No matter how many times you call C<new()>, you're -getting the same object. This is called a singleton. This is done so that -multiple modules share such global information as the test counter and -where test output is going. - -If you want a completely new Test::Builder object different from the -singleton, use C<create>. +require Test::Builder::ExitMagic; +my $final = Test::Builder::ExitMagic->new( + tb => Test::Builder->create(shared_stream => 1), +); +END { $final->do_magic() } -=cut +#################### +# }}} MAGIC things # +#################### -our $Test = Test::Builder->new; +#################### +# {{{ Constructors # +#################### sub new { - my($class) = shift; - $Test ||= $class->create; + my $class = shift; + my %params = @_; + $Test ||= $class->create(shared_stream => 1); + return $Test; } -=item B<create> - - my $Test = Test::Builder->create; - -Ok, so there can be more than one Test::Builder object and this is how -you get it. You might use this instead of C<new()> if you're testing -a Test::Builder based module, but otherwise you probably want C<new>. - -B<NOTE>: the implementation is not complete. C<level>, for example, is -still shared amongst B<all> Test::Builder objects, even ones created using -this method. Also, the method name may change in the future. - -=cut - sub create { my $class = shift; + my %params = @_; my $self = bless {}, $class; - $self->reset; + $self->reset(%params); return $self; } - # Copy an object, currently a shallow. # This does *not* bless the destination. This keeps the destructor from # firing when we're just storing a copy of the object to restore later. @@ -155,114 +76,154 @@ sub _copy { my($src, $dest) = @_; %$dest = %$src; - _share_keys($dest); + #_share_keys($dest); # Not sure the implications here. return; } +#################### +# }}} Constructors # +#################### -=item B<child> +############################################## +# {{{ Simple accessors/generators/deligators # +############################################## - my $child = $builder->child($name_of_child); - $child->plan( tests => 4 ); - $child->ok(some_code()); - ... - $child->finalize; +sub listen { shift->stream->listen(@_) } +sub munge { shift->stream->munge(@_) } +sub tap { shift->stream->tap } +sub lresults { shift->stream->lresults } +sub is_passing { shift->stream->is_passing(@_) } +sub use_fork { shift->stream->use_fork } +sub no_fork { shift->stream->no_fork } -Returns a new instance of C<Test::Builder>. Any output from this child will -be indented four spaces more than the parent's indentation. When done, the -C<finalize> method I<must> be called explicitly. +BEGIN { + Test::Builder::Util::accessors(qw/Parent Name _old_level _bailed_out default_name/); + Test::Builder::Util::accessor(modern => sub {$ENV{TB_MODERN} || 0}); + Test::Builder::Util::accessor(depth => sub { 0 }); +} -Trying to create a new child with a previous child still active (i.e., -C<finalize> not called) will C<croak>. +############################################## +# }}} Simple accessors/generators/deligators # +############################################## -Trying to run a test when you have an open child will also C<croak> and cause -the test suite to fail. +######################### +# {{{ Stream Management # +######################### + +sub stream { + my $self = shift; + + ($self->{stream}) = @_ if @_; -=cut + # If no stream is set use shared. We do not want to cache that we use + # shared cause shared is a stack, not a constant, and we always want the + # top. + return $self->{stream} || Test::Builder::Stream->shared; +} + +sub intercept { + my $self = shift; + my ($code) = @_; + + Carp::croak("argument to intercept must be a coderef, got: $code") + unless reftype $code eq 'CODE'; + + my $stream = Test::Builder::Stream->new(no_follow => 1) || die "Internal Error!"; + $stream->exception_followup; + + local $self->{stream} = $stream; + + my @results; + $stream->listen(INTERCEPTOR => sub { + my ($item) = @_; + push @results => $item; + }); + $code->($stream); + + return \@results; +} + +######################### +# }}} Stream Management # +######################### + +############################# +# {{{ Children and subtests # +############################# sub child { - my( $self, $name ) = @_; + my( $self, $name, $is_subtest ) = @_; - if( $self->{Child_Name} ) { - $self->croak("You already have a child named ($self->{Child_Name}) running"); - } + $self->croak("You already have a child named ($self->{Child_Name}) running") + if $self->{Child_Name}; my $parent_in_todo = $self->in_todo; # Clear $TODO for the child. my $orig_TODO = $self->find_TODO(undef, 1, undef); - my $class = ref $self; + my $class = Scalar::Util::blessed($self); my $child = $class->create; - # Add to our indentation - $child->_indent( $self->_indent . ' ' ); - - # Make the child use the same outputs as the parent - for my $method (qw(output failure_output todo_output)) { - $child->$method( $self->$method ); - } + $child->{stream} = $self->stream->spawn; # Ensure the child understands if they're inside a TODO - if( $parent_in_todo ) { - $child->failure_output( $self->todo_output ); - } + $child->tap->failure_output($self->tap->todo_output) + if $parent_in_todo && $self->tap; # This will be reset in finalize. We do this here lest one child failure # cause all children to fail. $child->{Child_Error} = $?; $? = 0; + $child->{Parent} = $self; $child->{Parent_TODO} = $orig_TODO; $child->{Name} = $name || "Child of " . $self->name; - $self->{Child_Name} = $child->name; - return $child; -} + $self->{Child_Name} = $child->name; -=item B<subtest> - - $builder->subtest($name, \&subtests); + $child->depth($self->depth + 1); -See documentation of C<subtest> in Test::More. + my $res = Test::Builder::Result::Child->new( + $self->context, + name => $child->name, + action => 'push', + in_todo => $self->in_todo || 0, + is_subtest => $is_subtest || 0, + ); + $self->stream->send($res); -=cut + return $child; +} sub subtest { my $self = shift; - my($name, $subtests) = @_; + my($name, $subtests, @args) = @_; - if ('CODE' ne ref $subtests) { - $self->croak("subtest()'s second argument must be a code ref"); - } + $self->croak("subtest()'s second argument must be a code ref") + unless $subtests && 'CODE' eq Scalar::Util::reftype($subtests); # Turn the child into the parent so anyone who has stored a copy of # the Test::Builder singleton will get the child. - my $error; - my $child; + my ($success, $error, $child); my $parent = {}; { - # child() calls reset() which sets $Level to 1, so we localize - # $Level first to limit the scope of the reset to the subtest. - local $Test::Builder::Level = $Test::Builder::Level + 1; + local $Level = $Level + 1; local $BLevel = $BLevel + 1; # Store the guts of $self as $parent and turn $child into $self. - $child = $self->child($name); + $child = $self->child($name, 1); + _copy($self, $parent); _copy($child, $self); my $run_the_subtests = sub { - # Add subtest name for clarification of starting point - $self->note("Subtest: $name"); - $subtests->(); - $self->done_testing unless $self->_plan_handled; + $subtests->(@args); + $self->done_testing unless defined $self->stream->plan; 1; }; - if( !eval { $run_the_subtests->() } ) { - $error = $@; - } + ($success, $error) = try { Test::Builder::Trace->nest($run_the_subtests) }; } # Restore the parent and the copied child. @@ -273,68 +234,19 @@ sub subtest { $self->find_TODO(undef, 1, $child->{Parent_TODO}); # Die *after* we restore the parent. - die $error if $error and !eval { $error->isa('Test::Builder::Exception') }; + die $error if $error && !(Scalar::Util::blessed($error) && $error->isa('Test::Builder::Exception')); - local $Test::Builder::Level = $Test::Builder::Level + 1; - my $finalize = $child->finalize; + local $Level = $Level + 1; local $BLevel = $BLevel + 1; + my $finalize = $child->finalize(1); - $self->BAIL_OUT($child->{Bailed_Out_Reason}) if $child->{Bailed_Out}; + $self->BAIL_OUT($child->{Bailed_Out_Reason}) if $child->_bailed_out; return $finalize; } -=begin _private - -=item B<_plan_handled> - - if ( $Test->_plan_handled ) { ... } - -Returns true if the developer has explicitly handled the plan via: - -=over 4 - -=item * Explicitly setting the number of tests - -=item * Setting 'no_plan' - -=item * Set 'skip_all'. - -=back - -This is currently used in subtests when we implicitly call C<< $Test->done_testing >> -if the developer has not set a plan. - -=end _private - -=cut - -sub _plan_handled { - my $self = shift; - return $self->{Have_Plan} || $self->{No_Plan} || $self->{Skip_All}; -} - - -=item B<finalize> - - my $ok = $child->finalize; - -When your child is done running tests, you must call C<finalize> to clean up -and tell the parent your pass/fail status. - -Calling finalize on a child with open children will C<croak>. - -If the child falls out of scope before C<finalize> is called, a failure -diagnostic will be issued and the child is considered to have failed. - -No attempt to call methods on a child after C<finalize> is called is -guaranteed to succeed. - -Calling this on the root builder is a no-op. - -=cut - sub finalize { my $self = shift; + my ($is_subtest) = @_; return unless $self->parent; if( $self->{Child_Name} ) { @@ -344,568 +256,720 @@ sub finalize { local $? = 0; # don't fail if $subtests happened to set $? nonzero $self->_ending; - # XXX This will only be necessary for TAP envelopes (we think) - #$self->_print( $self->is_passing ? "PASS\n" : "FAIL\n" ); - - local $Test::Builder::Level = $Test::Builder::Level + 1; + local $Level = $Level + 1; local $BLevel = $BLevel + 1; my $ok = 1; $self->parent->{Child_Name} = undef; - unless ($self->{Bailed_Out}) { + + unless ($self->_bailed_out) { if ( $self->{Skip_All} ) { $self->parent->skip($self->{Skip_All}); } - elsif ( not @{ $self->{Test_Results} } ) { + elsif ( ! $self->stream->tests_run ) { $self->parent->ok( 0, sprintf q[No tests run for subtest "%s"], $self->name ); } else { $self->parent->ok( $self->is_passing, $self->name ); } } + $? = $self->{Child_Error}; - delete $self->{Parent}; + my $parent = delete $self->{Parent}; + + my $res = Test::Builder::Result::Child->new( + $self->context, + name => $self->{Name} || undef, + action => 'pop', + in_todo => $self->in_todo || 0, + is_subtest => $is_subtest || 0, + ); + $parent->stream->send($res); return $self->is_passing; } -sub _indent { - my $self = shift; +############################# +# }}} Children and subtests # +############################# - if( @_ ) { - $self->{Indent} = shift; - } +##################################### +# {{{ Finding Testers and Providers # +##################################### - return $self->{Indent}; +sub trace_test { + my $out; + protect { $out = Test::Builder::Trace->new }; + return $out; } -=item B<parent> - - if ( my $parent = $builder->parent ) { - ... - } +sub find_TODO { + my( $self, $pack, $set, $new_value ) = @_; -Returns the parent C<Test::Builder> instance, if any. Only used with child -builders for nested TAP. + $pack ||= $self->trace_test->todo_package || $self->exported_to; + return unless $pack; -=cut + no strict 'refs'; ## no critic + no warnings 'once'; + my $old_value = ${ $pack . '::TODO' }; + $set and ${ $pack . '::TODO' } = $new_value; + return $old_value; +} -sub parent { shift->{Parent} } +##################################### +# }}} Finding Testers and Providers # +##################################### -=item B<name> +################ +# {{{ Planning # +################ - diag $builder->name; +my %PLAN_CMDS = ( + no_plan => 'no_plan', + skip_all => 'skip_all', + tests => '_plan_tests', +); -Returns the name of the current builder. Top level builders default to C<$0> -(the name of the executable). Child builders are named via the C<child> -method. If no name is supplied, will be named "Child of $parent->name". +sub plan { + my( $self, $cmd, $arg ) = @_; -=cut + return unless $cmd; -sub name { shift->{Name} } + local $Level = $Level + 1; local $BLevel = $BLevel + 1; -sub DESTROY { - my $self = shift; - if ( $self->parent and $$ == $self->{Original_Pid} ) { - my $name = $self->name; - $self->diag(<<"FAIL"); -Child ($name) exited without calling finalize() -FAIL - $self->parent->{In_Destroy} = 1; - $self->parent->ok(0, $name); + if( my $method = $PLAN_CMDS{$cmd} ) { + local $Level = $Level + 1; local $BLevel = $BLevel + 1; + $self->$method($arg); + } + else { + my @args = grep { defined } ( $cmd, $arg ); + $self->croak("plan() doesn't understand @args"); } + + return 1; } -=item B<reset> +sub skip_all { + my( $self, $reason ) = @_; - $Test->reset; + $self->{Skip_All} = $self->parent ? $reason : 1; -Reinitializes the Test::Builder singleton to its original state. -Mostly useful for tests run in persistent environments where the same -test might be run multiple times in the same process. + die bless {} => 'Test::Builder::Exception' if $self->parent; + $self->_issue_plan(0, "SKIP", $reason); +} -=cut +sub no_plan { + my($self, $arg) = @_; -our $Level; + $self->carp("no_plan takes no arguments") if $arg; -sub reset { ## no critic (Subroutines::ProhibitBuiltinHomonyms) - my($self) = @_; + $self->_issue_plan(undef, "NO_PLAN"); - # We leave this a global because it has to be localized and localizing - # hash keys is just asking for pain. Also, it was documented. - $Level = 1; + return 1; +} - $self->{Name} = $0; - $self->is_passing(1); - $self->{Ending} = 0; - $self->{Have_Plan} = 0; - $self->{No_Plan} = 0; - $self->{Have_Output_Plan} = 0; - $self->{Done_Testing} = 0; +sub _plan_tests { + my($self, $arg) = @_; - $self->{Original_Pid} = $$; - $self->{Child_Name} = undef; - $self->{Indent} ||= ''; + if($arg) { + $self->croak("Number of tests must be a positive integer. You gave it '$arg'") + unless $arg =~ /^\+?\d+$/; - $self->{Curr_Test} = 0; - $self->{Test_Results} = &share( [] ); + $self->_issue_plan($arg); + } + elsif( !defined $arg ) { + $self->croak("Got an undefined number of tests"); + } + else { + $self->croak("You said to run 0 tests"); + } - $self->{Exported_To} = undef; - $self->{Expected_Tests} = 0; + return; +} - $self->{Skip_All} = 0; +sub _issue_plan { + my($self, $max, $directive, $reason) = @_; - $self->{Use_Nums} = 1; + if ($directive && $directive eq 'OVERRIDE') { + $directive = undef; + } + elsif ($self->stream->plan) { + $self->croak("You tried to plan twice"); + } - $self->{No_Header} = 0; - $self->{No_Ending} = 0; + my $plan = Test::Builder::Result::Plan->new( + $self->context, + directive => $directive || undef, + reason => $reason || undef, + in_todo => $self->in_todo || 0, - $self->{Todo} = undef; - $self->{Todo_Stack} = []; - $self->{Start_Todo} = 0; - $self->{Opened_Testhandles} = 0; + max => defined($max) ? $max : undef, + ); - $self->_share_keys; - $self->_dup_stdhandles; + $self->stream->send($plan); - return; + return $plan; } +sub done_testing { + my($self, $num_tests) = @_; -# Shared scalar values are lost when a hash is copied, so we have -# a separate method to restore them. -# Shared references are retained across copies. -sub _share_keys { - my $self = shift; + my $expected = $self->stream->expected_tests; + my $total = $self->stream->tests_run; - share( $self->{Curr_Test} ); + # If done_testing() specified the number of tests, shut off no_plan. + if(defined $num_tests && !defined $expected) { + $self->_issue_plan($num_tests, 'OVERRIDE'); + $expected = $num_tests; + } - return; -} + if( $self->{Done_Testing} ) { + my($file, $line) = @{$self->{Done_Testing}}[1,2]; + my $ok = Test::Builder::Result::Ok->new( + $self->context, + real_bool => 0, + name => "done_testing() was already called at $file line $line", + bool => $self->in_todo ? 1 : 0, + in_todo => $self->in_todo || 0, + todo => $self->in_todo ? $self->todo() || "" : "", + ); + $self->stream->send($ok); + $self->is_passing(0) unless $self->in_todo; + return; + } -=back + $self->{Done_Testing} = [caller]; -=head2 Setting up tests + if ($expected && defined($num_tests) && $num_tests != $expected) { + my $ok = Test::Builder::Result::Ok->new( + $self->context, + real_bool => 0, + name => "planned to run $expected but done_testing() expects $num_tests", + bool => $self->in_todo ? 1 : 0, + in_todo => $self->in_todo || 0, + todo => $self->in_todo ? $self->todo() || "" : "", + ); + $self->stream->send($ok); + $self->is_passing(0) unless $self->in_todo; + } -These methods are for setting up tests and declaring how many there -are. You usually only want to call one of these methods. -=over 4 + $self->_issue_plan($total) unless $expected; -=item B<plan> + # The wrong number of tests were run + $self->is_passing(0) if defined $expected && $expected != $total; - $Test->plan('no_plan'); - $Test->plan( skip_all => $reason ); - $Test->plan( tests => $num_tests ); + # No tests were run + $self->is_passing(0) unless $total; -A convenient way to set up your tests. Call this and Test::Builder -will print the appropriate headers and take the appropriate actions. + return 1; +} -If you call C<plan()>, don't call any of the other methods below. +################ +# }}} Planning # +################ -If a child calls "skip_all" in the plan, a C<Test::Builder::Exception> is -thrown. Trap this error, call C<finalize()> and don't run any more tests on -the child. +############################# +# {{{ Base Result Producers # +############################# - my $child = $Test->child('some child'); - eval { $child->plan( $condition ? ( skip_all => $reason ) : ( tests => 3 ) ) }; - if ( eval { $@->isa('Test::Builder::Exception') } ) { - $child->finalize; - return; - } - # run your tests +sub _ok_obj { + my $self = shift; + my( $test, $name, @diag ) = @_; -=cut + if ( $self->{Child_Name} and not $self->{In_Destroy} ) { + $name = 'unnamed test' unless defined $name; + $self->is_passing(0); + $self->croak("Cannot run test ($name) with active children"); + } -my %plan_cmds = ( - no_plan => \&no_plan, - skip_all => \&skip_all, - tests => \&_plan_tests, -); + # $test might contain an object which we don't want to accidentally + # store, so we turn it into a boolean. + $test = $test ? 1 : 0; -sub plan { - my( $self, $cmd, $arg ) = @_; + # In case $name is a string overloaded object, force it to stringify. + $self->_unoverload_str( \$name ); - return unless $cmd; + # Capture the value of $TODO for the rest of this ok() call + # so it can more easily be found by other routines. + my $todo = $self->todo(); + my $in_todo = $self->in_todo; + local $self->{Todo} = $todo if $in_todo; - local $Level = $Level + 1; + $self->_unoverload_str( \$todo ); - $self->croak("You tried to plan twice") if $self->{Have_Plan}; + my $ok = Test::Builder::Result::Ok->new( + $self->context, + real_bool => $test, + bool => $self->in_todo ? 1 : $test, + name => $name || $self->default_name || undef, + in_todo => $self->in_todo || 0, + diag => \@diag, + ); - if( my $method = $plan_cmds{$cmd} ) { - local $Level = $Level + 1; - $self->$method($arg); + # # in a name can confuse Test::Harness. + $name =~ s|#|\\#|g if defined $name; + + if( $self->in_todo ) { + $ok->todo($todo); + $ok->in_todo(1); } - else { - my @args = grep { defined } ( $cmd, $arg ); - $self->croak("plan() doesn't understand @args"); + + if (defined $name and $name =~ /^[\d\s]+$/) { + $ok->diag(<<" ERR"); + You named your test '$name'. You shouldn't use numbers for your test names. + Very confusing. + ERR } - return 1; + return $ok; } +sub ok { + my $self = shift; + my( $test, $name, @diag ) = @_; -sub _plan_tests { - my($self, $arg) = @_; + my $ok = $self->_ok_obj($test, $name, @diag); + $self->_record_ok($ok); - if($arg) { - local $Level = $Level + 1; - return $self->expected_tests($arg); - } - elsif( !defined $arg ) { - $self->croak("Got an undefined number of tests"); - } - else { - $self->croak("You said to run 0 tests"); - } - - return; + return $test ? 1 : 0; } -=item B<expected_tests> - - my $max = $Test->expected_tests; - $Test->expected_tests($max); +sub _record_ok { + my $self = shift; + my ($ok) = @_; -Gets/sets the number of tests we expect this test to run and prints out -the appropriate headers. + $self->stream->send($ok); -=cut + $self->is_passing(0) unless $ok->real_bool || $self->in_todo; -sub expected_tests { - my $self = shift; - my($max) = @_; + # Check that we haven't violated the plan + $self->_check_is_passing_plan(); +} - if(@_) { - $self->croak("Number of tests must be a positive integer. You gave it '$max'") - unless $max =~ /^\+?\d+$/; +sub BAIL_OUT { + my( $self, $reason ) = @_; - $self->{Expected_Tests} = $max; - $self->{Have_Plan} = 1; + $self->_bailed_out(1); - $self->_output_plan($max) unless $self->no_header; + if ($self->parent) { + $self->{Bailed_Out_Reason} = $reason; + $self->no_ending(1); + die bless {} => 'Test::Builder::Exception'; } - return $self->{Expected_Tests}; + + my $bail = Test::Builder::Result::Bail->new( + $self->context, + reason => $reason, + in_todo => $self->in_todo || 0, + ); + $self->stream->send($bail); } -=item B<no_plan> +sub skip { + my( $self, $why ) = @_; + $why ||= ''; + $self->_unoverload_str( \$why ); - $Test->no_plan; + my $ok = Test::Builder::Result::Ok->new( + $self->context, + real_bool => 1, + bool => 1, + in_todo => $self->in_todo || 0, + skip => $why, + ); -Declares that this test will run an indeterminate number of tests. + $self->stream->send($ok); +} -=cut +sub todo_skip { + my( $self, $why ) = @_; + $why ||= ''; -sub no_plan { - my($self, $arg) = @_; + my $ok = Test::Builder::Result::Ok->new( + $self->context, + real_bool => 0, + bool => 1, + in_todo => $self->in_todo || 0, + skip => $why, + todo => $why, + ); - $self->carp("no_plan takes no arguments") if $arg; + $self->stream->send($ok); +} - $self->{No_Plan} = 1; - $self->{Have_Plan} = 1; +sub diag { + my $self = shift; - return 1; -} + my $msg = join '', map { defined($_) ? $_ : 'undef' } @_; -=begin private + my $r = Test::Builder::Result::Diag->new( + $self->context, + in_todo => $self->in_todo || 0, + message => $msg, + ); + $self->stream->send($r); +} -=item B<_output_plan> +sub note { + my $self = shift; - $tb->_output_plan($max); - $tb->_output_plan($max, $directive); - $tb->_output_plan($max, $directive => $reason); + my $msg = join '', map { defined($_) ? $_ : 'undef' } @_; -Handles displaying the test plan. + my $r = Test::Builder::Result::Note->new( + $self->context, + in_todo => $self->in_todo || 0, + message => $msg, + ); + $self->stream->send($r); +} -If a C<$directive> and/or C<$reason> are given they will be output with the -plan. So here's what skipping all tests looks like: +############################# +# }}} Base Result Producers # +############################# - $tb->_output_plan(0, "SKIP", "Because I said so"); +################################# +# {{{ Advanced Result Producers # +################################# -It sets C<< $tb->{Have_Output_Plan} >> and will croak if the plan was already -output. +my %numeric_cmps = map { ( $_, 1 ) } ( "<", "<=", ">", ">=", "==", "!=", "<=>" ); -=end private +# Bad, these are not comparison operators. Should we include more? +my %cmp_ok_bl = map { ( $_, 1 ) } ( "=", "+=", ".=", "x=", "^=", "|=", "||=", "&&=", "..."); -=cut +sub cmp_ok { + my( $self, $got, $type, $expect, $name ) = @_; -sub _output_plan { - my($self, $max, $directive, $reason) = @_; + if ($cmp_ok_bl{$type}) { + $self->croak("$type is not a valid comparison operator in cmp_ok()"); + } - $self->carp("The plan was already output") if $self->{Have_Output_Plan}; + my $test; + my $error; + my @diag; - my $plan = "1..$max"; - $plan .= " # $directive" if defined $directive; - $plan .= " $reason" if defined $reason; + my($pack, $file, $line) = $self->trace_test->report->call; - $self->_print("$plan\n"); + (undef, $error) = try { + # This is so that warnings come out at the caller's level + ## no critic (BuiltinFunctions::ProhibitStringyEval) + eval qq[ +#line $line "(eval in cmp_ok) $file" +\$test = \$got $type \$expect; +1; + ] || die $@; + }; - $self->{Have_Output_Plan} = 1; + # Treat overloaded objects as numbers if we're asked to do a + # numeric comparison. + my $unoverload + = $numeric_cmps{$type} + ? '_unoverload_num' + : '_unoverload_str'; - return; -} + push @diag => <<"END" if $error; +An error occurred while using $type: +------------------------------------ +$error +------------------------------------ +END + unless($test) { + $self->$unoverload( \$got, \$expect ); -=item B<done_testing> + if( $type =~ /^(eq|==)$/ ) { + push @diag => $self->_is_diag( $got, $type, $expect ); + } + elsif( $type =~ /^(ne|!=)$/ ) { + push @diag => $self->_isnt_diag( $got, $type ); + } + else { + push @diag => $self->_cmp_diag( $got, $type, $expect ); + } + } - $Test->done_testing(); - $Test->done_testing($num_tests); + local $Level = $Level + 1; local $BLevel = $BLevel + 1; + $self->ok($test, $name, @diag); -Declares that you are done testing, no more tests will be run after this point. + return $test ? 1 : 0; +} -If a plan has not yet been output, it will do so. -$num_tests is the number of tests you planned to run. If a numbered -plan was already declared, and if this contradicts, a failing test -will be run to reflect the planning mistake. If C<no_plan> was declared, -this will override. +sub is_eq { + my( $self, $got, $expect, $name ) = @_; + local $Level = $Level + 1; local $BLevel = $BLevel + 1; -If C<done_testing()> is called twice, the second call will issue a -failing test. + if( !defined $got || !defined $expect ) { + # undef only matches undef and nothing else + my $test = !defined $got && !defined $expect; -If C<$num_tests> is omitted, the number of tests run will be used, like -no_plan. + $self->ok($test, $name, $test ? () : $self->_is_diag( $got, 'eq', $expect )); + return $test; + } -C<done_testing()> is, in effect, used when you'd want to use C<no_plan>, but -safer. You'd use it like so: + return $self->cmp_ok( $got, 'eq', $expect, $name ); +} - $Test->ok($a == $b); - $Test->done_testing(); +sub is_num { + my( $self, $got, $expect, $name ) = @_; + local $Level = $Level + 1; local $BLevel = $BLevel + 1; -Or to plan a variable number of tests: + if( !defined $got || !defined $expect ) { + # undef only matches undef and nothing else + my $test = !defined $got && !defined $expect; - for my $test (@tests) { - $Test->ok($test); + $self->ok($test, $name, $test ? () : $self->_is_diag( $got, '==', $expect )); + return $test; } - $Test->done_testing(scalar @tests); -=cut + return $self->cmp_ok( $got, '==', $expect, $name ); +} -sub done_testing { - my($self, $num_tests) = @_; +sub isnt_eq { + my( $self, $got, $dont_expect, $name ) = @_; + local $Level = $Level + 1; local $BLevel = $BLevel + 1; - # If done_testing() specified the number of tests, shut off no_plan. - if( defined $num_tests ) { - $self->{No_Plan} = 0; - } - else { - $num_tests = $self->current_test; - } + if( !defined $got || !defined $dont_expect ) { + # undef only matches undef and nothing else + my $test = defined $got || defined $dont_expect; - if( $self->{Done_Testing} ) { - my($file, $line) = @{$self->{Done_Testing}}[1,2]; - $self->ok(0, "done_testing() was already called at $file line $line"); - return; + $self->ok( $test, $name, $test ? () : $self->_isnt_diag( $got, 'ne' )); + return $test; } - $self->{Done_Testing} = [caller]; + return $self->cmp_ok( $got, 'ne', $dont_expect, $name ); +} - if( $self->expected_tests && $num_tests != $self->expected_tests ) { - $self->ok(0, "planned to run @{[ $self->expected_tests ]} ". - "but done_testing() expects $num_tests"); - } - else { - $self->{Expected_Tests} = $num_tests; - } +sub isnt_num { + my( $self, $got, $dont_expect, $name ) = @_; + local $Level = $Level + 1; local $BLevel = $BLevel + 1; - $self->_output_plan($num_tests) unless $self->{Have_Output_Plan}; + if( !defined $got || !defined $dont_expect ) { + # undef only matches undef and nothing else + my $test = defined $got || defined $dont_expect; - $self->{Have_Plan} = 1; + $self->ok( $test, $name, $test ? () : $self->_isnt_diag( $got, '!=' )); + return $test; + } - # The wrong number of tests were run - $self->is_passing(0) if $self->{Expected_Tests} != $self->{Curr_Test}; + return $self->cmp_ok( $got, '!=', $dont_expect, $name ); +} - # No tests were run - $self->is_passing(0) if $self->{Curr_Test} == 0; +sub like { + my( $self, $thing, $regex, $name ) = @_; + local $Level = $Level + 1; local $BLevel = $BLevel + 1; - return 1; + return $self->_regex_ok( $thing, $regex, '=~', $name ); } +sub unlike { + my( $self, $thing, $regex, $name ) = @_; + local $Level = $Level + 1; local $BLevel = $BLevel + 1; -=item B<has_plan> + return $self->_regex_ok( $thing, $regex, '!~', $name ); +} - $plan = $Test->has_plan -Find out whether a plan has been defined. C<$plan> is either C<undef> (no plan -has been set), C<no_plan> (indeterminate # of tests) or an integer (the number -of expected tests). -=cut +################################# +# }}} Advanced Result Producers # +################################# -sub has_plan { - my $self = shift; +####################### +# {{{ Public helpers # +####################### - return( $self->{Expected_Tests} ) if $self->{Expected_Tests}; - return('no_plan') if $self->{No_Plan}; - return(undef); -} +sub explain { + my $self = shift; -=item B<skip_all> + return map { + ref $_ + ? do { + $self->_try(sub { require Data::Dumper }, die_on_fail => 1); - $Test->skip_all; - $Test->skip_all($reason); + my $dumper = Data::Dumper->new( [$_] ); + $dumper->Indent(1)->Terse(1); + $dumper->Sortkeys(1) if $dumper->can("Sortkeys"); + $dumper->Dump; + } + : $_ + } @_; +} -Skips all the tests, using the given C<$reason>. Exits immediately with 0. +sub carp { + my $self = shift; + return warn $self->_message_at_caller(@_); +} -=cut +sub croak { + my $self = shift; + return die $self->_message_at_caller(@_); +} -sub skip_all { - my( $self, $reason ) = @_; +sub context { + my $self = shift; - $self->{Skip_All} = $self->parent ? $reason : 1; + my $trace = $self->trace_test; - $self->_output_plan(0, "SKIP", $reason) unless $self->no_header; - if ( $self->parent ) { - die bless {} => 'Test::Builder::Exception'; - } - exit(0); + return ( + depth => $self->depth, + source => $self->name || "", + trace => $trace, + ); } -=item B<exported_to> +sub has_plan { + my $self = shift; - my $pack = $Test->exported_to; - $Test->exported_to($pack); + return($self->stream->expected_tests) if $self->stream->expected_tests; + return('no_plan') if $self->stream->plan; + return(undef); +} -Tells Test::Builder what package you exported your functions to. +sub reset { ## no critic (Subroutines::ProhibitBuiltinHomonyms) + my $self = shift; + my %params; -This method isn't terribly useful since modules which share the same -Test::Builder object might get exported to different packages and only -the last one will be honored. + if (@_) { + %params = @_; + $self->{reset_params} = \%params; + } + else { + %params = %{$self->{reset_params} || {}}; + } -=cut + my $modern = $params{modern} || $self->modern || 0; + $self->modern($modern); -sub exported_to { - my( $self, $pack ) = @_; + # We leave this a global because it has to be localized and localizing + # hash keys is just asking for pain. Also, it was documented. + $Level = 1; + $BLevel = 1; - if( defined $pack ) { - $self->{Exported_To} = $pack; + if ($params{new_stream} || !$params{shared_stream}) { + my $olds = $self->stream; + $self->{stream} = Test::Builder::Stream->new; + $self->{stream}->use_lresults if $olds->lresults; } - return $self->{Exported_To}; -} - -=back -=head2 Running tests + $final->pid($$) if $final; -These actually run the tests, analogous to the functions in Test::More. + $self->stream->use_tap unless $params{no_tap} || $ENV{TB_NO_TAP}; -They all return true if the test passed, false if the test failed. + $self->stream->plan(undef) unless $params{no_reset_plan}; -C<$name> is always optional. - -=over 4 + # Don't reset stream stuff when reseting/creating a modern TB object + unless ($modern) { + $self->stream->no_ending(0); + $self->tap->reset if $self->tap; + $self->lresults->reset if $self->lresults; + } -=item B<ok> + $self->{Name} = $0; - $Test->ok($test, $name); + $self->{Have_Issued_Plan} = 0; + $self->{Done_Testing} = 0; + $self->{Skip_All} = 0; -Your basic test. Pass if C<$test> is true, fail if $test is false. Just -like Test::Simple's C<ok()>. + $self->{Original_Pid} = $$; + $self->{Child_Name} = undef; + $self->{Indent} ||= ''; + $self->{Depth} = 0; -=cut + $self->{Exported_To} = undef; + $self->{Expected_Tests} = 0; -sub ok { - my( $self, $test, $name ) = @_; + $self->{Todo} = undef; + $self->{Todo_Stack} = []; + $self->{Start_Todo} = 0; + $self->{Opened_Testhandles} = 0; - if ( $self->{Child_Name} and not $self->{In_Destroy} ) { - $name = 'unnamed test' unless defined $name; - $self->is_passing(0); - $self->croak("Cannot run test ($name) with active children"); - } - # $test might contain an object which we don't want to accidentally - # store, so we turn it into a boolean. - $test = $test ? 1 : 0; + return; +} - lock $self->{Curr_Test}; - $self->{Curr_Test}++; - # In case $name is a string overloaded object, force it to stringify. - $self->_unoverload_str( \$name ); +####################### +# }}} Public helpers # +####################### - $self->diag(<<"ERR") if defined $name and $name =~ /^[\d\s]+$/; - You named your test '$name'. You shouldn't use numbers for your test names. - Very confusing. -ERR +#################### +# {{{ TODO related # +#################### - # Capture the value of $TODO for the rest of this ok() call - # so it can more easily be found by other routines. - my $todo = $self->todo(); - my $in_todo = $self->in_todo; - local $self->{Todo} = $todo if $in_todo; +sub todo { + my( $self, $pack ) = @_; - $self->_unoverload_str( \$todo ); + return $self->{Todo} if defined $self->{Todo}; - my $out; - my $result = &share( {} ); + local $Level = $Level + 1; local $BLevel = $BLevel + 1; + my $todo = $self->find_TODO($pack); + return $todo if defined $todo; - unless($test) { - $out .= "not "; - @$result{ 'ok', 'actual_ok' } = ( ( $self->in_todo ? 1 : 0 ), 0 ); - } - else { - @$result{ 'ok', 'actual_ok' } = ( 1, $test ); - } + return ''; +} - $out .= "ok"; - $out .= " $self->{Curr_Test}" if $self->use_numbers; +sub in_todo { + my $self = shift; - if( defined $name ) { - $name =~ s|#|\\#|g; # # in a name can confuse Test::Harness. - $out .= " - $name"; - $result->{name} = $name; - } - else { - $result->{name} = ''; - } + local $Level = $Level + 1; local $BLevel = $BLevel + 1; + return( defined $self->{Todo} || $self->find_TODO ) ? 1 : 0; +} + +sub todo_start { + my $self = shift; + my $message = @_ ? shift : ''; + $self->{Start_Todo}++; if( $self->in_todo ) { - $out .= " # TODO $todo"; - $result->{reason} = $todo; - $result->{type} = 'todo'; - } - else { - $result->{reason} = ''; - $result->{type} = ''; + push @{ $self->{Todo_Stack} } => $self->todo; } + $self->{Todo} = $message; - $self->{Test_Results}[ $self->{Curr_Test} - 1 ] = $result; - $out .= "\n"; - - $self->_print($out); + return; +} - unless($test) { - my $msg = $self->in_todo ? "Failed (TODO)" : "Failed"; - $self->_print_to_fh( $self->_diag_fh, "\n" ) if $ENV{HARNESS_ACTIVE}; +sub todo_end { + my $self = shift; - my( undef, $file, $line ) = $self->caller; - if( defined $name ) { - $self->diag(qq[ $msg test '$name'\n]); - $self->diag(qq[ at $file line $line.\n]); - } - else { - $self->diag(qq[ $msg test at $file line $line.\n]); - } + if( !$self->{Start_Todo} ) { + $self->croak('todo_end() called without todo_start()'); } - $self->is_passing(0) unless $test || $self->in_todo; + $self->{Start_Todo}--; - # Check that we haven't violated the plan - $self->_check_is_passing_plan(); + if( $self->{Start_Todo} && @{ $self->{Todo_Stack} } ) { + $self->{Todo} = pop @{ $self->{Todo_Stack} }; + } + else { + delete $self->{Todo}; + } - return $test ? 1 : 0; + return; } +#################### +# }}} TODO related # +#################### + +####################### +# {{{ Private helpers # +####################### # Check that we haven't yet violated the plan and set # is_passing() accordingly sub _check_is_passing_plan { my $self = shift; - my $plan = $self->has_plan; + my $plan = $self->stream->expected_tests; return unless defined $plan; # no plan yet defined return unless $plan !~ /\D/; # no numeric plan - $self->is_passing(0) if $plan < $self->{Curr_Test}; + $self->is_passing(0) if $plan < $self->stream->tests_run; } +sub _is_object { + my( $self, $thing ) = @_; + + return $self->_try( sub { ref $thing && $thing->isa('UNIVERSAL') } ) ? 1 : 0; +} sub _unoverload { my $self = shift; @@ -924,12 +988,6 @@ sub _unoverload { return; } -sub _is_object { - my( $self, $thing ) = @_; - - return $self->_try( sub { ref $thing && $thing->isa('UNIVERSAL') } ) ? 1 : 0; -} - sub _unoverload_str { my $self = shift; @@ -961,58 +1019,6 @@ sub _is_dualvar { return ($numval != 0 and $numval ne $val ? 1 : 0); } -=item B<is_eq> - - $Test->is_eq($got, $expected, $name); - -Like Test::More's C<is()>. Checks if C<$got eq $expected>. This is the -string version. - -C<undef> only ever matches another C<undef>. - -=item B<is_num> - - $Test->is_num($got, $expected, $name); - -Like Test::More's C<is()>. Checks if C<$got == $expected>. This is the -numeric version. - -C<undef> only ever matches another C<undef>. - -=cut - -sub is_eq { - my( $self, $got, $expect, $name ) = @_; - local $Level = $Level + 1; - - if( !defined $got || !defined $expect ) { - # undef only matches undef and nothing else - my $test = !defined $got && !defined $expect; - - $self->ok( $test, $name ); - $self->_is_diag( $got, 'eq', $expect ) unless $test; - return $test; - } - - return $self->cmp_ok( $got, 'eq', $expect, $name ); -} - -sub is_num { - my( $self, $got, $expect, $name ) = @_; - local $Level = $Level + 1; - - if( !defined $got || !defined $expect ) { - # undef only matches undef and nothing else - my $test = !defined $got && !defined $expect; - - $self->ok( $test, $name ); **** PATCH TRUNCATED AT 2000 LINES -- 16537 NOT SHOWN **** -- Perl5 Master Repository
