diff options
author | Mark Lapierre <mlapierre@gitlab.com> | 2019-06-03 10:37:43 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2019-06-03 10:37:43 +0000 |
commit | 3922c6da841871f010dcffb3fcbfffc48d49bdab (patch) | |
tree | ec90ac9c18bbd01056b42dc89bbe5a1de2be0958 /qa/spec | |
parent | 0488c26ec6d10b943999b7fb61ca7209ab2c275e (diff) | |
download | gitlab-ce-3922c6da841871f010dcffb3fcbfffc48d49bdab.tar.gz |
Generate knapsack report for review-qa-all
Add knapsack qa report and use it to run tests in parallel
Use the RSpec runner with knapsack
The way the Knapsack runner uses exec to start rspec seems
incompatible with the way we expect it to work. Plus, it requires
specifying KNAPSACK_TEST_DIR.
Instead, we use knapsacks AllocatorBuilder to select the spec
files to run, and then start rspec as normal, via
RSpec::Core::Runner.run
This also means we can incorporate tags.
Let the job run automatically
Include KNAPSACK_TEST_FILE_PATTERN in vars
Check all defined knapsack env vars before requiring knapsack
Diffstat (limited to 'qa/spec')
-rw-r--r-- | qa/spec/runtime/env_spec.rb | 24 | ||||
-rw-r--r-- | qa/spec/spec_helper.rb | 5 |
2 files changed, 29 insertions, 0 deletions
diff --git a/qa/spec/runtime/env_spec.rb b/qa/spec/runtime/env_spec.rb index 04085efe2ce..2560695ef2e 100644 --- a/qa/spec/runtime/env_spec.rb +++ b/qa/spec/runtime/env_spec.rb @@ -168,6 +168,30 @@ describe QA::Runtime::Env do end end + describe '.knapsack?' do + it 'returns true if KNAPSACK_GENERATE_REPORT is defined' do + stub_env('KNAPSACK_GENERATE_REPORT', 'true') + + expect(described_class.knapsack?).to be_truthy + end + + it 'returns true if KNAPSACK_REPORT_PATH is defined' do + stub_env('KNAPSACK_REPORT_PATH', '/a/path') + + expect(described_class.knapsack?).to be_truthy + end + + it 'returns true if KNAPSACK_TEST_FILE_PATTERN is defined' do + stub_env('KNAPSACK_TEST_FILE_PATTERN', '/a/**/pattern') + + expect(described_class.knapsack?).to be_truthy + end + + it 'returns false if neither KNAPSACK_GENERATE_REPORT nor KNAPSACK_REPORT_PATH nor KNAPSACK_TEST_FILE_PATTERN are defined' do + expect(described_class.knapsack?).to be_falsey + end + end + describe '.require_github_access_token!' do it 'raises ArgumentError if GITHUB_ACCESS_TOKEN is not defined' do stub_env('GITHUB_ACCESS_TOKEN', nil) diff --git a/qa/spec/spec_helper.rb b/qa/spec/spec_helper.rb index a368ffba711..f25dbf3a8ab 100644 --- a/qa/spec/spec_helper.rb +++ b/qa/spec/spec_helper.rb @@ -3,6 +3,11 @@ require_relative '../qa' require 'rspec/retry' +if ENV['CI'] && QA::Runtime::Env.knapsack? && !ENV['NO_KNAPSACK'] + require 'knapsack' + Knapsack::Adapters::RSpecAdapter.bind +end + %w[helpers shared_examples].each do |d| Dir[::File.join(__dir__, d, '**', '*.rb')].each { |f| require f } end |