On 4/20/06, Steve Peters <[EMAIL PROTECTED]> wrote: > Maybe I'm thinking too hard, or maybe the results reported aren't > exactly as clear as they probably should be. Here's an example test and > its results as reported by Test::Harness with the TODO changes. > > #!perl -w > > use strict; > use Test::More qw(no_plan); > > TODO: { > local $TODO = "TODO testing"; > is(1, 2, "A failing test"); > is(1, 1, "A passing test"); > } > [EMAIL PROTECTED]:~/smoke/perl-current/t$ ./perl harness th_test.t > th_test....ok > 1/2 unexpectedly succeeded > TODO PASSED tests 1-2 > > All tests successful (1 subtest UNEXPECTEDLY SUCCEEDED). > Passed Test Stat Wstat Total Pass Passed List of Passed > ------------------------------------------------------------------------------- > th_test.t 2 1 50.00% 1-2 > Files=1, Tests=2, 0 wallclock secs ( 0.11 cusr + 0.01 csys = 0.12 > CPU) > > The line starting TODO PASSED shows all TODO tests, not those that > unexpectedly succeeded, which confused me a bit. Also, the final > results show that one test passed, but then the list of passed is "1-2" > instead of just "2" which is the unexpected success. Is there a way to > have the list of passed just show the unexpected successes?
Attached patch should fix it up. Both in terms of making it clearer and of fixing the list. So your test file would look like: All tests successful (1 subtest UNEXPECTEDLY SUCCEEDED), 37 subtests skipped. Passed Todo Stat Wstat Todos Pass Passed List of Passed ------------------------------------------------------------------------------- t/demerphq.t 2 1 50.00% 3 Files=19, Tests=572, 8 wallclock secs ( 0.00 cusr + 0.00 csys = 0.00 CPU) Hopefully thats clearer. The "Todos" column shows how many todos there are in the file. Cheers, Yves -- perl -Mre=debug -e "/just|another|perl|hacker/"
Only in Test-Harness: Makefile.old diff -wurd Test-Harness-2.57_05/lib/Test/Harness.pm Test-Harness/lib/Test/Harness.pm --- Test-Harness-2.57_05/lib/Test/Harness.pm 2006-04-19 07:25:51.000000000 +0200 +++ Test-Harness/lib/Test/Harness.pm 2006-04-20 22:30:18.102615400 +0200 @@ -39,6 +39,7 @@ =cut $VERSION = "2.57_05"; +$VERSION = eval $VERSION; # Backwards compatibility for exportable variable names. *verbose = *Verbose; @@ -352,7 +353,7 @@ # state of the current test. my @failed = grep { !$results{details}[$_-1]{ok} } [EMAIL PROTECTED]; - my @todo_pass = grep { $results{details}[$_-1]{ok} && + my @todo_pass = grep { $results{details}[$_-1]{actual_ok} && $results{details}[$_-1]{type} eq 'todo' } [EMAIL PROTECTED]; @@ -362,6 +363,7 @@ max => $results{max}, failed => [EMAIL PROTECTED], todo_pass => [EMAIL PROTECTED], + todo => $results{todo}, bonus => $results{bonus}, skipped => $results{skip}, skip_reason => $results{skip_reason}, @@ -384,14 +386,14 @@ push(@msg, "$test{skipped}/$test{max} skipped: $test{skip_reason}") if $test{skipped}; if ($test{bonus}) { - my ($txt, $canon) = _canondetail($test{max},$test{skipped},'TODO passed', + my ($txt, $canon) = _canondetail($test{todo},0,'TODO passed', @{$test{todo_pass}}); $todo_passed{$tfile} = { canon => $canon, - max => $test{max}, + max => $test{todo}, failed => $test{bonus}, name => $tfile, - percent => 100*$test{bonus}/$test{max}, + percent => 100*$test{bonus}/$test{todo}, estat => '', wstat => '', }; @@ -568,7 +570,7 @@ if (_all_ok($tot)) { $out .= "All tests successful$bonusmsg.\n"; if ($tot->{bonus}) { - my($fmt_top, $fmt) = _create_fmts("Passed",$todo_passed); + my($fmt_top, $fmt) = _create_fmts("Passed Todo",$todo_passed); # Now write to formats for my $script (sort keys %{$todo_passed||{}}) { my $Curtest = $todo_passed->{$script}; @@ -593,7 +595,7 @@ $tot->{max} - $tot->{ok}, $tot->{max}, $percent_ok; - my($fmt_top, $fmt1, $fmt2) = _create_fmts("Failed",$failedtests); + my($fmt_top, $fmt1, $fmt2) = _create_fmts("Failed Test",$failedtests); # Now write to formats for my $script (sort keys %$failedtests) { @@ -767,12 +769,13 @@ sub _create_fmts { - my $type = shift; + my $failed_str = shift; my $failedtests = shift; + my ($type) = split /\s/,$failed_str; my $short = substr($type,0,4); - my $failed_str = "$type Test"; - my $middle_str = " Stat Wstat Total $short $type "; + my $total = $short eq 'Pass' ? 'Todos' : 'Total'; + my $middle_str = " Stat Wstat $total $short $type "; my $list_str = "List of $type"; # Figure out our longest name string for formatting purposes. @@ -812,7 +815,6 @@ my $skipped = shift; my $type = shift; my @detail = @_; - my %seen; @detail = sort {$a <=> $b} grep !$seen{$_}++, @detail; my $detail = @detail; diff -wurd Test-Harness-2.57_05/t/version.t Test-Harness/t/version.t --- Test-Harness-2.57_05/t/version.t 2006-03-27 19:51:05.000000000 +0200 +++ Test-Harness/t/version.t 2006-04-20 21:50:20.180740400 +0200 @@ -19,5 +19,5 @@ } my $ver = $ENV{HARNESS_VERSION} or die "HARNESS_VERSION not set"; -like( $ver, qr/^2.\d\d(_\d\d)?$/, "Version is proper format" ); +like( $ver, qr/^2.\d\d(_?\d\d)?$/, "Version is proper format" ); is( $ver, $Test::Harness::VERSION );