Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'qa/qa/specs/runner.rb')
-rw-r--r--qa/qa/specs/runner.rb98
1 files changed, 44 insertions, 54 deletions
diff --git a/qa/qa/specs/runner.rb b/qa/qa/specs/runner.rb
index c30e5d822c4..68b624b3f2e 100644
--- a/qa/qa/specs/runner.rb
+++ b/qa/qa/specs/runner.rb
@@ -19,18 +19,6 @@ module QA
@options = []
end
- def paths_from_knapsack
- allocator = Knapsack::AllocatorBuilder.new(Knapsack::Adapters::RSpecAdapter).allocator
-
- QA::Runtime::Logger.info '==== Knapsack specs to execute ====='
- QA::Runtime::Logger.info 'Report specs:'
- QA::Runtime::Logger.info allocator.report_node_tests.join(', ')
- QA::Runtime::Logger.info 'Leftover specs:'
- QA::Runtime::Logger.info allocator.leftover_node_tests.join(', ')
-
- ['--', allocator.node_tests]
- end
-
def rspec_tags
tags_for_rspec = []
@@ -52,77 +40,79 @@ module QA
tags_for_rspec
end
- # rubocop:disable Metrics/AbcSize
- # rubocop:disable Metrics/CyclomaticComplexity
def perform
args = []
args.push('--tty') if tty
args.push(rspec_tags)
args.push(options)
- if Runtime::Env.knapsack?
- args.push(paths_from_knapsack)
- else
- args.push(DEFAULT_TEST_PATH_ARGS) unless options.any? { |opt| opt =~ %r{/features/} }
+ unless Runtime::Env.knapsack? || options.any? { |opt| opt.include?('features') }
+ args.push(DEFAULT_TEST_PATH_ARGS)
end
- Runtime::Scenario.define(:large_setup?, args.flatten.include?('can_use_large_setup'))
-
- if Runtime::Scenario.attributes[:parallel]
+ if Runtime::Env.knapsack?
+ KnapsackRunner.run(args.flatten) { |status| abort if status.nonzero? }
+ elsif Runtime::Scenario.attributes[:parallel]
ParallelRunner.run(args.flatten)
elsif Runtime::Scenario.attributes[:loop]
LoopRunner.run(args.flatten)
elsif Runtime::Scenario.attributes[:count_examples_only]
- args.unshift('--dry-run')
- out = StringIO.new
+ count_examples_only(args)
+ elsif Runtime::Scenario.attributes[:test_metadata_only]
+ test_metadata_only(args)
+ else
+ RSpec::Core::Runner.run(args.flatten, *DEFAULT_STD_ARGS).tap { |status| abort if status.nonzero? }
+ end
+ end
- RSpec::Core::Runner.run(args.flatten, $stderr, out).tap do |status|
- abort if status.nonzero?
- end
+ private
- begin
- total_examples = out.string.match(/(\d+) examples?,/)[1]
- rescue StandardError
- raise RegexMismatchError, 'Rspec output did not match regex'
- end
+ def count_examples_only(args)
+ args.unshift('--dry-run')
+ out = StringIO.new
- filename = build_filename
+ RSpec::Core::Runner.run(args.flatten, $stderr, out).tap do |status|
+ abort if status.nonzero?
+ end
- File.open(filename, 'w') { |f| f.write(total_examples) } if total_examples.to_i > 0
+ begin
+ total_examples = out.string.match(/(\d+) examples?,/)[1]
+ rescue StandardError
+ raise RegexMismatchError, 'Rspec output did not match regex'
+ end
- $stdout.puts "Total examples in #{Runtime::Scenario.klass}: #{total_examples}#{total_examples.to_i > 0 ? ". Saved to file: #{filename}" : ''}"
- elsif Runtime::Scenario.attributes[:test_metadata_only]
- args.unshift('--dry-run')
+ filename = build_filename
- output_file = Pathname.new(File.join(Runtime::Path.qa_root, 'tmp', 'test-metadata.json'))
+ File.open(filename, 'w') { |f| f.write(total_examples) } if total_examples.to_i > 0
- RSpec.configure do |config|
- config.add_formatter(QA::Support::JsonFormatter, output_file)
- config.fail_if_no_examples = true
- end
+ saved_file_msg = total_examples.to_i > 0 ? ". Saved to file: #{filename}" : ''
+ $stdout.puts "Total examples in #{Runtime::Scenario.klass}: #{total_examples}#{saved_file_msg}"
+ end
- RSpec::Core::Runner.run(args.flatten, $stderr, $stdout) do |status|
- abort if status.nonzero?
- end
+ def test_metadata_only(args)
+ args.unshift('--dry-run')
- $stdout.puts "Saved to file: #{output_file}"
- else
- RSpec::Core::Runner.run(args.flatten, *DEFAULT_STD_ARGS).tap do |status|
- abort if status.nonzero?
- end
+ output_file = Pathname.new(File.join(Runtime::Path.qa_root, 'tmp', 'test-metadata.json'))
+
+ RSpec.configure do |config|
+ config.add_formatter(QA::Support::JsonFormatter, output_file)
+ config.fail_if_no_examples = true
end
- end
- # rubocop:enable Metrics/AbcSize
- # rubocop:enable Metrics/CyclomaticComplexity
- private
+ RSpec::Core::Runner.run(args.flatten, $stderr, $stdout) do |status|
+ abort if status.nonzero?
+ end
+
+ $stdout.puts "Saved to file: #{output_file}"
+ end
def build_filename
filename = Runtime::Scenario.klass.split('::').last(3).join('_').downcase
tags = []
+ tag_opts = %w[--tag -t]
options.reduce do |before, after|
- tags << after if %w[--tag -t].include?(before)
+ tags << after if tag_opts.include?(before)
after
end
tags = tags.compact.join('_')