Skip to content

Instantly share code, notes, and snippets.

@zenspider

zenspider/fail.rb

Created Jun 4, 2020
Embed
What would you like to do?
#!/usr/bin/env ruby -ws
$f ||= false # fast
require "fileutils"
FileUtils.mkdir_p "results"
class Array
def human_sort
base = 10
sort_by { |item| item.to_s.split(/(\d+)/).map { |e| [e.to_i(base), e] } }
end
end
system "./travis_current_failures.rb > fail.log" unless File.exist? "fail.log"
unknowns = File.readlines("fail.log").map(&:chomp).human_sort.uniq
max = unknowns.size
bad = []
t0 = Time.now
puts "Running #{max} failures"
unknowns.each_with_index do |path, i|
result_path = "results/#{path.tr "^a-zA-Z0-9", "."}.log"
next if $f && File.file?(result_path)
warn "%4d: %s" % [max-i, path]
cmd = "testrbl #{path} &> #{result_path}"
t1 = Time.now
passed = system cmd
td = Time.now - t1
if passed
if File.empty? result_path
warn " %.2fs: no tests! %s" % [td, path]
bad << path
else
warn " %.2fs: passed %s" % [td, path]
end
else
warn " %.2fs: failed %s => %s" % [td, path, result_path]
bad << path
end
end
puts "Ran in %d seconds" % [ Time.now - t0 ]
puts "Bad files left: %d" % [bad.size]
File.write "fail.log", bad.human_sort.join("\n")
system "say done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.