Class: Henitai::Integration::Rspec
Overview
RSpec integration adapter.
Constant Summary
collapse
- DEFAULT_SUITE_TIMEOUT =
300.0
Henitai::Integration::RspecTestSelection::REQUIRE_DIRECTIVE_PATTERN
Instance Method Summary
collapse
#select_tests
#build_result, #mutant_log_name, #run_child_activation_and_tests, #run_in_child, #run_mutant, #scenario_log_paths, #spawn_mutant
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, #run_mutant, #scenario_log_support, #select_tests, #spawn_mutant, #subprocess_env, #suppress_coverage!, #suppress_simplecov!, #wait_nonblocking, #wait_with_timeout, #with_non_interactive_stdin, #with_subprocess_env
Instance Method Details
#per_test_coverage_supported? ⇒ Boolean
57
58
59
|
# File 'lib/henitai/integration.rb', line 57
def per_test_coverage_supported?
true
end
|
#rspec_suite_runner_script ⇒ String
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/henitai/integration.rb', line 74
def rspec_suite_runner_script
<<~RUBY
require "rspec/core"
test_files = ARGV.map { |file| File.expand_path(file) }
config = RSpec.configuration
options = RSpec::Core::ConfigurationOptions.new(
["--format", "progress", "--format", "Henitai::CoverageFormatter"]
)
runner = RSpec::Core::Runner.send(:new, options)
RSpec::Core::Runner.send(:trap_interrupt)
runner.send(:configure, $stderr, $stdout)
config.files_to_run = test_files
config.load_spec_files
status = runner.send(:run_specs, RSpec.world.ordered_example_groups)
exit(status.is_a?(Integer) ? status : (status == true ? 0 : 1))
RUBY
end
|
#run_tests(test_files) ⇒ Integer
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
# File 'lib/henitai/integration.rb', line 111
def run_tests(test_files)
require "rspec/core"
::RSpec.__send__(:configuration).fail_if_no_examples = true
debug_child_rspec_trace(test_files:, rspec_options: [], rspec_argv: test_files)
debug_child_example_count("before_run") debug_child_puts("[henitai-debug-child] runner_run_start")
status = run_rspec_runner(test_files)
debug_child_puts("[henitai-debug-child] runner_run_return status=#{status.inspect}")
debug_child_example_count("after_run") debug_child_rspec_exit(status)
return status if status.is_a?(Integer)
status == true ? 0 : 1
end
|
#spawn_suite_process(test_files, log_paths) ⇒ Integer
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/henitai/integration.rb', line 95
def spawn_suite_process(test_files, log_paths)
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
|
#suite_command(test_files) ⇒ Array[String]
65
66
67
68
69
70
71
72
|
# File 'lib/henitai/integration.rb', line 65
def suite_command(test_files)
[
"bundle", "exec", "ruby",
"-r", "henitai/rspec_coverage_formatter",
"-e", rspec_suite_runner_script,
*test_files
]
end
|
#test_files ⇒ Array[String]
55
|
# File 'lib/henitai/integration.rb', line 55
def test_files = spec_files
|