class FlakyStats::LogFile
Public Class Methods
new(options = {})
click to toggle source
# File lib/flaky_stats/logfile.rb, line 8 def initialize(options = {}) @failing_log = options[:failing_log] @logfile = options[:logfile] end
Public Instance Methods
get_error_info(line)
click to toggle source
# File lib/flaky_stats/logfile.rb, line 13 def get_error_info(line) information= line.partition(/\.\/.*.rb/) filename = information[1] lineno = information[2].partition(/:/)[2].to_i return {filename: filename, lineno: lineno} end
read_failing_log()
click to toggle source
Read the failing log from our test stack
# File lib/flaky_stats/logfile.rb, line 21 def read_failing_log() failed_files = [] # Read in the file file = File.readlines(@failing_log) # Get lines which begin with rspec file.each do |line| if line =~ /rspec \.\// # Get the file name only failed_files << get_error_info(line) end end return failed_files end
write_flaky_stats(real_flaky_tests)
click to toggle source
Log flaky stats
# File lib/flaky_stats/logfile.rb, line 39 def write_flaky_stats(real_flaky_tests) File.open(@logfile, "a") do |log| real_flaky_tests.each {|data| log.puts data} end end