Commit 1a78c64a authored by Peter Leitzen's avatar Peter Leitzen

Merge branch '198362-fix-spring-test-detection' into 'master'

Fix test runtime ID not working with bin/spring

Closes #198362

See merge request gitlab-org/gitlab!23671
parents df766246 f9b35f55
...@@ -16,7 +16,7 @@ module Gitlab ...@@ -16,7 +16,7 @@ module Gitlab
matches << :console if console? matches << :console if console?
matches << :sidekiq if sidekiq? matches << :sidekiq if sidekiq?
matches << :rake if rake? matches << :rake if rake?
matches << :rspec if rspec? matches << :test_suite if test_suite?
if matches.one? if matches.one?
matches.first matches.first
...@@ -48,8 +48,8 @@ module Gitlab ...@@ -48,8 +48,8 @@ module Gitlab
!!(defined?(::Rake) && Rake.application.top_level_tasks.any?) !!(defined?(::Rake) && Rake.application.top_level_tasks.any?)
end end
def rspec? def test_suite?
Rails.env.test? && process_name == 'rspec' Rails.env.test?
end end
def console? def console?
...@@ -64,10 +64,6 @@ module Gitlab ...@@ -64,10 +64,6 @@ module Gitlab
puma? || sidekiq? puma? || sidekiq?
end end
def process_name
File.basename($0)
end
def max_threads def max_threads
if puma? if puma?
Puma.cli_config.options[:max_threads] Puma.cli_config.options[:max_threads]
......
...@@ -5,6 +5,7 @@ require 'spec_helper' ...@@ -5,6 +5,7 @@ require 'spec_helper'
describe Gitlab::Runtime do describe Gitlab::Runtime do
before do before do
allow(described_class).to receive(:process_name).and_return('ruby') allow(described_class).to receive(:process_name).and_return('ruby')
stub_rails_env('production')
end end
context "when unknown" do context "when unknown" do
...@@ -47,7 +48,7 @@ describe Gitlab::Runtime do ...@@ -47,7 +48,7 @@ describe Gitlab::Runtime do
expect(subject.sidekiq?).to be(false) expect(subject.sidekiq?).to be(false)
expect(subject.console?).to be(false) expect(subject.console?).to be(false)
expect(subject.rake?).to be(false) expect(subject.rake?).to be(false)
expect(subject.rspec?).to be(false) expect(subject.test_suite?).to be(false)
end end
it "reports its maximum concurrency" do it "reports its maximum concurrency" do
...@@ -74,7 +75,7 @@ describe Gitlab::Runtime do ...@@ -74,7 +75,7 @@ describe Gitlab::Runtime do
expect(subject.sidekiq?).to be(false) expect(subject.sidekiq?).to be(false)
expect(subject.console?).to be(false) expect(subject.console?).to be(false)
expect(subject.rake?).to be(false) expect(subject.rake?).to be(false)
expect(subject.rspec?).to be(false) expect(subject.test_suite?).to be(false)
end end
it "reports its maximum concurrency" do it "reports its maximum concurrency" do
...@@ -106,7 +107,7 @@ describe Gitlab::Runtime do ...@@ -106,7 +107,7 @@ describe Gitlab::Runtime do
expect(subject.puma?).to be(false) expect(subject.puma?).to be(false)
expect(subject.console?).to be(false) expect(subject.console?).to be(false)
expect(subject.rake?).to be(false) expect(subject.rake?).to be(false)
expect(subject.rspec?).to be(false) expect(subject.test_suite?).to be(false)
end end
it "reports its maximum concurrency" do it "reports its maximum concurrency" do
...@@ -131,7 +132,7 @@ describe Gitlab::Runtime do ...@@ -131,7 +132,7 @@ describe Gitlab::Runtime do
expect(subject.sidekiq?).to be(false) expect(subject.sidekiq?).to be(false)
expect(subject.puma?).to be(false) expect(subject.puma?).to be(false)
expect(subject.rake?).to be(false) expect(subject.rake?).to be(false)
expect(subject.rspec?).to be(false) expect(subject.test_suite?).to be(false)
end end
it "reports its maximum concurrency" do it "reports its maximum concurrency" do
...@@ -139,14 +140,14 @@ describe Gitlab::Runtime do ...@@ -139,14 +140,14 @@ describe Gitlab::Runtime do
end end
end end
context "rspec" do context "test suite" do
before do before do
allow(described_class).to receive(:process_name).and_return('rspec') stub_rails_env('test')
end end
it "identifies itself" do it "identifies itself" do
expect(subject.identify).to eq(:rspec) expect(subject.identify).to eq(:test_suite)
expect(subject.rspec?).to be(true) expect(subject.test_suite?).to be(true)
end end
it "does not identify as others" do it "does not identify as others" do
......
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