_tests/lib/run_test_options.rb
#
# Parses the command line supplied to the run-test.rb wrapper script.
#
Parses the command line supplied to the run-test.rb wrapper script.
Parses the command line supplied to the run - test . rb wrapper script .
def parse_command_line(args)
    test_configuration = {}
    option_parser = OptionParser.new do |opts|
      opts.banner = 'Usage: run-tests.rb [options]'
      opts.separator 'Specific options:'
      opts.on('--unit', 'Execute frontend unit-tests') do |opt|
        test_configuration[:unit] = opt
      end
      opts.on('--e2e', 'Execute frontend end-to-end tests') do |opt|
        test_configuration = create_default_test_configuration
        test_configuration[:e2e] = opt
      end
      opts.on('--blc', 'Execute broken link checks') do |opt|
        test_configuration[:blc] = opt
      end
       e2e and broken link testing commandline options
      opts.on('--base-url RHD_BASE_URL', String, 'Run the tests against the specified host e.g http://developers.stage.redhat.com') do |host|
        test_configuration[:base_url] = host
      end
      opts.on('--verbose', 'Verbose output for debugging') do |opt|
        bind_environment_variable('RHD_VERBOSE_OUTPUT', 'true')
        test_configuration[:verbose] = opt
      end
       e2e commandline options
      opts.on('--browser BROWSER', String, 'The driver to use when running the tests. [default=chrome]') do |browser|
        check_supported_browser(browser)
        test_configuration[:browser] = browser
      end
      opts.on('--use-browserstack', 'Run the specified test type using Docker') do
        test_configuration[:browserstack] = true
      end
      opts.on('--browser-count BROWSER_COUNT', String, 'The number of browsers to launch when running the tests with Docker [default=2]') do |browser_count|
        test_configuration[:browser_count] = browser_count.to_i
      end
      opts.on('--reporters REPORT', String, 'Type of report you wish to generate. Will mostly be used for Jenkins config, i.e. junit report') do |report|
        test_configuration[:report] = report
      end
      opts.on('--cucumber-tags CUCUMBER_TAGS', String, 'The cucumber tags to use') do |cucumber_tags|
        test_configuration[:cucumber_tags] = cucumber_tags
      end
      opts.on('--kc', 'Run the KeyCloak e2e tests') do
        test_configuration[:keycloak] = true
      end
       Broken link checking commandline options
      opts.on('-c CONFIG_FILE', 'specify the config.yaml file for broken link checks') do |opt|
        test_configuration[:config] = opt
      end
      opts.on('-s SINGLE_URL', 'test a single URL, outputting the response to the console') do |opt|
        test_configuration[:single_url] = opt
        test_configuration[:base_url] = opt
      end
      opts.on('--ignore-internal', "Ignore internal URL's") do |opt|
        test_configuration[:ignore_internal] = opt
      end
      opts.on('--ignore-external', "Ignore external URL's") do |opt|
        test_configuration[:ignore_external] = opt
      end
      opts.on('--ignore-ssl', 'Disable SSL certificate checking for staging environments') do |opt|
        test_configuration[:ignore_ssl] = opt
      end
       Options supporting the execution of the tests within Docker
      opts.on('--use-docker', 'Run the specified test type using Docker') do
        test_configuration[:docker] = true
      end
      opts.on('--update-github-status SHA1', String, 'The SHA to report test results for on GitHub') do |sha1|
        test_configuration[:github_sha1] = sha1
      end
      opts.on('--profile PROFILE', String, 'Used to determine the git status context for e2e tests') do |profile|
        test_configuration[:profile] = profile
      end
      opts.on_tail('-h', '--help', 'Show this message') do
        puts opts
        Kernel.exit(1)
      end
    end
    begin
      option_parser.parse!(args)
    rescue OptionParser::InvalidOption => e
      puts e
      option_parser.parse(%w(-h))
    end
    bind_test_type_environment_variable(test_configuration)
    bind_github_status_environment_variables(test_configuration[:github_sha1], ENV['rhd_test'].to_s, test_configuration[:profile])
    bind_browser_environment_variables(test_configuration[:docker], test_configuration[:browser], test_configuration) if test_configuration[:e2e]
    build_test_execution_command(test_configuration)
    test_configuration
  end
def parse_command_line ( args ) test_configuration = { } option_parser = OptionParser . new do | opts | opts . banner = 'Usage: run-tests.rb [options]' opts . separator 'Specific options:' opts . on ( '--unit' , 'Execute frontend unit-tests' ) do | opt | test_configuration [ :unit ] = opt end opts . on ( '--e2e' , 'Execute frontend end-to-end tests' ) do | opt | test_configuration = create_default_test_configuration test_configuration [ :e2e ] = opt end opts . on ( '--blc' , 'Execute broken link checks' ) do | opt | test_configuration [ :blc ] = opt end opts . on ( '--base-url RHD_BASE_URL' , String , 'Run the tests against the specified host e.g http://developers.stage.redhat.com' ) do | host | test_configuration [ :base_url ] = host end opts . on ( '--verbose' , 'Verbose output for debugging' ) do | opt | bind_environment_variable ( 'RHD_VERBOSE_OUTPUT' , 'true' ) test_configuration [ :verbose ] = opt end opts . on ( '--browser BROWSER' , String , 'The driver to use when running the tests. [default=chrome]' ) do | browser | check_supported_browser ( browser ) test_configuration [ :browser ] = browser end opts . on ( '--use-browserstack' , 'Run the specified test type using Docker' ) do test_configuration [ :browserstack ] = true end opts . on ( '--browser-count BROWSER_COUNT' , String , 'The number of browsers to launch when running the tests with Docker [default=2]' ) do | browser_count | test_configuration [ :browser_count ] = browser_count . to_i end opts . on ( '--reporters REPORT' , String , 'Type of report you wish to generate. Will mostly be used for Jenkins config, i.e. junit report' ) do | report | test_configuration [ :report ] = report end opts . on ( '--cucumber-tags CUCUMBER_TAGS' , String , 'The cucumber tags to use' ) do | cucumber_tags | test_configuration [ :cucumber_tags ] = cucumber_tags end opts . on ( '--kc' , 'Run the KeyCloak e2e tests' ) do test_configuration [ :keycloak ] = true end opts . on ( '-c CONFIG_FILE' , 'specify the config.yaml file for broken link checks' ) do | opt | test_configuration [ :config ] = opt end opts . on ( '-s SINGLE_URL' , 'test a single URL, outputting the response to the console' ) do | opt | test_configuration [ :single_url ] = opt test_configuration [ :base_url ] = opt end opts . on ( '--ignore-internal' , "Ignore internal URL's" ) do | opt | test_configuration [ :ignore_internal ] = opt end opts . on ( '--ignore-external' , "Ignore external URL's" ) do | opt | test_configuration [ :ignore_external ] = opt end opts . on ( '--ignore-ssl' , 'Disable SSL certificate checking for staging environments' ) do | opt | test_configuration [ :ignore_ssl ] = opt end opts . on ( '--use-docker' , 'Run the specified test type using Docker' ) do test_configuration [ :docker ] = true end opts . on ( '--update-github-status SHA1' , String , 'The SHA to report test results for on GitHub' ) do | sha1 | test_configuration [ :github_sha1 ] = sha1 end opts . on ( '--profile PROFILE' , String , 'Used to determine the git status context for e2e tests' ) do | profile | test_configuration [ :profile ] = profile end opts . on_tail ( '-h' , '--help' , 'Show this message' ) do puts opts Kernel . exit ( 1 ) end end begin option_parser . parse! ( args ) rescue OptionParser :: InvalidOption => e puts e option_parser . parse ( %w( -h ) ) end bind_test_type_environment_variable ( test_configuration ) bind_github_status_environment_variables ( test_configuration [ :github_sha1 ] , ENV [ 'rhd_test' ] . to_s , test_configuration [ :profile ] ) bind_browser_environment_variables ( test_configuration [ :docker ] , test_configuration [ :browser ] , test_configuration ) if test_configuration [ :e2e ] build_test_execution_command ( test_configuration ) test_configuration end
Parses the command line supplied to the run-test.rb wrapper script.
Parses the command line supplied to the run - test . rb wrapper script .
# # e2e and broken link testing commandline options # # # e2e commandline options # # # Broken link checking commandline options # # # Options supporting the execution of the tests within Docker #
args