Skip to content

Commit

Permalink
+ Removed #bisect_files and mode accessor. Just deal with methods onl…
Browse files Browse the repository at this point in the history
…y for now.

[git-p4: depot-paths = "//src/minitest-bisect/dev/": change = 13112]
  • Loading branch information
zenspider committed May 22, 2021
1 parent b47c18d commit 9cd63ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 59 deletions.
58 changes: 11 additions & 47 deletions lib/minitest/bisect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def process_flags flags
RbConfig::CONFIG['ruby_install_name'] +
RbConfig::CONFIG['EXEEXT']).sub(/.*\s.*/m, '"\&"')

attr_accessor :tainted, :failures, :culprits, :mode, :seen_bad
attr_accessor :tainted, :failures, :culprits, :seen_bad
alias :tainted? :tainted

def self.run files
Expand All @@ -78,18 +78,14 @@ def run args

cmd = nil

if :until_I_have_negative_filtering_in_minitest != 0 then
mt_flags = args.dup
expander = Minitest::Bisect::PathExpander.new mt_flags
mt_flags = args.dup
expander = Minitest::Bisect::PathExpander.new mt_flags

files = expander.process
rb_flags = expander.rb_flags
mt_flags += ["--server", $$]
files = expander.process
rb_flags = expander.rb_flags
mt_flags += ["--server", $$]

cmd = bisect_methods build_files_cmd(files, rb_flags, mt_flags)
else
cmd = bisect_methods bisect_files args
end
cmd = bisect_methods build_files_cmd(files, rb_flags, mt_flags)

puts "Final reproduction:"
puts
Expand All @@ -99,37 +95,7 @@ def run args
Minitest::Server.stop
end

def bisect_files files
self.mode = :files

files, flags = files.partition { |arg| File.file? arg }
rb_flags, mt_flags = flags.partition { |arg| arg =~ /^-I/ }
mt_flags += ["--server", $$]

puts "reproducing..."
system "#{build_files_cmd files, rb_flags, mt_flags} #{SHH}"
abort "Reproduction run passed? Aborting. Try running with MTB_VERBOSE=2 to verify." unless tainted?
puts "reproduced"

found, count = files.find_minimal_combination_and_count do |test|
puts "# of culprit files: #{test.size}"

system "#{build_files_cmd test, rb_flags, mt_flags} #{SHH}"

self.tainted?
end

puts
puts "Minimal files found in #{count} steps:"
puts
cmd = build_files_cmd found, rb_flags, mt_flags
puts cmd
cmd
end

def bisect_methods cmd
self.mode = :methods

time_it "reproducing...", build_methods_cmd(cmd)

unless tainted? then
Expand Down Expand Up @@ -245,12 +211,10 @@ def minitest_start
def minitest_result file, klass, method, fails, assertions, time
fails.reject! { |fail| Minitest::Skip === fail }

if mode == :methods then
if fails.empty? then
culprits << "#{klass}##{method}" unless seen_bad # UGH
else
self.seen_bad = true
end
if fails.empty? then
culprits << "#{klass}##{method}" unless seen_bad # UGH
else
self.seen_bad = true
end

return if fails.empty?
Expand Down
13 changes: 1 addition & 12 deletions test/minitest/test_bisect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class TestMinitest::TestBisect < Minitest::Test

def setup
self.bisect = Minitest::Bisect.new
bisect.reset
end

def test_class_run
Expand Down Expand Up @@ -124,9 +125,6 @@ def test_map_failures
end

def test_minitest_result
bisect.mode = :methods
bisect.reset

bisect.minitest_result "file.rb", "TestClass", "test_method", [], 1, 1

assert_equal false, bisect.tainted
Expand All @@ -135,9 +133,6 @@ def test_minitest_result
end

def test_minitest_result_skip
bisect.mode = :methods
bisect.reset

fail = Minitest::Skip.new("woot")

bisect.minitest_result "file.rb", "TestClass", "test_method", [fail], 1, 1
Expand All @@ -148,9 +143,6 @@ def test_minitest_result_skip
end

def test_minitest_result_fail
bisect.mode = :methods
bisect.reset

fail = Minitest::Assertion.new "msg"

bisect.minitest_result "file.rb", "TestClass", "test_method", [fail], 1, 1
Expand All @@ -163,9 +155,6 @@ def test_minitest_result_fail
end

def test_minitest_result_error
bisect.mode = :methods
bisect.reset

fail = Minitest::UnexpectedError.new RuntimeError.new("woot")

bisect.minitest_result "file.rb", "TestClass", "test_method", [fail], 1, 1
Expand Down

0 comments on commit 9cd63ed

Please sign in to comment.