Skip to content

Commit

Permalink
Remove the now redundant History->test_count
Browse files Browse the repository at this point in the history
Synonym for result_count

For #198
  • Loading branch information
schwern committed May 26, 2012
1 parent b1aa706 commit 43a460e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 26 deletions.
2 changes: 1 addition & 1 deletion lib/TB2/Event/SubtestEnd.pm
Expand Up @@ -113,7 +113,7 @@ sub _build_result {
$result_args{skip} = 1; $result_args{skip} = 1;
$result_args{reason} = $subtest_plan->skip_reason; $result_args{reason} = $subtest_plan->skip_reason;
} }
elsif( $subtest_history->test_count == 0 ) { elsif( $subtest_history->result_count == 0 ) {
# The subtest didn't run any tests # The subtest didn't run any tests
my $name = $result_args{name}; my $name = $result_args{name};
$result_args{name} = "No tests run in subtest"; $result_args{name} = "No tests run in subtest";
Expand Down
33 changes: 12 additions & 21 deletions lib/TB2/History.pm
Expand Up @@ -272,10 +272,8 @@ sub handle_result {


=head2 result_count =head2 result_count
Get the count of results stored in the stack. The number of results which have been seen.
NOTE: This could be diffrent from the number of tests that have been
seen, to get that count use test_count.
=head3 has_results =head3 has_results
Expand Down Expand Up @@ -303,14 +301,15 @@ my @statistic_attributes = qw(
fail_count fail_count
todo_count todo_count
skip_count skip_count
test_count
); );


has $_ => ( for my $name (@statistic_attributes) {
is => 'rw', has $name => (
isa => 'TB2::Positive_Int', is => 'rw',
default => 0, isa => 'TB2::Positive_Int',
) for @statistic_attributes; default => 0,
);
}


sub _update_statistics { sub _update_statistics {
my $self = shift; my $self = shift;
Expand All @@ -320,19 +319,11 @@ sub _update_statistics {
$self->fail_count( $self->fail_count + 1 ) if $result->is_fail; $self->fail_count( $self->fail_count + 1 ) if $result->is_fail;
$self->todo_count( $self->todo_count + 1 ) if $result->is_todo; $self->todo_count( $self->todo_count + 1 ) if $result->is_todo;
$self->skip_count( $self->skip_count + 1 ) if $result->is_skip; $self->skip_count( $self->skip_count + 1 ) if $result->is_skip;
$self->test_count( $self->test_count + 1 );


return; return;
} }




=head3 test_count
A count of the number of tests that have been added to results. This
value is not guaranteed to be the same as results_count if you have
altered the results_stack. This is a static counter of the number of
tests that have been seen, not the number of results stored.
=head3 pass_count =head3 pass_count
A count of the number of passed tests have been added to results. A count of the number of passed tests have been added to results.
Expand Down Expand Up @@ -377,11 +368,11 @@ sub can_succeed {
if( my $plan = $self->plan ) { if( my $plan = $self->plan ) {
if( my $expect = $plan->asserts_expected ) { if( my $expect = $plan->asserts_expected ) {
# We ran more tests than the plan # We ran more tests than the plan
return 0 if $self->test_count > $expect; return 0 if $self->result_count > $expect;
} }
elsif( $plan->skip ) { elsif( $plan->skip ) {
# We were supposed to skip everything, but we ran tests # We were supposed to skip everything, but we ran tests
return 0 if $self->test_count; return 0 if $self->result_count;
} }
} }


Expand Down Expand Up @@ -429,11 +420,11 @@ sub test_was_successful {


if( $plan->no_plan ) { if( $plan->no_plan ) {
# Didn't run any tests # Didn't run any tests
return 0 if !$self->test_count; return 0 if !$self->result_count;
} }
else { else {
# Wrong number of tests # Wrong number of tests
return 0 if $self->test_count != $plan->asserts_expected; return 0 if $self->result_count != $plan->asserts_expected;
} }


# We're exiting with non-zero # We're exiting with non-zero
Expand Down
6 changes: 3 additions & 3 deletions lib/Test/Builder.pm
Expand Up @@ -2215,7 +2215,7 @@ sub _ending {
my $plan = $history->plan; my $plan = $history->plan;


# They never set a plan nor ran a test. # They never set a plan nor ran a test.
return if !$plan && !$history->test_count; return if !$plan && !$history->result_count;


# Forked children often run fragments of tests. # Forked children often run fragments of tests.
my $in_child = $self->history->is_child_process; my $in_child = $self->history->is_child_process;
Expand Down Expand Up @@ -2258,7 +2258,7 @@ sub test_exit_code {
my $plan = $history->plan; my $plan = $history->plan;


# They never set a plan nor ran a test. # They never set a plan nor ran a test.
return $real_exit_code if !$plan && !$history->test_count; return $real_exit_code if !$plan && !$history->result_count;


# The test bailed out. # The test bailed out.
if( $history->abort ) { if( $history->abort ) {
Expand All @@ -2268,7 +2268,7 @@ FAIL
return 255; return 255;
} }
# Some tests were run... # Some tests were run...
elsif( $history->test_count ) { elsif( $history->result_count ) {
# ...but we exited with non-zero # ...but we exited with non-zero
if($real_exit_code) { if($real_exit_code) {
$self->diag(<<"FAIL"); $self->diag(<<"FAIL");
Expand Down
1 change: 0 additions & 1 deletion t/History/HistoryStats.t
Expand Up @@ -39,7 +39,6 @@ note "basic history stats"; {
ok $history->has_results, q{we have results}; ok $history->has_results, q{we have results};


is $history->result_count, 4, q{count looks good}; is $history->result_count, 4, q{count looks good};
is $history->test_count, 4, q{test_count};
is $history->pass_count, 2, q{pass_count}; is $history->pass_count, 2, q{pass_count};
is $history->fail_count, 2, q{fail_count}; is $history->fail_count, 2, q{fail_count};
is $history->todo_count, 0, q{todo_count}; is $history->todo_count, 0, q{todo_count};
Expand Down

0 comments on commit 43a460e

Please sign in to comment.