Permalink
Browse files

Remove the now redundant History->test_count

Synonym for result_count

For #198
  • Loading branch information...
1 parent b1aa706 commit 43a460ec5a1a203689d98d8521e5ad0405e16af3 @schwern schwern committed May 26, 2012
Showing with 16 additions and 26 deletions.
  1. +1 −1 lib/TB2/Event/SubtestEnd.pm
  2. +12 −21 lib/TB2/History.pm
  3. +3 −3 lib/Test/Builder.pm
  4. +0 −1 t/History/HistoryStats.t
View
2 lib/TB2/Event/SubtestEnd.pm
@@ -113,7 +113,7 @@ sub _build_result {
$result_args{skip} = 1;
$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
my $name = $result_args{name};
$result_args{name} = "No tests run in subtest";
View
33 lib/TB2/History.pm
@@ -272,10 +272,8 @@ sub handle_result {
=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
@@ -303,14 +301,15 @@ my @statistic_attributes = qw(
fail_count
todo_count
skip_count
- test_count
);
-has $_ => (
- is => 'rw',
- isa => 'TB2::Positive_Int',
- default => 0,
-) for @statistic_attributes;
+for my $name (@statistic_attributes) {
+ has $name => (
+ is => 'rw',
+ isa => 'TB2::Positive_Int',
+ default => 0,
+ );
+}
sub _update_statistics {
my $self = shift;
@@ -320,19 +319,11 @@ sub _update_statistics {
$self->fail_count( $self->fail_count + 1 ) if $result->is_fail;
$self->todo_count( $self->todo_count + 1 ) if $result->is_todo;
$self->skip_count( $self->skip_count + 1 ) if $result->is_skip;
- $self->test_count( $self->test_count + 1 );
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
A count of the number of passed tests have been added to results.
@@ -377,11 +368,11 @@ sub can_succeed {
if( my $plan = $self->plan ) {
if( my $expect = $plan->asserts_expected ) {
# We ran more tests than the plan
- return 0 if $self->test_count > $expect;
+ return 0 if $self->result_count > $expect;
}
elsif( $plan->skip ) {
# We were supposed to skip everything, but we ran tests
- return 0 if $self->test_count;
+ return 0 if $self->result_count;
}
}
@@ -429,11 +420,11 @@ sub test_was_successful {
if( $plan->no_plan ) {
# Didn't run any tests
- return 0 if !$self->test_count;
+ return 0 if !$self->result_count;
}
else {
# 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
View
6 lib/Test/Builder.pm
@@ -2215,7 +2215,7 @@ sub _ending {
my $plan = $history->plan;
# 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.
my $in_child = $self->history->is_child_process;
@@ -2258,7 +2258,7 @@ sub test_exit_code {
my $plan = $history->plan;
# 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.
if( $history->abort ) {
@@ -2268,7 +2268,7 @@ FAIL
return 255;
}
# Some tests were run...
- elsif( $history->test_count ) {
+ elsif( $history->result_count ) {
# ...but we exited with non-zero
if($real_exit_code) {
$self->diag(<<"FAIL");
View
1 t/History/HistoryStats.t
@@ -39,7 +39,6 @@ note "basic history stats"; {
ok $history->has_results, q{we have results};
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->fail_count, 2, q{fail_count};
is $history->todo_count, 0, q{todo_count};

0 comments on commit 43a460e

Please sign in to comment.