Skip to content

Commit

Permalink
Remove duplication of test/assertion counting
Browse files Browse the repository at this point in the history
Now #mrbtest and #_run focus on the different ways the report their
tests more than how tests get run.

This also fixes a bug in #mrbtest where there was a variable typo
"@test_cound".
  • Loading branch information
drbrain committed Dec 13, 2016
1 parent d9f257a commit 4f2688f
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions mrblib/mtest_unit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -441,13 +441,8 @@ def mrbtest
suites = TestCase.send "test_suites"
return if suites.empty?

@test_cound, @assertion_count = 0, 0

results = _run_suites suites

@test_count = results.map{ |r| r[0] }.inject(0) { |sum, tc| sum + tc }
@assertion_count = results.map{ |r| r[1] }.inject(0) { |sum, ac| sum + ac }

$ok_test += (test_count.to_i - failures.to_i - errors.to_i - skips.to_i)
$ko_test += failures.to_i
$kill_test += errors.to_i
Expand All @@ -474,13 +469,8 @@ def _run_tests
puts "# Running tests:"
puts

@test_count, @assertion_count = 0, 0

results = _run_suites suites

@test_count = results.map{ |r| r[0] }.inject(0) { |sum, tc| sum + tc }
@assertion_count = results.map{ |r| r[1] }.inject(0) { |sum, ac| sum + ac }

t = Time.now - start

puts
Expand All @@ -498,7 +488,14 @@ def _run_tests
end

def _run_suites suites
suites.map { |suite| _run_suite suite }
@test_count, @assertion_count = 0, 0

results = suites.map { |suite| _run_suite suite }

@test_count = results.map{ |r| r[0] }.inject(0) { |sum, tc| sum + tc }
@assertion_count = results.map{ |r| r[1] }.inject(0) { |sum, ac| sum + ac }

return results
end

def _run_suite suite
Expand Down

0 comments on commit 4f2688f

Please sign in to comment.