Class: Evilution::Integration::Minitest Private
- Defined in:
- lib/evilution/integration/minitest.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
- .baseline_options ⇒ Object private
- .baseline_runner ⇒ Object private
- .baseline_test_files(test_file) ⇒ Object private
-
.dispatch_minitest_suites(reporter, options) ⇒ Object
private
Dispatch to the version-appropriate suite runner.
-
.initialize_minitest_state(reporter, options) ⇒ Object
private
Mirror Minitest.run's preamble: seed setup + plugin init.
- .run_baseline_minitest ⇒ Object private
- .run_baseline_test_file(test_file) ⇒ Object private
-
.stub_autorun! ⇒ Object
private
User helpers that
require "minitest/autorun"install an at_exit handler callingMinitest.run(ARGV).
Instance Method Summary collapse
-
#initialize(test_files: nil, hooks: nil, fallback_to_full_suite: false, spec_selector: nil) ⇒ Minitest
constructor
private
A new instance of Minitest.
Methods inherited from Base
Constructor Details
#initialize(test_files: nil, hooks: nil, fallback_to_full_suite: false, spec_selector: nil) ⇒ Minitest
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Minitest.
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/evilution/integration/minitest.rb', line 94 def initialize(test_files: nil, hooks: nil, fallback_to_full_suite: false, spec_selector: nil) @test_files = test_files @minitest_loaded = false @spec_selector = spec_selector || Evilution::SpecSelector.new( spec_resolver: Evilution::SpecResolver.new(test_dir: "test", test_suffix: "_test.rb", request_dir: "integration") ) @fallback_to_full_suite = fallback_to_full_suite @crash_detector = nil @warned_files = Set.new super(hooks: hooks) end |
Class Method Details
.baseline_options ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
86 87 88 89 90 91 92 |
# File 'lib/evilution/integration/minitest.rb', line 86 def self. { runner: baseline_runner, spec_resolver: Evilution::SpecResolver.new(test_dir: "test", test_suffix: "_test.rb", request_dir: "integration"), fallback_dir: "test" } end |
.baseline_runner ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
13 14 15 |
# File 'lib/evilution/integration/minitest.rb', line 13 def self.baseline_runner ->(test_file) { run_baseline_test_file(test_file) } end |
.baseline_test_files(test_file) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
40 41 42 |
# File 'lib/evilution/integration/minitest.rb', line 40 def self.baseline_test_files(test_file) File.directory?(test_file) ? Dir.glob(File.join(test_file, "**/*_test.rb")) : [test_file] end |
.dispatch_minitest_suites(reporter, options) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Dispatch to the version-appropriate suite runner. Minitest 6 removed ::Minitest.__run; the equivalent public entry point is run_all_suites. Minitest 5.x still exposes __run.
75 76 77 78 79 80 81 82 83 84 |
# File 'lib/evilution/integration/minitest.rb', line 75 def self.dispatch_minitest_suites(reporter, ) if ::Minitest.respond_to?(:run_all_suites) ::Minitest.run_all_suites(reporter, ) elsif ::Minitest.respond_to?(:__run) ::Minitest.__run(reporter, ) else raise Evilution::Error, "Minitest #{::Minitest::VERSION} has neither run_all_suites nor __run" end end |
.initialize_minitest_state(reporter, options) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Mirror Minitest.run's preamble: seed setup + plugin init. Without seeding
Minitest.seed before dispatching suites, Minitest 5.x raises
TypeError: no implicit conversion of nil into Integer from
Minitest::Test.runnable_methods calling srand(Minitest.seed) on nil.
init_plugins also needs Minitest.reporter set first because some plugins
(pride) read it during init.
63 64 65 66 67 68 69 70 |
# File 'lib/evilution/integration/minitest.rb', line 63 def self.initialize_minitest_state(reporter, ) ::Minitest.seed = [:seed] srand(::Minitest.seed) if ::Minitest.seed ::Minitest.reporter = reporter ::Minitest.init_plugins() if ::Minitest.respond_to?(:init_plugins) ::Minitest.reporter = nil end |
.run_baseline_minitest ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/evilution/integration/minitest.rb', line 44 def self.run_baseline_minitest out = StringIO.new = ::Minitest.process_args(["--seed", "0"]) [:io] = out reporter = ::Minitest::CompositeReporter.new reporter << ::Minitest::SummaryReporter.new(out, ) initialize_minitest_state(reporter, ) reporter.start dispatch_minitest_suites(reporter, ) reporter.report reporter.passed? end |
.run_baseline_test_file(test_file) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/evilution/integration/minitest.rb', line 17 def self.run_baseline_test_file(test_file) require "minitest" require "stringio" stub_autorun! ::Minitest::Runnable.runnables.clear files = baseline_test_files(test_file) Evilution::Integration::Loading::TestLoadPath.add!(files) files.each { |f| load(File.(f)) } run_baseline_minitest end |
.stub_autorun! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
User helpers that require "minitest/autorun" install an at_exit handler
calling Minitest.run(ARGV). At evilution process exit ARGV still holds
evilution flags (--integration, --spec, ...) and Minitest's option parser
prints a misleading "invalid option" banner. Stubbing autorun before user
code loads prevents the handler from ever being installed.
33 34 35 36 37 38 |
# File 'lib/evilution/integration/minitest.rb', line 33 def self.stub_autorun! location = ::Minitest.singleton_class.instance_method(:autorun).source_location return if location && location.first == __FILE__ ::Minitest.define_singleton_method(:autorun) { nil } end |