Skip to content

Instantly share code, notes, and snippets.

@gnarg
Created February 19, 2013 21:57
Show Gist options
  • Save gnarg/4990495 to your computer and use it in GitHub Desktop.
Save gnarg/4990495 to your computer and use it in GitHub Desktop.
def bisect(suspects, victim)
return suspects[0] if suspects.size == 1
pivot = suspects.size / 2
suspects.partition {|file| suspects.index(file) < pivot }.each do |part|
command = %[ruby -r test/unit -I ./vendor/gems/dependency_detection-0.0.1.build/lib -r dependency_detection -r./#{part.join(' -r ./')} #{victim}]
print command + "\n"
if system(command)
puts "------ PASSED: #{$?} -------"
next
else
puts "------ FAILED: #{$?} -------"
return bisect(part, victim)
end
end
end
victim = ARGV[0]
suspects = Dir.glob((ARGV[1] || 'test/**/*_test.rb')) - [victim]
suspects.reject!{|path| path.include?('multiverse') }
puts "FOUND: " + bisect(suspects, victim).inspect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment