module Pork::Report::Imp
Public Class Methods
new(o=$stdout)
click to toggle source
Calls superclass method
# File lib/pork/report.rb, line 6 def initialize o=$stdout super extensions = Pork.report_extensions extend(*extensions.reverse) if extensions.any? end
Public Instance Methods
case_end()
click to toggle source
# File lib/pork/report.rb, line 13 def case_end ; end
case_errored()
click to toggle source
# File lib/pork/report.rb, line 17 def case_errored; io.print msg_errored; end
case_failed()
click to toggle source
# File lib/pork/report.rb, line 16 def case_failed ; io.print msg_failed ; end
case_pass()
click to toggle source
# File lib/pork/report.rb, line 14 def case_pass ; io.print msg_pass ; end
case_skip()
click to toggle source
# File lib/pork/report.rb, line 15 def case_skip ; io.print msg_skip ; end
case_start(_;)
click to toggle source
# File lib/pork/report.rb, line 12 def case_start _; end
loaded(at, files)
click to toggle source
# File lib/pork/report.rb, line 19 def loaded at, files elapsed = Time.now - at delta = $LOADED_FEATURES.size - files io.printf("Loaded %s files in %s seconds, %s files/s\n", *loadings([delta, elapsed.round(6), (delta / elapsed).round(4)])) io.puts end
prepare(paths)
click to toggle source
# File lib/pork/report.rb, line 28 def prepare paths end
report(stat)
click to toggle source
# File lib/pork/report.rb, line 31 def report stat io.puts io.puts messages(stat) io.printf("\nFinished in %s seconds, %s tests/s, %s assertions/s \n", *velocity(stat.velocity)) io.printf("%s tests, %s assertions, %s failures, %s errors, %s skips\n", *numbers(stat.numbers)) end
Private Instance Methods
backlight_line(line)
click to toggle source
# File lib/pork/report.rb, line 104 def backlight_line line line end
backtrace(test, err)
click to toggle source
# File lib/pork/report.rb, line 88 def backtrace test, err if $VERBOSE err.backtrace else strip(reject_pork(test, err)) end end
bad(text)
click to toggle source
# File lib/pork/report.rb, line 57 def bad text text end
command(source_location, seed)
click to toggle source
# File lib/pork/report.rb, line 79 def command source_location, seed "env#{pork_test(source_location)} #{pork_mode} #{pork_seed(seed)}" \ " #{Gem.ruby} -S #{$0} #{ARGV.join(' ')}" end
highlight_line(line)
click to toggle source
# File lib/pork/report.rb, line 100 def highlight_line line line end
loadings(values)
click to toggle source
# File lib/pork/report.rb, line 41 def loadings values values end
messages(stat)
click to toggle source
# File lib/pork/report.rb, line 65 def messages stat stat.exceptions.reverse_each.map do |(err, msg, test, seed)| "\n #{show_command(test.source_location, seed)}" \ "\n #{show_backtrace(test, err)}" \ "#{show_source(test, err)}" \ "\n#{show_message(msg)}" \ "\n#{show_exception(err)}" end end
numbers(values)
click to toggle source
# File lib/pork/report.rb, line 49 def numbers values values end
ok(text)
click to toggle source
# File lib/pork/report.rb, line 53 def ok text text end
pork_mode()
click to toggle source
# File lib/pork/report.rb, line 147 def pork_mode "PORK_MODE=#{Pork.execute_mode}" end
pork_seed(seed)
click to toggle source
# File lib/pork/report.rb, line 151 def pork_seed seed "PORK_SEED=#{seed}" end
pork_test(source_location)
click to toggle source
# File lib/pork/report.rb, line 137 def pork_test source_location if !!ENV['PORK_SEED'] == !!ENV['PORK_TEST'] || ENV['PORK_TEST'] file, line = source_location " PORK_TEST='#{strip([file]).join}:#{line}'" else # cannot replicate a test case with PORK_SEED set and PORK_TEST unset # unless we could restore random's state (srand didn't work for that) end end
reject_pork(test, err)
click to toggle source
# File lib/pork/report.rb, line 116 def reject_pork test, err bt = err.backtrace.reject{ |l| l =~ %r{/lib/pork(/\w+)*\.rb:\d+} } if bt.empty? ["#{test.source_location.join(':')}:in `block in would'"] else bt end end
show_backtrace(test, err)
click to toggle source
# File lib/pork/report.rb, line 84 def show_backtrace test, err backtrace(test, err).join("\n ") end
show_command(source_location, seed)
click to toggle source
# File lib/pork/report.rb, line 75 def show_command source_location, seed "Replicate this test with:\n#{command(source_location, seed)}" end
show_exception(err)
click to toggle source
# File lib/pork/report.rb, line 112 def show_exception err "#{err.class}: #{err.message}" end
show_message(msg)
click to toggle source
# File lib/pork/report.rb, line 108 def show_message msg msg end
show_source(_, _)
click to toggle source
# File lib/pork/report.rb, line 96 def show_source _, _ '' end
strip(bt)
click to toggle source
# File lib/pork/report.rb, line 125 def strip bt strip_home(strip_cwd(bt)) end
strip_cwd(bt)
click to toggle source
# File lib/pork/report.rb, line 133 def strip_cwd bt bt.map{ |path| path.sub("#{Dir.pwd}/", '') } end
strip_home(bt)
click to toggle source
# File lib/pork/report.rb, line 129 def strip_home bt bt.map{ |path| path.sub(ENV['HOME'], '~') } end
time(text)
click to toggle source
# File lib/pork/report.rb, line 61 def time text text end
velocity(values)
click to toggle source
# File lib/pork/report.rb, line 45 def velocity values values end