Created
September 15, 2015 15:40
-
-
Save tehviking/ca7955506f01073dcba9 to your computer and use it in GitHub Desktop.
Find failures & errors and their count in test output
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Parser | |
attr_reader :files | |
def initialize | |
@read_file_mode = false | |
@files = {} | |
end | |
def feed(line) | |
if scan_mode? && scan_match(line) | |
@read_file_mode = true | |
elsif @read_file_mode | |
read_file_name line | |
end | |
end | |
def scan_mode? | |
!@read_file_mode | |
end | |
def scan_match(line) | |
line =~ /\d+\) (Error|Failure)/ | |
end | |
def read_file_name(line) | |
if line =~ /\[*desktop\/(.*test.rb)/ | |
@files[$1] ||= 0 | |
@files[$1] += 1 | |
@read_file_mode = false | |
end | |
end | |
end | |
File.open("functionals2.txt") do |file| | |
p = Parser.new | |
file.each_line do |line| | |
p.feed line | |
end | |
p.files.each {|k, v| puts "#{k}: #{v}"} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment