Module: RSpecTracer
- Extended by:
- Configuration
- Defined in:
- lib/rspec_tracer.rb,
lib/rspec_tracer/cache.rb,
lib/rspec_tracer/filter.rb,
lib/rspec_tracer/logger.rb,
lib/rspec_tracer/runner.rb,
lib/rspec_tracer/example.rb,
lib/rspec_tracer/version.rb,
lib/rspec_tracer/reporter.rb,
lib/rspec_tracer/source_file.rb,
lib/rspec_tracer/rspec_runner.rb,
lib/rspec_tracer/configuration.rb,
lib/rspec_tracer/report_merger.rb,
lib/rspec_tracer/report_writer.rb,
lib/rspec_tracer/ruby_coverage.rb,
lib/rspec_tracer/rspec_reporter.rb,
lib/rspec_tracer/time_formatter.rb,
lib/rspec_tracer/coverage_merger.rb,
lib/rspec_tracer/coverage_writer.rb,
lib/rspec_tracer/remote_cache/aws.rb,
lib/rspec_tracer/report_generator.rb,
lib/rspec_tracer/coverage_reporter.rb,
lib/rspec_tracer/remote_cache/repo.rb,
lib/rspec_tracer/remote_cache/cache.rb,
lib/rspec_tracer/html_reporter/reporter.rb,
lib/rspec_tracer/remote_cache/validator.rb
Defined Under Namespace
Modules: Configuration, Example, HTMLReporter, RSpecReporter, RSpecRunner, RemoteCache, RubyCoverage, SourceFile, TimeFormatter
Classes: ArrayFilter, BlockFilter, Cache, CoverageMerger, CoverageReporter, CoverageWriter, Filter, Logger, RegexFilter, ReportGenerator, ReportMerger, ReportWriter, Reporter, Runner, StringFilter
Constant Summary
collapse
- PARALLEL_TESTS_BOOT_MARKER_FILENAME =
Filesystem barrier markers, layered on top of parallel_tests’s pid-file wait to defend against the GHA-observed race where the gem’s ‘wait_for_other_processes_to_finish` returns while a sibling worker hasn’t fully flushed its ‘parallel_tests_N/` dir yet. Each worker writes BOOT at setup-time and DONE as the first step of its at_exit tasks; the elected worker waits for every booted peer’s DONE marker (deadline-bounded) before proceeding to merge + purge.
'.rspec_tracer_boot'
- PARALLEL_TESTS_DONE_MARKER_FILENAME =
'.rspec_tracer_done'
- PARALLEL_TESTS_PEER_DONE_DEADLINE_SECONDS =
5
- VERSION =
'1.2.3'
Configuration::ALLOWED_CONFIGURER, Configuration::DEFAULT_CACHE_DIR, Configuration::DEFAULT_COVERAGE_DIR, Configuration::DEFAULT_LOCK_FILE, Configuration::DEFAULT_REPORT_DIR, Configuration::LOG_LEVEL
Class Attribute Summary collapse
Class Method Summary
collapse
configure
Class Attribute Details
.duplicate_examples ⇒ Object
Returns the value of attribute duplicate_examples.
45
46
47
|
# File 'lib/rspec_tracer.rb', line 45
def duplicate_examples
@duplicate_examples
end
|
.no_examples ⇒ Object
Returns the value of attribute no_examples.
45
46
47
|
# File 'lib/rspec_tracer.rb', line 45
def no_examples
@no_examples
end
|
.pid ⇒ Object
Returns the value of attribute pid.
45
46
47
|
# File 'lib/rspec_tracer.rb', line 45
def pid
@pid
end
|
.running ⇒ Object
Returns the value of attribute running.
45
46
47
|
# File 'lib/rspec_tracer.rb', line 45
def running
@running
end
|
Class Method Details
.at_exit_behavior ⇒ Object
rubocop:enable Metrics/AbcSize
91
92
93
94
95
96
97
98
99
100
101
|
# File 'lib/rspec_tracer.rb', line 91
def at_exit_behavior
return unless RSpecTracer.pid == Process.pid && RSpecTracer.running
::Kernel.exit(1) if duplicate_examples
run_exit_tasks
ensure
FileUtils.rm_f(RSpecTracer.lock_file) if parallel_tests_last_process?
RSpecTracer.running = false
end
|
.coverage_merger ⇒ Object
126
127
128
|
# File 'lib/rspec_tracer.rb', line 126
def coverage_merger
@coverage_merger if defined?(@coverage_merger)
end
|
.coverage_reporter ⇒ Object
118
119
120
|
# File 'lib/rspec_tracer.rb', line 118
def coverage_reporter
@coverage_reporter if defined?(@coverage_reporter)
end
|
.examples_traced_files ⇒ Object
142
143
144
|
# File 'lib/rspec_tracer.rb', line 142
def examples_traced_files
@examples_traced_files if defined?(@examples_traced_files)
end
|
.filter_examples ⇒ Object
rubocop:disable Metrics/AbcSize
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# File 'lib/rspec_tracer.rb', line 60
def filter_examples
groups = Set.new
to_run = Hash.new { |hash, group| hash[group] = [] }
RSpec.world.filtered_examples.each_pair do |example_group, examples|
examples.each do |example|
tracer_example = RSpecTracer::Example.from(example)
example_id = tracer_example[:example_id]
example.metadata[:rspec_tracer_example_id] = example_id
if runner.run_example?(example_id)
run_reason = runner.run_example_reason(example_id)
tracer_example[:run_reason] = run_reason
example.metadata[:description] = "#{example.description} (#{run_reason})"
to_run[example_group] << example
groups << example.example_group.parent_groups.last
runner.register_example(tracer_example)
else
runner.on_example_skipped(example_id)
end
end
end
runner.deregister_duplicate_examples
[to_run, groups.to_a]
end
|
.parallel_tests? ⇒ Boolean
150
151
152
|
# File 'lib/rspec_tracer.rb', line 150
def parallel_tests?
defined?(@parallel_tests) && @parallel_tests == true
end
|
.report_merger ⇒ Object
130
131
132
|
# File 'lib/rspec_tracer.rb', line 130
def report_merger
@report_merger if defined?(@report_merger)
end
|
.report_writer ⇒ Object
122
123
124
|
# File 'lib/rspec_tracer.rb', line 122
def report_writer
@report_writer if defined?(@report_writer)
end
|
.runner ⇒ Object
114
115
116
|
# File 'lib/rspec_tracer.rb', line 114
def runner
@runner if defined?(@runner)
end
|
.simplecov? ⇒ Boolean
146
147
148
|
# File 'lib/rspec_tracer.rb', line 146
def simplecov?
defined?(@simplecov) && @simplecov == true
end
|
.start ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/rspec_tracer.rb', line 47
def start
RSpecTracer.running = false
RSpecTracer.pid = Process.pid
return if RUBY_ENGINE == 'jruby' && !valid_jruby_opts?
RSpecTracer.logger.debug "Started RSpec tracer (pid: #{RSpecTracer.pid})"
parallel_tests_setup
initial_setup
end
|
.start_example_trace ⇒ Object
103
104
105
|
# File 'lib/rspec_tracer.rb', line 103
def start_example_trace
trace_point.enable
end
|
.stop_example_trace(example_id) ⇒ Object
107
108
109
110
111
112
|
# File 'lib/rspec_tracer.rb', line 107
def stop_example_trace(example_id)
trace_point.disable
@examples_traced_files[example_id] = @traced_files
@traced_files = Set.new
end
|
.trace_point ⇒ Object
134
135
136
|
# File 'lib/rspec_tracer.rb', line 134
def trace_point
@trace_point if defined?(@trace_point)
end
|
.traced_files ⇒ Object
138
139
140
|
# File 'lib/rspec_tracer.rb', line 138
def traced_files
@traced_files if defined?(@traced_files)
end
|