Top Level Namespace

Includes:
Sauce::Utilities

Defined Under Namespace

Modules: Capybara, ChildProcess, Kernel, ParallelTests, Sauce, Selenium Classes: ConfigureCommand, ConnectCommand

Instance Method Summary collapse

Methods included from Sauce::Utilities

incorrectly_integrated_warning, page_deprecation_message, #silence_stream, #wait_for_server_on_port, warn_if_suspect_misconfiguration

Instance Method Details

#parse_task_args(test_tool = :rspec, args) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/tasks/parallel_testing.rb', line 104

def parse_task_args(test_tool=:rspec, args)
  default = {
    :concurrency => [Sauce::TestBroker.concurrency, 20].min
  }

  if test_tool == :rspec
    default[:test_options] = '-t sauce'
    default[:files] = 'spec'
  end

  if test_tool == :cucumber
    default[:files] = 'features'
  end

  env_args = {
    :concurrency => ENV['concurrency'],
    :features => ENV['features'],
    :parallel_options => ENV['parallel_test_options'],
    :test_options => ENV['test_options'],
    :files => ENV['test_files']
  }

  concurrency = args[:concurrency] || env_args[:concurrency] || default[:concurrency]
  test_options = args[:test_options] || env_args[:test_options] || default[:test_options]
  parallel_options = args[:parallel_options] || env_args[:parallel_options]
  files = args[:files] || env_args[:files] || default[:files]

  return_args = [
    '-n', concurrency.to_s,
    '--type'
  ]

  return_args.push 'saucerspec' if test_tool == :rspec
  return_args.push 'saucecucumber' if test_tool == :cucumber

  if test_options
    return_args.push '-o'
    return_args.push test_options
  end

  return_args.push *(parallel_options.split(' ')) if parallel_options
  return_args.concat files.split

  return return_args
end

#run_parallel_tests(t, args, command) ⇒ Object



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/tasks/parallel_testing.rb', line 74

def run_parallel_tests(t, args, command)
  if ParallelTests.number_of_running_processes == 0
    username    = ENV["SAUCE_USERNAME"].to_s
    access_key  = ENV["SAUCE_ACCESS_KEY"].to_s
    if(!username.empty? && !access_key.empty?)
      parallel_arguments = parse_task_args(command, args)
      ParallelTests::CLI.new.run(parallel_arguments)
    else
      puts <<-ENDLINE
    -----------------------------------------------------------------------
    Your Sauce username and/or access key are unavailable. Please:
    1.  Set the SAUCE_USERNAME and SAUCE_ACCESS_KEY environment variables.
    2.  Rerun your tests.
    -----------------------------------------------------------------------
      ENDLINE
    end
  else
    puts <<-ENDLINE
  ---------------------------------------------------------------------------
  There are already parallel_tests processes running.  This can interfere
  with test startup and shutdown.

  If you're not running other parallel tests, this might be caused by zombie
  processes (The worst kind of processes).  Kill `em off and try again.
  ---------------------------------------------------------------------------
    ENDLINE
    exit(1)
  end
end

#start_tunnel_for_parallel_tests(c) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/sauce/parallel.rb', line 3

def start_tunnel_for_parallel_tests(c)
  c[:start_tunnel] = ParallelTests.first_process?
  if ParallelTests.first_process?
    at_exit do
      if ParallelTests.first_process?
        ParallelTests.wait_for_other_processes_to_finish
      end
    end
  else
    while not File.exist? "sauce_connect.ready"
      sleep 0.5
    end
  end
end