class Minitest::Reporters::TravisReporter

Public Class Methods

new(*) click to toggle source
Calls superclass method
# File lib/minitest/xs_and_os_plugin.rb, line 31
def initialize(*)
  super
  @color_enabled = io.respond_to?(:tty?) && io.tty?

end

Public Instance Methods

backtrace(backtrace) click to toggle source
# File lib/minitest/xs_and_os_plugin.rb, line 142
def backtrace(backtrace)
  backtrace = filter_backtrace(backtrace).map { |line| location(line, true) }
  return if backtrace.empty?
  indent(backtrace.join("\n")).gsub(/^(\s+)/, "\\1# ")
end
color(string, color = :default) click to toggle source
# File lib/minitest/xs_and_os_plugin.rb, line 178
def color(string, color = :default)
  if color_enabled?
    color = @@color.fetch(color)
    "\e[1;#{color}m#{string}\e[0m"
  else
    string
  end
end
color_enabled?() click to toggle source
# File lib/minitest/xs_and_os_plugin.rb, line 187
def color_enabled?
  @color_enabled
end
display_failing(result, index) click to toggle source
# File lib/minitest/xs_and_os_plugin.rb, line 101
def display_failing(result, index)
  backtrace = backtrace(result.failure.backtrace)
  message   = result.failure.message
  message   = message.lines.tap(&:pop).join.chomp if result.error?

  str = "\n\n"
  str << color('%4d) %s' % [index, result_name(result.name)])
  str << "\n" << color(indent(message), :red)
  str << "\n" << color(backtrace, :blue)
  io.print str
end
display_replay_command(result) click to toggle source
# File lib/minitest/xs_and_os_plugin.rb, line 121
def display_replay_command(result)
  location, line = find_test_file(result)
  if location.empty?
    return
  else
    command = %(rake TEST=#{location} TESTOPTS="--name=#{result.name}")
    str = "\n"
    str << color(command, :red)
    io.print str
  end


end
display_skipped(result, index) click to toggle source
# File lib/minitest/xs_and_os_plugin.rb, line 113
def display_skipped(result, index)
  location = location(result.failure.location)
  str      = "\n\n"
  str << color('%4d) %s [SKIPPED]' % [index, result_name(result.name)], :yellow)
  str << "\n" << indent(color(location, :yellow))
  io.print str
end
filter_backtrace(backtrace) click to toggle source
# File lib/minitest/xs_and_os_plugin.rb, line 157
def filter_backtrace(backtrace)
  Minitest.backtrace_filter.filter(backtrace)
end
find_test_file(result) click to toggle source
# File lib/minitest/xs_and_os_plugin.rb, line 135
def find_test_file(result)
  location, line = result.source_location
  location       = location.gsub(%r[^.*?/((?:test|spec)/.*?)$], "\\1")

  [location, line]
end
indent(text) click to toggle source
# File lib/minitest/xs_and_os_plugin.rb, line 97
def indent(text)
  text.gsub(/^/, '      ')
end
location(location, include_line_number = false) click to toggle source
# File lib/minitest/xs_and_os_plugin.rb, line 148
def location(location, include_line_number = false)
  regex    = include_line_number ? /^([^:]+:\d+)/ : /^([^:]+)/
  location = File.expand_path(location[regex, 1])

  return location unless location.start_with?(Dir.pwd)

  location.gsub(%r[^#{Regexp.escape(Dir.pwd)}/], '')
end
pluralize(word, count) click to toggle source
# File lib/minitest/xs_and_os_plugin.rb, line 191
def pluralize(word, count)
  case count
    when 0
      "no #{word}s"
    when 1
      "1 #{word}"
    else
      "#{count} #{word}s"
  end
end
print_result_code(result_code) click to toggle source
record(result) click to toggle source
Calls superclass method
# File lib/minitest/xs_and_os_plugin.rb, line 37
def record(result)
  super
  puts
  print result.class_name
  print ' '
  print self.result_name result.name
  print ' ['
  print_result_code(result.result_code)
  print ']'
end
report() click to toggle source
Calls superclass method
# File lib/minitest/xs_and_os_plugin.rb, line 54
def report
  super
  io.sync = true

  failing_results = results.reject(&:skipped?)
  skipped_results = results.select(&:skipped?)

  color = :green
  color = :yellow if skipped_results.any?
  color = :red if failing_results.any?

  if failing_results.any? || skipped_results.any?
    failing_results.each.with_index(1) { |result, index| display_failing(result, index) }
    skipped_results.each.with_index(failing_results.size + 1) { |result, index| display_skipped(result, index) }
  end

  io.print "\n\n"
  io.puts statistics
  io.puts color(summary, color)

  if failing_results.any?
    io.puts "\nFailed Tests:\n"
    failing_results.each { |result| display_replay_command(result) }
    io.puts "\n\n"
  end
end
result_name(name) click to toggle source
# File lib/minitest/xs_and_os_plugin.rb, line 161
def result_name(name)
  name
      .gsub(/^test(_\d+)?_/, '')
      .gsub(/_/, ' ')
end
start() click to toggle source
Calls superclass method
# File lib/minitest/xs_and_os_plugin.rb, line 48
def start
  super
  io.print "Run options: #{options[:args]} / "
  io.print 'Running:'
end
statistics() click to toggle source
# File lib/minitest/xs_and_os_plugin.rb, line 82
def statistics
  'Finished in %.6fs, %.4f runs/s, %.4f assertions/s.' %
      [total_time, count / total_time, assertions / total_time]
end