Module: RSpecTracer

Extended by:
Configuration
Defined in:
lib/rspec_tracer/cache.rb,
lib/rspec_tracer/filter.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,
lib/rspec_tracer.rb

Defined Under Namespace

Modules: Configuration, Example, HTMLReporter, RSpecReporter, RSpecRunner, RemoteCache, RubyCoverage, SourceFile, TimeFormatter Classes: ArrayFilter, BlockFilter, Cache, CoverageMerger, CoverageReporter, CoverageWriter, Filter, RegexFilter, ReportGenerator, ReportMerger, ReportWriter, Reporter, Runner, StringFilter

Constant Summary collapse

VERSION =
'1.0.0'

Constants included from Configuration

Configuration::DEFAULT_CACHE_DIR, Configuration::DEFAULT_COVERAGE_DIR, Configuration::DEFAULT_REPORT_DIR

Class Attribute Summary collapse

Attributes included from Configuration

#coverage_filters, #filters

Class Method Summary collapse

Methods included from Configuration

add_coverage_filter, add_filter, cache_dir, cache_path, configure, coverage_dir, coverage_path, coverage_track_files, coverage_tracked_files, parallel_tests_lock_file, project_name, report_dir, report_path, root, verbose?

Class Attribute Details

.no_examplesObject

Returns the value of attribute no_examples.



36
37
38
# File 'lib/rspec_tracer.rb', line 36

def no_examples
  @no_examples
end

.pidObject

Returns the value of attribute pid.



36
37
38
# File 'lib/rspec_tracer.rb', line 36

def pid
  @pid
end

.runningObject

Returns the value of attribute running.



36
37
38
# File 'lib/rspec_tracer.rb', line 36

def running
  @running
end

Class Method Details

.at_exit_behaviorObject

rubocop:enable Metrics/AbcSize



83
84
85
86
87
88
89
90
91
92
93
# File 'lib/rspec_tracer.rb', line 83

def at_exit_behavior
  return unless RSpecTracer.pid == Process.pid && RSpecTracer.running

  run_exit_tasks

  ::Kernel.exit(1) if runner.non_zero_exit_code?
ensure
  FileUtils.rm_f(RSpecTracer.parallel_tests_lock_file) if parallel_tests_last_process?

  RSpecTracer.running = false
end

.coverage_mergerObject



121
122
123
# File 'lib/rspec_tracer.rb', line 121

def coverage_merger
  return @coverage_merger if defined?(@coverage_merger)
end

.coverage_reporterObject



117
118
119
# File 'lib/rspec_tracer.rb', line 117

def coverage_reporter
  return @coverage_reporter if defined?(@coverage_reporter)
end

.filter_examplesObject

rubocop:disable Metrics/AbcSize



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/rspec_tracer.rb', line 52

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.[: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.[: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

Returns:

  • (Boolean)


145
146
147
# File 'lib/rspec_tracer.rb', line 145

def parallel_tests?
  return @parallel_tests if defined?(@parallel_tests)
end

.report_mergerObject



125
126
127
# File 'lib/rspec_tracer.rb', line 125

def report_merger
  return @report_merger if defined?(@report_merger)
end

.runnerObject



113
114
115
# File 'lib/rspec_tracer.rb', line 113

def runner
  return @runner if defined?(@runner)
end

.simplecov?Boolean

Returns:

  • (Boolean)


141
142
143
# File 'lib/rspec_tracer.rb', line 141

def simplecov?
  return @simplecov if defined?(@simplecov)
end

.start(&block) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/rspec_tracer.rb', line 38

def start(&block)
  RSpecTracer.running = false
  RSpecTracer.pid = Process.pid

  return if RUBY_ENGINE == 'jruby' && !valid_jruby_opts?

  puts "Started RSpec tracer (pid: #{RSpecTracer.pid})"

  parallel_tests_setup
  configure(&block) if block
  initial_setup
end

.start_example_traceObject



95
96
97
# File 'lib/rspec_tracer.rb', line 95

def start_example_trace
  trace_point.enable if trace_example?
end

.stop_example_trace(success) ⇒ Object



99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/rspec_tracer.rb', line 99

def stop_example_trace(success)
  return unless trace_example?

  trace_point.disable

  unless success
    @traced_files = Set.new

    return
  end

  @trace_example = false
end

.trace_example?Boolean

Returns:

  • (Boolean)


137
138
139
# File 'lib/rspec_tracer.rb', line 137

def trace_example?
  defined?(@trace_example) ? @trace_example : false
end

.trace_pointObject



129
130
131
# File 'lib/rspec_tracer.rb', line 129

def trace_point
  return @trace_point if defined?(@trace_point)
end

.traced_filesObject



133
134
135
# File 'lib/rspec_tracer.rb', line 133

def traced_files
  return @traced_files if defined?(@traced_files)
end