class Oktest::BaseReporter
Constants
- CHARS
- LABELS
Attributes
counts[R]
Public Class Methods
new()
click to toggle source
# File lib/oktest.rb, line 1743 def initialize() @exceptions = [] @counts = {} end
Public Instance Methods
enter_all(runner)
click to toggle source
# File lib/oktest.rb, line 1750 def enter_all(runner) #; [!pq3ia] initalizes counter by zero. reset_counts() @start_at = Time.now end
enter_scope(scope)
click to toggle source
# File lib/oktest.rb, line 1762 def enter_scope(scope) end
enter_spec(spec, depth)
click to toggle source
# File lib/oktest.rb, line 1774 def enter_spec(spec, depth) end
enter_topic(topic, depth)
click to toggle source
# File lib/oktest.rb, line 1768 def enter_topic(topic, depth) end
exit_all(runner)
click to toggle source
# File lib/oktest.rb, line 1756 def exit_all(runner) #; [!wjp7u] prints footer with elapsed time. elapsed = Time.now - @start_at puts footer(elapsed) end
exit_scope(scope)
click to toggle source
# File lib/oktest.rb, line 1765 def exit_scope(scope) end
exit_spec(spec, depth, status, exc, parent)
click to toggle source
# File lib/oktest.rb, line 1777 def exit_spec(spec, depth, status, exc, parent) #; [!r6yge] increments counter according to status. @counts[status] += 1 #; [!nupb4] keeps exception info when status is FAIL or ERROR. @exceptions << [spec, status, exc, parent] if status == :FAIL || status == :ERROR end
exit_topic(topic, depth)
click to toggle source
# File lib/oktest.rb, line 1771 def exit_topic(topic, depth) end
Protected Instance Methods
print_exc(spec, status, exc, topic)
click to toggle source
# File lib/oktest.rb, line 1805 def print_exc(spec, status, exc, topic) #; [!5ara3] prints exception info of assertion failure. #; [!pcpy4] prints exception info of error. label = Color.status(status, LABELS[status]) path = Color.topic(spec_path(spec, topic)) puts "[#{label}] #{path}" print_exc_backtrace(exc, status) print_exc_message(exc, status) end
print_exc_backtrace(exc, status)
click to toggle source
# File lib/oktest.rb, line 1815 def print_exc_backtrace(exc, status) #; [!ocxy6] prints backtrace info and lines in file. rexp = FILENAME_FILTER prev_file = prev_line = nil exc.backtrace.each_with_index do |str, i| #; [!jbped] skips backtrace of oktest.rb when assertion failure. #; [!cfkzg] don't skip first backtrace entry when error. next if str =~ rexp && ! (i == 0 && status == :ERROR) linestr = nil if str =~ /:(\d+)/ file = $` # file path line = $1.to_i # line number next if file == prev_file && line == prev_line linestr = Util.file_line(file, line) if str && File.exist?(file) prev_file, prev_line = file, line end puts " #{str}" puts " #{linestr.strip}" if linestr end end
print_exc_message(exc, status)
click to toggle source
# File lib/oktest.rb, line 1838 def print_exc_message(exc, status) #; [!hr7jn] prints detail of assertion failed. #; [!pd41p] prints detail of exception. if status == :FAIL msg = "#{exc}" else msg = "#{exc.class.name}: #{exc}" end lines = [] msg.each_line {|line| lines << line } puts lines.shift.chomp puts lines.join.chomp unless lines.empty? puts exc.diff if exc.respond_to?(:diff) && exc.diff # for oktest.rb end
print_exceptions()
click to toggle source
# File lib/oktest.rb, line 1791 def print_exceptions() #; [!fbr16] prints assertion failures and excerptions with separator. sep = '-' * 70 @exceptions.each do |tuple| puts sep print_exc(*tuple) tuple.clear end #; [!2s9r2] prints nothing when no fails nor errors. puts sep if ! @exceptions.empty? #; [!ueeih] clears exceptions. @exceptions.clear end
reset_counts()
click to toggle source
# File lib/oktest.rb, line 1786 def reset_counts() #; [!oc29s] clears counters to zero. STATUSES.each {|sym| @counts[sym] = 0 } end
spec_path(spec, topic)
click to toggle source
# File lib/oktest.rb, line 1868 def spec_path(spec, topic) #; [!dv6fu] returns path string from top topic to current spec. arr = [spec.desc] while topic && topic.topic? arr << topic.target.to_s if topic.target topic = topic.parent end return arr.reverse.join(" > ") end