Skip to content

Commit

Permalink
Add support for pluralization in the test suite messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
treed committed Jul 25, 2009
1 parent 4ef71dd commit fd55266
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions Rakefile
Expand Up @@ -14,6 +14,7 @@ $missing = 0
$missing_files = []
$toomany = 0
$toomany_files = []
$pl = false
$start = Time.now

def clean?
Expand All @@ -25,6 +26,22 @@ def clean?
return true
end

def pl(word)
$pl ? word + "s" : word
end

def were
$pl ? "were" : "was"
end

def are
$pl ? "are" : "is"
end

def them
$pl ? "them" : "it"
end

def parrot(input, output, grammar="", target="")
target = "--target=#{target}" if target != ""
sh "#{CONFIG[:parrot]} #{grammar} #{target} -o #{output} #{input}"
Expand Down Expand Up @@ -315,40 +332,47 @@ namespace :test do |ns|
dur_minutes += 1
end
puts "Test statistics:"
puts " The test suite took #{dur_minutes} minutes and #{dur_seconds} seconds."
puts " The test suite took #{dur_minutes}:#{dur_seconds}."
puts " #{$tests} tests were run, from #{$test_files} files."
puts " #{$ok} tests passed, #{$unexpected_passes} of which were unexpected."
unless $u_p_files.empty?
$u_p_files.uniq!
puts " Unexpected passes were found in the following files:"
$pl = $u_p_files > 1
puts " Unexpected passes were found in the following #{pl "file"}:"
$u_p_files.each do |pass|
puts " #{pass}"
end
end
puts " #{$nok} tests failed, #{$expected_failures} of which were expected."
$pl = $nok > 1
puts " #{$nok} #{pl "test"} failed, #{$expected_failures} of which were expected."
unless $unexpected_failures.empty?
$unexpected_failures.uniq!
puts " Unexpected failures were found in the following files:"
$pl = $unexpected_failures.size > 1
puts " Unexpected #{pl "failure"} #{were} found in the following #{pl "file"}:"
$unexpected_failures.each do |fail|
puts " #{fail}"
end
end
$pl = $missing_files.size > 1
unless $missing_files.empty?
puts " There were #{$missing} test files that reported fewer results than were planned:"
puts " There #{were} #{$missing} test #{pl "file"} that reported fewer results than were planned:"
$missing_files.uniq!
$missing_files.each do |missing|
puts " #{missing}"
end
end
$pl = $toomany_files.size > 1
unless $toomany_files.empty?
puts " There were #{$toomany} test files that reported more results than were planned:"
puts " There #{were} #{$toomany} test #{pl "file"} that reported more results than were planned:"
$toomany_files.uniq!
$toomany_files.each do |toomany|
puts " #{toomany}"
end
end
puts " There were #{$unknown} unknown or confusing results."
puts " There were #{$failures} complete failures."
$pl = $unknown > 1
puts " There #{were} #{$unknown} unknown or confusing #{pl "result"}." if $unknown > 0
$pl = $failures > 1
puts " There #{were} #{$failures} complete #{pl "failure"}." if $failures > 0
puts " -- CLEAN FOR COMMIT --" if clean?
end
end

0 comments on commit fd55266

Please sign in to comment.