diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/quality/test_level.rb | 75 | ||||
-rw-r--r-- | lib/tasks/spec.rake | 44 |
2 files changed, 14 insertions, 105 deletions
diff --git a/lib/quality/test_level.rb b/lib/quality/test_level.rb deleted file mode 100644 index 24d8eac200c..00000000000 --- a/lib/quality/test_level.rb +++ /dev/null @@ -1,75 +0,0 @@ -# frozen_string_literal: true - -module Quality - class TestLevel - UnknownTestLevelError = Class.new(StandardError) - - TEST_LEVEL_FOLDERS = { - unit: %w[ - bin - config - db - dependencies - factories - finders - frontend - graphql - helpers - initializers - javascripts - lib - migrations - models - policies - presenters - rack_servers - routing - rubocop - serializers - services - sidekiq - tasks - uploaders - validators - views - workers - elastic_integration - ], - integration: %w[ - controllers - mailers - requests - ], - system: ['features'] - }.freeze - - attr_reader :prefix - - def initialize(prefix = nil) - @prefix = prefix - @patterns = {} - @regexps = {} - end - - def pattern(level) - @patterns[level] ||= "#{prefix}spec/{#{TEST_LEVEL_FOLDERS.fetch(level).join(',')}}{,/**/}*_spec.rb".freeze - end - - def regexp(level) - @regexps[level] ||= Regexp.new("#{prefix}spec/(#{TEST_LEVEL_FOLDERS.fetch(level).join('|')})").freeze - end - - def level_for(file_path) - case file_path - when regexp(:unit) - :unit - when regexp(:integration) - :integration - when regexp(:system) - :system - else - raise UnknownTestLevelError, "Test level for #{file_path} couldn't be set. Please rename the file properly or change the test level detection regexes in #{__FILE__}." - end - end - end -end diff --git a/lib/tasks/spec.rake b/lib/tasks/spec.rake index c881ad4cf12..2eddcb3c777 100644 --- a/lib/tasks/spec.rake +++ b/lib/tasks/spec.rake @@ -1,32 +1,7 @@ -# frozen_string_literal: true - -return if Rails.env.production? - Rake::Task["spec"].clear if Rake::Task.task_defined?('spec') namespace :spec do - desc 'GitLab | RSpec | Run unit tests' - RSpec::Core::RakeTask.new(:unit, :rspec_opts) do |t, args| - require_dependency 'quality/test_level' - t.pattern = Quality::TestLevel.new.pattern(:unit) - t.rspec_opts = args[:rspec_opts] - end - - desc 'GitLab | RSpec | Run integration tests' - RSpec::Core::RakeTask.new(:integration, :rspec_opts) do |t, args| - require_dependency 'quality/test_level' - t.pattern = Quality::TestLevel.new.pattern(:integration) - t.rspec_opts = args[:rspec_opts] - end - - desc 'GitLab | RSpec | Run system tests' - RSpec::Core::RakeTask.new(:system, :rspec_opts) do |t, args| - require_dependency 'quality/test_level' - t.pattern = Quality::TestLevel.new.pattern(:system) - t.rspec_opts = args[:rspec_opts] - end - - desc '[Deprecated] Use the "bin/rspec --tag api" instead' + desc 'GitLab | Rspec | Run request specs' task :api do cmds = [ %w(rake gitlab:setup), @@ -35,7 +10,7 @@ namespace :spec do run_commands(cmds) end - desc '[Deprecated] Use the "spec:system" task instead' + desc 'GitLab | Rspec | Run feature specs' task :feature do cmds = [ %w(rake gitlab:setup), @@ -44,7 +19,7 @@ namespace :spec do run_commands(cmds) end - desc '[Deprecated] Use "bin/rspec spec/models" instead' + desc 'GitLab | Rspec | Run model specs' task :models do cmds = [ %w(rake gitlab:setup), @@ -53,7 +28,7 @@ namespace :spec do run_commands(cmds) end - desc '[Deprecated] Use "bin/rspec spec/services" instead' + desc 'GitLab | Rspec | Run service specs' task :services do cmds = [ %w(rake gitlab:setup), @@ -62,7 +37,7 @@ namespace :spec do run_commands(cmds) end - desc '[Deprecated] Use "bin/rspec spec/lib" instead' + desc 'GitLab | Rspec | Run lib specs' task :lib do cmds = [ %w(rake gitlab:setup), @@ -70,6 +45,15 @@ namespace :spec do ] run_commands(cmds) end + + desc 'GitLab | Rspec | Run other specs' + task :other do + cmds = [ + %w(rake gitlab:setup), + %w(rspec spec --tag ~@api --tag ~@feature --tag ~@models --tag ~@lib --tag ~@services) + ] + run_commands(cmds) + end end desc "GitLab | Run specs" |