Class: Henitai::Integration::Minitest

Inherits:
Base
  • Object
show all
Includes:
MutantRunSupport, RspecTestSelection
Defined in:
lib/henitai/integration/minitest.rb,
sig/henitai.rbs

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 =

Returns:

  • (Float)
300.0

Constants included from RspecTestSelection

RspecTestSelection::REQUIRE_DIRECTIVE_PATTERN

Instance Method Summary collapse

Methods included from RspecTestSelection

#select_tests

Methods included from MutantRunSupport

#build_result, #mutant_log_name, #run_child_activation_and_tests, #scenario_log_paths

Methods inherited from Base

#cleanup_child_process, #cleanup_process_group, #debug_child?, #debug_child_activation_check, #debug_child_activation_end, #debug_child_activation_start, #debug_child_example_count, #debug_child_mutant_meta, #debug_child_puts, #debug_child_rspec_exit, #debug_child_rspec_trace, #handle_timeout, #loaded_feature?, #loaded_feature_map, #pause, #reap_child, #restore_subprocess_env, #rspec_world_example_count, #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.

Parameters:

  • (Integer, nil)
  • (Object)


88
89
90
91
92
93
# File 'lib/henitai/integration/minitest.rb', line 88

def cleanup_suite_process(pid, wait_result)
  return unless pid

  cleanup_child_process(pid)
  reap_child(pid) if wait_result.nil?
end

#per_test_coverage_supported?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/henitai/integration/minitest.rb', line 28

def per_test_coverage_supported?
  true
end

#preload_environmentvoid

This method returns an undefined value.



516
# File 'sig/henitai.rbs', line 516

def preload_environment: () -> void

#run_in_child(mutant:, test_files:, log_paths:) ⇒ Integer

Parameters:

  • mutant: (Mutant)
  • test_files: (Array[String])
  • log_paths: (Hash[Symbol, String])

Returns:

  • (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

#run_mutant(mutant:, test_files:, timeout:) ⇒ ScenarioExecutionResult

Parameters:

  • mutant: (Mutant)
  • test_files: (Array[String])
  • timeout: (Float)

Returns:



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

Parameters:

  • (Array[String])
  • timeout: (Float) (defaults to: DEFAULT_SUITE_TIMEOUT)

Returns:



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

Parameters:

  • (Array[String])

Returns:

  • (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_pathvoid

This method returns an undefined value.



517
# File 'sig/henitai.rbs', line 517

def setup_load_path: () -> void

#spawn_mutant(mutant:, test_files:) ⇒ ChildHandle

Parameters:

  • mutant: (Mutant)
  • test_files: (Array[String])

Returns:



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

Parameters:

  • (Array[String])
  • (Hash[Symbol, String])

Returns:

  • (Integer)


74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/henitai/integration/minitest.rb', line 74

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
      )
    end
  end
end

#spec_filesArray[String]

Returns:

  • (Array[String])


95
96
97
98
# File 'lib/henitai/integration/minitest.rb', line 95

def spec_files
  (Dir.glob("test/**/*_test.rb") + Dir.glob("test/**/*_spec.rb"))
    .reject { |f| f.start_with?("test/system/") }
end

#subprocess_envHash[String, String]

Returns:

  • (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

Returns:

  • (nil)


518
# File 'sig/henitai.rbs', line 518

def suppress_minitest_autorun!: () -> nil

#suppress_simplecov!void

This method returns an undefined value.



519
# File 'sig/henitai.rbs', line 519

def suppress_simplecov!: () -> void

#test_filesArray[String]

Returns:

  • (Array[String])


26
# File 'lib/henitai/integration/minitest.rb', line 26

def test_files = spec_files