I want to write some code to do the things below:
-
If the input file (e.g.:
"file.out") contains the info like"n failures, n errors","n failures, 0 errors", or"0 failures, n errors"(wheren >= 1), thenputs "script failed"(because there are failures or errors displayed). -
If the input file contains the info:
"0 failures, 0 errors", thenputs "script passed"(because there are no failures and errors displayed).
I think I need to write something like below (but it does not work correctly as the scenario I expect):
if open("#{file}.out").grep(/[1-9][0-9]* failures|[1-9][0-9]* errors/).length > 0
puts "script passed"
else
puts "script failed"
end
How can I accomplish this?
Usage: