Class: Henitai::Integration::Minitest
Overview
Minitest integration adapter.
A sibling of Rspec behind Base: it shares the framework-agnostic mutant-run
orchestration (MutantRunSupport) and test selection (RspecTestSelection)
but implements its own Minitest-specific test invocation and suite command.
Per-test coverage collection is not yet wired into this path.
Constant Summary
collapse
- DEFAULT_SUITE_TIMEOUT =
300.0
RspecTestSelection::REQUIRE_DIRECTIVE_PATTERN
Instance Method Summary
collapse
-
#cleanup_suite_process(pid, wait_result) ⇒ void
A timeout has already torn the group down and reaped the child in handle_timeout; signalling again would only race a recycled pid.
-
#per_test_coverage_supported? ⇒ Boolean
-
#preload_environment ⇒ void
-
#run_in_child(mutant:, test_files:, log_paths:) ⇒ Integer
-
#run_mutant(mutant:, test_files:, timeout:) ⇒ ScenarioExecutionResult
-
#run_suite(test_files, timeout: DEFAULT_SUITE_TIMEOUT) ⇒ ScenarioExecutionResult
-
#run_tests(test_files) ⇒ Integer
-
#setup_load_path ⇒ void
-
#spawn_mutant(mutant:, test_files:) ⇒ ChildHandle
-
#spawn_suite_process(test_files, log_paths) ⇒ Integer
pgroup: true makes the suite child a group leader, so the whole tree it spawns -- a Rails test server, browser drivers -- is signalable as one group.
-
#spec_files ⇒ Array[String]
-
#subprocess_env ⇒ Hash[String, String]
-
#suite_command(test_files) ⇒ Object
-
#suppress_minitest_autorun! ⇒ nil
-
#suppress_simplecov! ⇒ void
-
#test_files ⇒ Array[String]
#select_tests
#build_result, #mutant_log_name, #run_child_activation_and_tests, #scenario_log_paths
Methods inherited from Base
#child_debug_log, #cleanup_child_process, #cleanup_process_group, #handle_timeout, #pause, #reap_child, #restore_subprocess_env, #scenario_log_support, #select_tests, #suppress_coverage!, #wait_nonblocking, #wait_with_timeout, #with_non_interactive_stdin, #with_subprocess_env
Instance Method Details
#cleanup_suite_process(pid, wait_result) ⇒ void
This method returns an undefined value.
A timeout has already torn the group down and reaped the child in
handle_timeout; signalling again would only race a recycled pid.
96
97
98
99
100
101
|
# File 'lib/henitai/integration/minitest.rb', line 96
def cleanup_suite_process(pid, wait_result)
return unless pid
cleanup_process_group(pid) unless wait_result == :timeout
reap_child(pid) if wait_result.nil?
end
|
#per_test_coverage_supported? ⇒ Boolean
28
29
30
|
# File 'lib/henitai/integration/minitest.rb', line 28
def per_test_coverage_supported?
true
end
|
#preload_environment ⇒ void
This method returns an undefined value.
526
|
# File 'sig/henitai.rbs', line 526
def preload_environment: () -> void
|
#run_in_child(mutant:, test_files:, log_paths:) ⇒ Integer
42
43
44
45
46
|
# File 'lib/henitai/integration/minitest.rb', line 42
def run_in_child(mutant:, test_files:, log_paths:)
ENV["RAILS_ENV"] = "test" unless ENV["RAILS_ENV"] == "test"
RailsEnvironmentPreloader.new.call
super
end
|
32
33
34
35
|
# File 'lib/henitai/integration/minitest.rb', line 32
def run_mutant(mutant:, test_files:, timeout:)
MinitestLoadPath.ensure!
super
end
|
#run_suite(test_files, timeout: DEFAULT_SUITE_TIMEOUT) ⇒ ScenarioExecutionResult
48
49
50
51
52
53
54
55
|
# File 'lib/henitai/integration/minitest.rb', line 48
def run_suite(test_files, timeout: DEFAULT_SUITE_TIMEOUT)
log_paths = scenario_log_paths("baseline")
pid = spawn_suite_process(test_files, log_paths)
wait_result = wait_with_timeout(pid, timeout)
build_result(wait_result, log_paths)
ensure
cleanup_suite_process(pid, wait_result)
end
|
#run_tests(test_files) ⇒ Integer
63
64
65
|
# File 'lib/henitai/integration/minitest.rb', line 63
def run_tests(test_files)
MinitestTestRunner.new.call(test_files)
end
|
#setup_load_path ⇒ void
This method returns an undefined value.
527
|
# File 'sig/henitai.rbs', line 527
def setup_load_path: () -> void
|
#spawn_mutant(mutant:, test_files:) ⇒ ChildHandle
37
38
39
40
|
# File 'lib/henitai/integration/minitest.rb', line 37
def spawn_mutant(mutant:, test_files:)
MinitestLoadPath.ensure!
super
end
|
#spawn_suite_process(test_files, log_paths) ⇒ Integer
pgroup: true makes the suite child a group leader, so the whole tree
it spawns -- a Rails test server, browser drivers -- is signalable as
one group. Without it the parent's kill(:SIGTERM, -pid) addresses a
group that does not exist, raises ESRCH, and leaves a timed-out suite
running to completion while the parent has already given up on it.
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
# File 'lib/henitai/integration/minitest.rb', line 79
def spawn_suite_process(test_files, log_paths)
FileUtils.mkdir_p(File.dirname(log_paths[:stdout_path]))
File.open(log_paths[:stdout_path], "w") do |stdout_file|
File.open(log_paths[:stderr_path], "w") do |stderr_file|
Process.spawn(
subprocess_env,
*suite_command(test_files),
out: stdout_file,
err: stderr_file,
pgroup: true
)
end
end
end
|
#spec_files ⇒ Array[String]
103
104
105
106
|
# File 'lib/henitai/integration/minitest.rb', line 103
def spec_files
(Dir.glob("test/**/*_test.rb") + Dir.glob("test/**/*_spec.rb"))
.reject { |f| f.start_with?("test/system/") }
end
|
#subprocess_env ⇒ Hash[String, String]
67
68
69
70
71
72
|
# File 'lib/henitai/integration/minitest.rb', line 67
def subprocess_env
env = super
env["RAILS_ENV"] = "test" unless ENV["RAILS_ENV"] == "test"
env["PARALLEL_WORKERS"] = "1"
env
end
|
#suite_command(test_files) ⇒ Object
57
58
59
|
# File 'lib/henitai/integration/minitest.rb', line 57
def suite_command(test_files)
MinitestSuiteCommand.new.build(test_files)
end
|
#suppress_minitest_autorun! ⇒ nil
528
|
# File 'sig/henitai.rbs', line 528
def suppress_minitest_autorun!: () -> nil
|
#suppress_simplecov! ⇒ void
This method returns an undefined value.
529
|
# File 'sig/henitai.rbs', line 529
def suppress_simplecov!: () -> void
|
#test_files ⇒ Array[String]
26
|
# File 'lib/henitai/integration/minitest.rb', line 26
def test_files = spec_files
|