📄 test-harness.t
字号:
}, failed => { }, all_ok => 1, }, with_comments => { total => { bonus => 2, max => 5, 'ok' => 5, files => 1, bad => 0, good => 1, tests => 1, sub_skipped=> 0, 'todo' => 4, skipped => 0, }, failed => { }, all_ok => 1, }, taint => { total => { bonus => 0, max => 1, 'ok' => 1, files => 1, bad => 0, good => 1, tests => 1, sub_skipped=> 0, 'todo' => 0, skipped => 0, }, failed => { }, all_ok => 1, }, taint_warn => { total => { bonus => 0, max => 1, 'ok' => 1, files => 1, bad => 0, good => 1, tests => 1, sub_skipped=> 0, 'todo' => 0, skipped => 0, }, failed => { }, all_ok => 1, }, 'die' => { total => { bonus => 0, max => 0, 'ok' => 0, files => 1, bad => 1, good => 0, tests => 1, sub_skipped=> 0, 'todo' => 0, skipped => 0, }, failed => { estat => $die_estat, max => '??', failed => '??', canon => '??', }, all_ok => 0, }, die_head_end => { total => { bonus => 0, max => 0, 'ok' => 4, files => 1, bad => 1, good => 0, tests => 1, sub_skipped=> 0, 'todo' => 0, skipped => 0, }, failed => { estat => $die_estat, max => '??', failed => '??', canon => '??', }, all_ok => 0, }, die_last_minute => { total => { bonus => 0, max => 4, 'ok' => 4, files => 1, bad => 1, good => 0, tests => 1, sub_skipped=> 0, 'todo' => 0, skipped => 0, }, failed => { estat => $die_estat, max => 4, failed => 0, canon => '??', }, all_ok => 0, }, bignum => { total => { bonus => 0, max => 2, 'ok' => 4, files => 1, bad => 1, good => 0, tests => 1, sub_skipped=> 0, 'todo' => 0, skipped => 0, }, failed => { canon => '??', }, all_ok => 0, }, bignum_many => { total => { bonus => 0, max => 2, 'ok' => 11, files => 1, bad => 1, good => 0, tests => 1, sub_skipped=> 0, 'todo' => 0, skipped => 0, }, failed => { canon => '3-100000', }, all_ok => 0, }, 'shbang_misparse' => { total => { bonus => 0, max => 2, 'ok' => 2, files => 1, bad => 0, good => 1, tests => 1, sub_skipped=> 0, 'todo' => 0, skipped => 0, }, failed => { }, all_ok => 1, }, too_many => { total => { bonus => 0, max => 3, 'ok' => 7, files => 1, bad => 1, good => 0, tests => 1, sub_skipped => 0, 'todo' => 0, skipped => 0, }, failed => { canon => '4-7', }, all_ok => 0, }, switches => { total => { bonus => 0, max => 1, 'ok' => 1, files => 1, bad => 0, good => 1, tests => 1, sub_skipped=> 0, 'todo' => 0, skipped => 0, }, failed => { }, all_ok => 1, }, );my $tests_per_loop = 8;plan tests => (keys(%samples) * $tests_per_loop);use Test::Harness;my @_INC = map { qq{"-I$_"} } @INC;$Test::Harness::Switches = "@_INC -Mstrict";tie *NULL, 'Dev::Null' or die $!;for my $test ( sort keys %samples ) {SKIP: { skip "-t introduced in 5.8.0", $tests_per_loop if ($test eq 'taint_warn') && ($] < 5.008); my $expect = $samples{$test}; # execute_tests() runs the tests but skips the formatting. my $test_path = File::Spec->catfile($SAMPLE_TESTS, $test); print STDERR "# $test\n" if $ENV{TEST_VERBOSE}; my $totals; my $failed; my $warning = ''; eval { local $SIG{__WARN__} = sub { $warning .= join '', @_; }; ($totals, $failed) = Test::Harness::execute_tests(tests => [$test_path], out => \*NULL); }; # $? is unreliable in MacPerl, so we'll just fudge it. $failed->{estat} = $die_estat if $IsMacPerl and $failed; SKIP: { skip "special tests for bailout", 1 unless $test eq 'bailout'; like( $@, '/Further testing stopped: GERONI/i' ); } SKIP: { skip "don't apply to a bailout", 6 if $test eq 'bailout'; is( $@, '', '$@ is empty' ); is( Test::Harness::_all_ok($totals), $expect->{all_ok}, "$test - all ok" ); ok( defined $expect->{total}, "$test - has total" ); is_deeply( {map { $_=>$totals->{$_} } keys %{$expect->{total}}}, $expect->{total}, "$test - totals" ); is_deeply( {map { $_=>$failed->{$test_path}{$_} } keys %{$expect->{failed}}}, $expect->{failed}, "$test - failed" ); skip "No tests were run", 1 unless $totals->{max}; my $output = Test::Harness::get_results($totals, $failed); like( $output, '/All tests successful|List of Failed/', 'Got what looks like a valid summary' ); } my $expected_warnings = ""; if ( $test eq "bignum" ) { $expected_warnings = <<WARN;Enormous test number seen [test 136211425]Can't detailize, too big.WARN } elsif ( $test eq 'bignum_many' ) { $expected_warnings = <<WARN;Enormous test number seen [test 100001]Can't detailize, too big.WARN } my $desc = $expected_warnings ? 'Got proper warnings' : 'No warnings'; is( $warning, $expected_warnings, "$test - $desc" );} # taint SKIP block} # for tests
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -