Module: RSpec::Abq::Extensions::Runner

Defined in:
lib/rspec/abq/extensions.rb

Overview

Runner is class responsbile for execution in RSpec

Instance Method Summary collapse

Instance Method Details

#run_specs(example_groups) ⇒ Fixnum

Runs the provided example groups.

Parameters:

  • example_groups (Array<RSpec::Core::ExampleGroup>)

    groups to run. Ignored in favor of @world.ordered_example_groups

Returns:

  • (Fixnum)

    exit status code. 0 if all specs passed or if rspec-abq wants to quit early, or the configured failure exit status (1 by default) if specs failed.



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/rspec/abq/extensions.rb', line 121

def run_specs(example_groups)
  if Gem::Version.new(RSpec::Core::Version::STRING) >= Gem::Version.new("3.11.0") && RSpec.world.rspec_is_quitting
    return exit_code(false)
  end

  if !!ENV[ABQ_GENERATE_MANIFEST]
    # before abq can start workers, it asks for a manifest
    RSpec::Abq::Manifest.write_manifest(example_groups, RSpec.configuration.seed, RSpec.configuration.ordering_registry)
    # gracefully quit after manifest generation. The worker will launch another instance of rspec with an init_message
    return 0
  end

  return 0 if Abq.fast_exit?

  # if not quitting early, ensure we have an initial test
  Abq.fetch_next_example

  # Note: this is all examples, not the examples run by ABQ. Because of that, the numbers in the worker
  # summary will likely be wrong.
  examples_count = @world.example_count(example_groups)
  examples_passed = @configuration.reporter.report(examples_count) do |reporter|
    @configuration.with_suite_hooks do
      if examples_count == 0 && @configuration.fail_if_no_examples
        return @configuration.failure_exit_code
      end

      example_groups.map { |g| g.run_with_abq(reporter) }.all?
    end
  end

  if Abq.target_test_case != Abq::TestCase.end_marker
    warn "Hit end of test run without being on end marker. Target test case is #{Abq.target_test_case.inspect}"
    examples_passed = false
  end

  if Gem::Version.new(RSpec::Core::Version::STRING) >= Gem::Version.new("3.10.0")
    exit_code(examples_passed)
  else
    examples_passed ? 0 : @configuration.failure_exit_code
  end
end