Commit 8ef5a6d0 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'move-quality-into-tooling' into 'master'

Move quality/test_level into tooling [RUN ALL RSPEC]

See merge request gitlab-org/gitlab!53696
parents 8a14d179 e05f9112
...@@ -5,21 +5,21 @@ return if Rails.env.production? ...@@ -5,21 +5,21 @@ return if Rails.env.production?
namespace :spec do namespace :spec do
desc 'GitLab | RSpec | Run unit tests' desc 'GitLab | RSpec | Run unit tests'
RSpec::Core::RakeTask.new(:unit, :rspec_opts) do |t, args| RSpec::Core::RakeTask.new(:unit, :rspec_opts) do |t, args|
require_dependency 'quality/test_level' require_test_level
t.pattern = Quality::TestLevel.new.pattern(:unit) t.pattern = Quality::TestLevel.new.pattern(:unit)
t.rspec_opts = args[:rspec_opts] t.rspec_opts = args[:rspec_opts]
end end
desc 'GitLab | RSpec | Run integration tests' desc 'GitLab | RSpec | Run integration tests'
RSpec::Core::RakeTask.new(:integration, :rspec_opts) do |t, args| RSpec::Core::RakeTask.new(:integration, :rspec_opts) do |t, args|
require_dependency 'quality/test_level' require_test_level
t.pattern = Quality::TestLevel.new.pattern(:integration) t.pattern = Quality::TestLevel.new.pattern(:integration)
t.rspec_opts = args[:rspec_opts] t.rspec_opts = args[:rspec_opts]
end end
desc 'GitLab | RSpec | Run system tests' desc 'GitLab | RSpec | Run system tests'
RSpec::Core::RakeTask.new(:system, :rspec_opts) do |t, args| RSpec::Core::RakeTask.new(:system, :rspec_opts) do |t, args|
require_dependency 'quality/test_level' require_test_level
t.pattern = Quality::TestLevel.new.pattern(:system) t.pattern = Quality::TestLevel.new.pattern(:system)
t.rspec_opts = args[:rspec_opts] t.rspec_opts = args[:rspec_opts]
end end
...@@ -28,4 +28,8 @@ namespace :spec do ...@@ -28,4 +28,8 @@ namespace :spec do
RSpec::Core::RakeTask.new(:api) do |t| RSpec::Core::RakeTask.new(:api) do |t|
t.pattern = 'spec/requests/api/**/*_spec.rb' t.pattern = 'spec/requests/api/**/*_spec.rb'
end end
def require_test_level
require_relative '../../tooling/quality/test_level'
end
end end
...@@ -109,7 +109,7 @@ function rspec_paralellized_job() { ...@@ -109,7 +109,7 @@ function rspec_paralellized_job() {
cp "${KNAPSACK_RSPEC_SUITE_REPORT_PATH}" "${KNAPSACK_REPORT_PATH}" cp "${KNAPSACK_RSPEC_SUITE_REPORT_PATH}" "${KNAPSACK_REPORT_PATH}"
if [[ -z "${KNAPSACK_TEST_FILE_PATTERN}" ]]; then if [[ -z "${KNAPSACK_TEST_FILE_PATTERN}" ]]; then
pattern=$(ruby -r./lib/quality/test_level.rb -e "puts Quality::TestLevel.new(%(${spec_folder_prefix})).pattern(:${test_level})") pattern=$(ruby -r./tooling/quality/test_level.rb -e "puts Quality::TestLevel.new(%(${spec_folder_prefix})).pattern(:${test_level})")
export KNAPSACK_TEST_FILE_PATTERN="${pattern}" export KNAPSACK_TEST_FILE_PATTERN="${pattern}"
fi fi
......
...@@ -25,7 +25,7 @@ ENV["RAILS_ENV"] = 'test' ...@@ -25,7 +25,7 @@ ENV["RAILS_ENV"] = 'test'
ENV["IN_MEMORY_APPLICATION_SETTINGS"] = 'true' ENV["IN_MEMORY_APPLICATION_SETTINGS"] = 'true'
ENV["RSPEC_ALLOW_INVALID_URLS"] = 'true' ENV["RSPEC_ALLOW_INVALID_URLS"] = 'true'
require File.expand_path('../config/environment', __dir__) require_relative '../config/environment'
require 'rspec/mocks' require 'rspec/mocks'
require 'rspec/rails' require 'rspec/rails'
...@@ -72,6 +72,8 @@ Dir[Rails.root.join("spec/support/shared_contexts/*.rb")].sort.each { |f| requir ...@@ -72,6 +72,8 @@ Dir[Rails.root.join("spec/support/shared_contexts/*.rb")].sort.each { |f| requir
Dir[Rails.root.join("spec/support/shared_examples/*.rb")].sort.each { |f| require f } Dir[Rails.root.join("spec/support/shared_examples/*.rb")].sort.each { |f| require f }
Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |f| require f } Dir[Rails.root.join("spec/support/**/*.rb")].sort.each { |f| require f }
require_relative '../tooling/quality/test_level'
quality_level = Quality::TestLevel.new quality_level = Quality::TestLevel.new
RSpec.configure do |config| RSpec.configure do |config|
......
# frozen_string_literal: true # frozen_string_literal: true
require 'fast_spec_helper' require_relative '../../../tooling/quality/test_level'
RSpec.describe Quality::TestLevel do RSpec.describe Quality::TestLevel do
describe '#pattern' do describe '#pattern' do
...@@ -197,7 +197,7 @@ RSpec.describe Quality::TestLevel do ...@@ -197,7 +197,7 @@ RSpec.describe Quality::TestLevel do
it 'raises an error for an unknown level' do it 'raises an error for an unknown level' do
expect { subject.level_for('spec/unknown/foo_spec.rb') } expect { subject.level_for('spec/unknown/foo_spec.rb') }
.to raise_error(described_class::UnknownTestLevelError, .to raise_error(described_class::UnknownTestLevelError,
%r{Test level for spec/unknown/foo_spec.rb couldn't be set. Please rename the file properly or change the test level detection regexes in .+/lib/quality/test_level.rb.}) %r{Test level for spec/unknown/foo_spec.rb couldn't be set. Please rename the file properly or change the test level detection regexes in .+/tooling/quality/test_level.rb.})
end end
end end
......
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