Skip to content

Commit

Permalink
Allow SpecRunner to not run in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre authored and mergify[bot] committed Aug 26, 2020
1 parent 25f436e commit 220e6b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 6 additions & 2 deletions tasks/check_commit.rake
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ RuboCop::RakeTask.new(:check_commit, :commit) do |t, args|
paths.reject { |p| p.start_with?(/docs|Gemfile|README|CHANGELOG/) }
specs = paths.select { |p| p.start_with?('spec') }

puts "Checking: #{paths.join(' ')}"
RuboCop::SpecRunner.new(specs).run_specs
if specs.empty?
puts 'Caution: No spec was changed!'
else
puts "Checking: #{paths.join(' ')}"
RuboCop::SpecRunner.new(specs, parallel: false).run_specs
end

t.patterns = paths
end
6 changes: 4 additions & 2 deletions tasks/spec_runner.rake
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,20 @@ module RuboCop
class SpecRunner
attr_reader :rspec_args

def initialize(rspec_args = %w[spec], external_encoding: 'UTF-8', internal_encoding: nil)
def initialize(rspec_args = %w[spec], parallel: true,
external_encoding: 'UTF-8', internal_encoding: nil)
@rspec_args = rspec_args
@previous_external_encoding = Encoding.default_external
@previous_internal_encoding = Encoding.default_internal

@temporary_external_encoding = external_encoding
@temporary_internal_encoding = internal_encoding
@parallel = parallel
end

def run_specs
n_failures = with_encoding do
if Process.respond_to?(:fork)
if @parallel && Process.respond_to?(:fork)
parallel_runner_klass.new(rspec_args).execute
else
::RSpec::Core::Runner.run(rspec_args)
Expand Down

0 comments on commit 220e6b6

Please sign in to comment.