Module: Minitest::Tagz::MinitestRunnerStrategy::RunPatch

Defined in:
lib/minitest/tagz.rb

Instance Method Summary collapse

Instance Method Details

#run(*args) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/minitest/tagz.rb', line 40

def run(*args)
  # Check for no match and don't filter runnable methods if there would be no match
  if Tagz.run_all_if_no_match?
    run_map = Runnable.runnables.reduce({}) {|memo, r| memo[r] = r.runnable_methods; memo}
    should_skip_filter = run_map.all? do |ctxt, methods|
      methods.all? do |m|
        serialized = MinitestRunnerStrategy.serialize(ctxt, m)
        tags = MinitestRunnerStrategy.tag_map[serialized]
        tags.nil? ||
          tags.empty? ||
          ((tags & Tagz.positive_tags).empty? &&
           (tags & Tagz.negative_tags).empty?)
      end
    end
    if should_skip_filter
      puts "Couldn't find any runnables with the given tag, running all runnables" if Tagz.log_if_no_match?
      return super
    end
  end

  ::Minitest::Test.singleton_class.class_eval { prepend(RunnableMethodsFilter) }
  super
end