Class: Gitlab::QA::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/qa/runner.rb

Overview

rubocop:disable Metrics/AbcSize

Class Method Summary collapse

Class Method Details

.gitlab_qa_optionsObject

rubocop:enable Metrics/AbcSize



54
55
56
# File 'lib/gitlab/qa/runner.rb', line 54

def self.gitlab_qa_options
  @gitlab_qa_options ||= @options.top.list.map(&:long).flatten
end

.run(args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/gitlab/qa/runner.rb', line 7

def self.run(args)
  Runtime::Scenario.define(:teardown, true)
  Runtime::Scenario.define(:run_tests, true)

  @options = OptionParser.new do |opts|
    opts.banner = 'Usage: gitlab-qa [options] Scenario URL [[--] path] [rspec_options]'

    opts.on('--no-teardown', 'Skip teardown of containers after the scenario completes.') do
      Runtime::Scenario.define(:teardown, false)
    end

    opts.on('--no-tests', 'Orchestrates the docker containers but does not run the tests. Implies --no-teardown') do
      Runtime::Scenario.define(:run_tests, false)
      Runtime::Scenario.define(:teardown, false)
    end

    opts.on_tail('-v', '--version', 'Show the version') do
      require 'gitlab/qa/version'
      puts "#{$PROGRAM_NAME} : #{VERSION}"
      exit
    end

    opts.on_tail('-h', '--help', 'Show the usage') do
      puts opts
      exit
    end

    begin
      opts.parse(args)
    rescue OptionParser::InvalidOption
      # Ignore invalid options and options that are passed through to the tests
    end
  end

  args.reject! { |arg| gitlab_qa_options.include?(arg) }

  if args.size >= 1
    Scenario
      .const_get(args.shift)
      .perform(*args)
  else
    puts @options
    exit 1
  end
end