Commit 0d1b2180 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'use-exec-in-parallel_spec' into 'master'

ci: Use `exec` instead of `spawn` in `parallel_rspec_runner.rb`

See merge request gitlab-org/gitlab!79213
parents 6c8c74f8 0ba99267
......@@ -127,6 +127,7 @@
.ci-patterns: &ci-patterns
- ".gitlab-ci.yml"
- ".gitlab/ci/**/*"
- "scripts/rspec_helpers.sh"
.ci-build-images-patterns: &ci-build-images-patterns
- ".gitlab-ci.yml"
......@@ -245,6 +246,7 @@
- ".gitlab-ci.yml"
- ".gitlab/ci/**/*"
- "*_VERSION"
- "scripts/rspec_helpers.sh"
# DB patterns + .ci-patterns
.db-patterns: &db-patterns
......
......@@ -296,7 +296,7 @@ function retry_failed_rspec_examples() {
echo "${CI_JOB_URL}" > "${RETRIED_TESTS_REPORT_PATH}"
echo $failed_examples >> "${RETRIED_TESTS_REPORT_PATH}"
echoinfo "Retrying the failing examples in a new RSpec proces..."
echoinfo "Retrying the failing examples in a new RSpec process..."
install_junit_merge_gem
......
......@@ -18,9 +18,7 @@ RSpec.describe Tooling::ParallelRSpecRunner do # rubocop:disable RSpec/FilePath
allow(File).to receive(:exist?).with(filter_tests_file).and_return(true)
allow(File).to receive(:read).and_call_original
allow(File).to receive(:read).with(filter_tests_file).and_return(filter_tests)
allow(Process).to receive(:spawn)
allow(Process).to receive(:wait)
allow(Process).to receive(:last_status).and_return(double(exitstatus: 0))
allow(subject).to receive(:exec)
end
subject { described_class.new(allocator: allocator, filter_tests_file: filter_tests_file, rspec_args: rspec_args) }
......@@ -88,7 +86,7 @@ RSpec.describe Tooling::ParallelRSpecRunner do # rubocop:disable RSpec/FilePath
end
def expect_command(cmd)
expect(Process).to receive(:spawn).with(*cmd)
expect(subject).to receive(:exec).with(*cmd)
end
end
end
......@@ -16,4 +16,4 @@ OptionParser.new do |opts|
end
end.parse!
exit Tooling::ParallelRSpecRunner.run(**options)
Tooling::ParallelRSpecRunner.run(**options)
......@@ -38,14 +38,12 @@ module Tooling
Knapsack.logger.info tests_to_run
Knapsack.logger.info
# Without this guard clause, we're run all the specs instead of none!
if tests_to_run.empty?
Knapsack.logger.info 'No tests to run on this node, exiting.'
return 0
return
end
Process.wait Process.spawn(*rspec_command)
Process.last_status.exitstatus
exec(*rspec_command)
end
private
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment