Skip to content

Colorize tests #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions dragon/log.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,9 @@ def log_unfiltered str, subsystem = nil
end

def log_with_color xterm_escape_code, *args
log_print xterm_escape_code
log(*args)
ensure
log_reset_color
message_id, message = args
message ||= message_id
log("#{xterm_escape_code}#{message}#{XTERM_COLOR[:reset]}")
end

def log_reset_color
Expand Down
30 changes: 15 additions & 15 deletions dragon/tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_methods

# @gtk
def start
log "* TEST: gtk.test.start has been invoked."
log_cyan "* TEST: gtk.test.start has been invoked."
if test_methods_focused.length != 0
@is_running = true
test_methods_focused.each { |m| run_test m }
Expand Down Expand Up @@ -76,12 +76,12 @@ def running?

def log_inconclusive m
self.inconclusive << {m: m}
log "Inconclusive."
log_yellow "Inconclusive."
end

def log_passed m
self.passed << {m: m}
log "Passed."
log_green "Passed."
end

def log_no_tests_found
Expand All @@ -97,7 +97,7 @@ def test_game_over args, assert
end

def log_test_running m
log "** Running: #{m}"
log_cyan "** Running: #{m}"
end

def test_signature_invalid_exception? e, m
Expand Down Expand Up @@ -127,24 +127,24 @@ def clear_summary
end

def print_summary
log "** Summary"
log "*** Passed"
log "#{self.passed.length} test(s) passed."
self.passed.each { |h| log "**** :#{h[:m]}" }
log "*** Inconclusive"
log_cyan "** Summary"
log_green "*** Passed"
log_green "#{self.passed.length} test(s) passed."
self.passed.each { |h| log_green "**** :#{h[:m]}" }
log_yellow "*** Inconclusive"
if self.inconclusive.length > 0
log_once :assertion_ok_note, <<-S
NOTE FOR INCONCLUSIVE TESTS: No assertion was performed in the test.
Add assert.ok! at the end of the test if you are using your own assertions.
S
end
log "#{self.inconclusive.length} test(s) inconclusive."
self.inconclusive.each { |h| log "**** :#{h[:m]}" }
log "*** Failed"
log "#{self.failed.length} test(s) failed."
log_yellow "#{self.inconclusive.length} test(s) inconclusive."
self.inconclusive.each { |h| log_yellow "**** :#{h[:m]}" }
log_red "*** Failed"
log_red "#{self.failed.length} test(s) failed."
self.failed.each do |h|
log "**** Test name: :#{h[:m]}"
log "#{h[:e].to_s.gsub("* ERROR:", "").strip}\n#{h[:e].__backtrace_to_org__}"
log_red "**** Test name: :#{h[:m]}"
log_red "#{h[:e].to_s.gsub("* ERROR:", "").strip}\n#{h[:e].__backtrace_to_org__}"
end
end
end
Expand Down