diff options
Diffstat (limited to 'cpan/Test-Simple/t/subtest')
-rw-r--r-- | cpan/Test-Simple/t/subtest/bail_out.t | 59 | ||||
-rw-r--r-- | cpan/Test-Simple/t/subtest/basic.t | 5 | ||||
-rw-r--r-- | cpan/Test-Simple/t/subtest/line_numbers.t | 5 | ||||
-rw-r--r-- | cpan/Test-Simple/t/subtest/predicate.t | 12 | ||||
-rw-r--r-- | cpan/Test-Simple/t/subtest/threads.t | 25 | ||||
-rw-r--r-- | cpan/Test-Simple/t/subtest/todo.t | 1 |
6 files changed, 100 insertions, 7 deletions
diff --git a/cpan/Test-Simple/t/subtest/bail_out.t b/cpan/Test-Simple/t/subtest/bail_out.t new file mode 100644 index 0000000000..70dc9ac56f --- /dev/null +++ b/cpan/Test-Simple/t/subtest/bail_out.t @@ -0,0 +1,59 @@ +#!/usr/bin/perl -w + +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = ('../lib', 'lib'); + } + else { + unshift @INC, 't/lib'; + } +} + +my $Exit_Code; +BEGIN { + *CORE::GLOBAL::exit = sub { $Exit_Code = shift; }; +} + +use Test::Builder; +use Test::More; + +my $output; +my $TB = Test::More->builder; +$TB->output(\$output); + +my $Test = Test::Builder->create; +$Test->level(0); + +$Test->plan(tests => 2); + +plan tests => 4; + +ok 'foo'; +subtest 'bar' => sub { + plan tests => 3; + ok 'sub_foo'; + subtest 'sub_bar' => sub { + plan tests => 3; + ok 'sub_sub_foo'; + ok 'sub_sub_bar'; + BAIL_OUT("ROCKS FALL! EVERYONE DIES!"); + ok 'sub_sub_baz'; + }; + ok 'sub_baz'; +}; + +$Test->is_eq( $output, <<'OUT' ); +1..4 +ok 1 + # Subtest: bar + 1..3 + ok 1 + # Subtest: sub_bar + 1..3 + ok 1 + ok 2 +Bail out! ROCKS FALL! EVERYONE DIES! +OUT + +$Test->is_eq( $Exit_Code, 255 ); diff --git a/cpan/Test-Simple/t/subtest/basic.t b/cpan/Test-Simple/t/subtest/basic.t index 0a0a96273a..93780a9da2 100644 --- a/cpan/Test-Simple/t/subtest/basic.t +++ b/cpan/Test-Simple/t/subtest/basic.t @@ -40,7 +40,6 @@ $ENV{HARNESS_ACTIVE} = 0; $tb->ok( $_, "We're on $_" ); } - $tb->reset_outputs; is $tb->read, <<"END", 'Output should nest properly'; 1..7 ok 1 - We're on 1 @@ -86,7 +85,6 @@ END } $tb->_ending; - $tb->reset_outputs; is $tb->read, <<"END", 'We should allow arbitrary nesting'; ok 1 - We're on 1 # We ran 1 @@ -124,7 +122,6 @@ END $child->ok(3); $child->finalize; } - $tb->reset_outputs; is $tb->read, <<"END", 'Previous child failures should not force subsequent failures'; 1..3 ok 1 @@ -194,7 +191,6 @@ END $child->todo_end; $child->finalize; $tb->_ending; - $tb->reset_outputs; is $tb->read, <<"END", 'TODO tests should not make the parent test fail'; 1..1 1..1 @@ -209,7 +205,6 @@ END my $child = $tb->child; $child->finalize; $tb->_ending; - $tb->reset_outputs; my $expected = <<"END"; 1..1 not ok 1 - No tests run for subtest "Child of $0" diff --git a/cpan/Test-Simple/t/subtest/line_numbers.t b/cpan/Test-Simple/t/subtest/line_numbers.t index 33d70ecee0..7a20a60ae6 100644 --- a/cpan/Test-Simple/t/subtest/line_numbers.t +++ b/cpan/Test-Simple/t/subtest/line_numbers.t @@ -26,6 +26,7 @@ $ENV{HARNESS_ACTIVE} = 0; our %line; { + test_out(" # Subtest: namehere"); test_out(" 1..3"); test_out(" ok 1"); test_out(" not ok 2"); @@ -46,6 +47,7 @@ our %line; test_test("un-named inner tests"); } { + test_out(" # Subtest: namehere"); test_out(" 1..3"); test_out(" ok 1 - first is good"); test_out(" not ok 2 - second is bad"); @@ -76,6 +78,7 @@ sub run_the_subtest { }; BEGIN{ $line{outerfail3} = __LINE__ } } { + test_out(" # Subtest: namehere"); test_out(" 1..3"); test_out(" ok 1 - first is good"); test_out(" not ok 2 - second is bad"); @@ -92,6 +95,7 @@ sub run_the_subtest { test_test("subtest() called from a sub"); } { + test_out( " # Subtest: namehere"); test_out( " 1..0"); test_err( " # No tests run!"); test_out( 'not ok 1 - No tests run for subtest "namehere"'); @@ -105,6 +109,7 @@ sub run_the_subtest { test_test("lineno in 'No tests run' diagnostic"); } { + test_out(" # Subtest: namehere"); test_out(" 1..1"); test_out(" not ok 1 - foo is bar"); test_err(" # Failed test 'foo is bar'"); diff --git a/cpan/Test-Simple/t/subtest/predicate.t b/cpan/Test-Simple/t/subtest/predicate.t index 9fbdf00ca2..4e29a426b1 100644 --- a/cpan/Test-Simple/t/subtest/predicate.t +++ b/cpan/Test-Simple/t/subtest/predicate.t @@ -16,7 +16,7 @@ BEGIN { use strict; use warnings; -use Test::More tests => 4; +use Test::More tests => 5; use Test::Builder; use Test::Builder::Tester; @@ -40,6 +40,7 @@ sub foobar_ok ($;$) { }; } { + test_out(" # Subtest: namehere"); test_out(" 1..2"); test_out(" ok 1 - foo"); test_out(" not ok 2 - bar"); @@ -64,6 +65,7 @@ sub foobar_ok_2 ($;$) { foobar_ok($value, $name); } { + test_out(" # Subtest: namehere"); test_out(" 1..2"); test_out(" ok 1 - foo"); test_out(" not ok 2 - bar"); @@ -93,6 +95,7 @@ sub barfoo_ok ($;$) { }); } { + test_out(" # Subtest: namehere"); test_out(" 1..2"); test_out(" ok 1 - foo"); test_out(" not ok 2 - bar"); @@ -117,6 +120,7 @@ sub barfoo_ok_2 ($;$) { barfoo_ok($value, $name); } { + test_out(" # Subtest: namehere"); test_out(" 1..2"); test_out(" ok 1 - foo"); test_out(" not ok 2 - bar"); @@ -134,8 +138,10 @@ sub barfoo_ok_2 ($;$) { # A subtest-based predicate called from within a subtest { + test_out(" # Subtest: outergroup"); test_out(" 1..2"); test_out(" ok 1 - this passes"); + test_out(" # Subtest: namehere"); test_out(" 1..2"); test_out(" ok 1 - foo"); test_out(" not ok 2 - bar"); @@ -145,6 +151,7 @@ sub barfoo_ok_2 ($;$) { test_out(" not ok 2 - namehere"); test_err(" # Failed test 'namehere'"); test_err(" # at $0 line $line{ipredcall}."); + test_err(" # Looks like you failed 1 test of 2."); test_out("not ok 1 - outergroup"); test_err("# Failed test 'outergroup'"); test_err("# at $0 line $line{outercall}."); @@ -154,5 +161,6 @@ sub barfoo_ok_2 ($;$) { ok 1, "this passes"; barfoo_ok_2 "foot", "namehere"; BEGIN{ $line{ipredcall} = __LINE__ } }; BEGIN{ $line{outercall} = __LINE__ } -} + test_test("outergroup with internal barfoo_ok_2 failing line numbers"); +} diff --git a/cpan/Test-Simple/t/subtest/threads.t b/cpan/Test-Simple/t/subtest/threads.t new file mode 100644 index 0000000000..0d70b1e6e5 --- /dev/null +++ b/cpan/Test-Simple/t/subtest/threads.t @@ -0,0 +1,25 @@ +#!/usr/bin/perl -w + +use strict; +use warnings; + +use Config; +BEGIN { + unless ( $] >= 5.008001 && $Config{'useithreads'} && + eval { require threads; 'threads'->import; 1; }) + { + print "1..0 # Skip: no working threads\n"; + exit 0; + } +} + +use Test::More; + +subtest 'simple test with threads on' => sub { + is( 1+1, 2, "simple test" ); + is( "a", "a", "another simple test" ); +}; + +pass("Parent retains sharedness"); + +done_testing(2); diff --git a/cpan/Test-Simple/t/subtest/todo.t b/cpan/Test-Simple/t/subtest/todo.t index 345f5e124b..7269da9b95 100644 --- a/cpan/Test-Simple/t/subtest/todo.t +++ b/cpan/Test-Simple/t/subtest/todo.t @@ -52,6 +52,7 @@ sub test_subtest_in_todo { my ($set_via, $todo_reason, $level) = @$combo; test_out( + " # Subtest: xxx", @outlines, "not ok 1 - $xxx # TODO $todo_reason", "# Failed (TODO) test '$xxx'", |