Class: FlakyStats::LogFile
- Inherits:
-
Object
- Object
- FlakyStats::LogFile
- Defined in:
- lib/flaky_stats/logfile.rb
Instance Method Summary collapse
- #get_error_info(line) ⇒ Object
-
#initialize(options = {}) ⇒ LogFile
constructor
A new instance of LogFile.
-
#read_failing_log ⇒ Object
Read the failing log from our test stack.
-
#write_flaky_stats(real_flaky_tests) ⇒ Object
Log flaky stats.
Constructor Details
#initialize(options = {}) ⇒ LogFile
Returns a new instance of LogFile.
8 9 10 11 |
# File 'lib/flaky_stats/logfile.rb', line 8 def initialize( = {}) @failing_log = [:failing_log] @logfile = [:logfile] end |
Instance Method Details
#get_error_info(line) ⇒ Object
13 14 15 16 17 18 |
# 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 ⇒ Object
Read the failing log from our test stack
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# 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) ⇒ Object
Log flaky stats
39 40 41 42 43 |
# 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 |