File: binary_search_specs.rb

package info (click to toggle)
puppet-agent 8.10.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,404 kB
  • sloc: ruby: 286,820; sh: 492; xml: 116; makefile: 88; cs: 68
file content (28 lines) | stat: -rwxr-xr-x 723 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env ruby
# Author: Nick Lewis

specs_in_order = File.read('spec_order.txt').split

failing_spec = ARGV.first

specs = specs_in_order[0...specs_in_order.index(failing_spec)]

suspects = specs

while suspects.length > 1 do
  count = suspects.length
  specs_to_run = suspects[0...(count/2)]
  puts "Trying #{specs_to_run.join(' ')}"
  start = Time.now
  system("bundle exec rspec #{specs_to_run.join(' ')} #{failing_spec}")
  puts "Finished in #{Time.now - start} seconds"
  if $? == 0
    puts "This group is innocent. The culprit is in the other half."
    suspects = suspects[(count/2)..-1]
  else
    puts "One of these is guilty."
    suspects = specs_to_run
  end
end

puts "The culprit is #{suspects.first}"