Class: ParallelCalabash::Runner
- Inherits:
-
Object
- Object
- ParallelCalabash::Runner
- Defined in:
- lib/parallel_calabash/runner.rb
Class Method Summary collapse
- .base_command ⇒ Object
- .command_for_process(process_number, cmd) ⇒ Object
- .execute_command_for_process(process_number, cmd, silence) ⇒ Object
- .run_tests(test_files, process_number, options) ⇒ Object
- .show_output(output, silence) ⇒ Object
Class Method Details
.base_command ⇒ Object
4 5 6 |
# File 'lib/parallel_calabash/runner.rb', line 4 def base_command 'calabash-android run' end |
.command_for_process(process_number, cmd) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/parallel_calabash/runner.rb', line 26 def command_for_process process_number, cmd env = {} device_for_current_process = ParallelCalabash::AdbHelper.device_for_process process_number env = env.merge({'AUTOTEST' => '1', 'ADB_DEVICE_ARG' => device_for_current_process, "TEST_PROCESS_NUMBER" => (process_number+1).to_s}) separator = (WINDOWS ? ' & ' : ';') exports = env.map { |k, v| WINDOWS ? "(SET \"#{k}=#{v}\")" : "#{k}=#{v};export #{k}" }.join(separator) exports + separator + cmd end |
.execute_command_for_process(process_number, cmd, silence) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/parallel_calabash/runner.rb', line 13 def execute_command_for_process(process_number, cmd, silence) command_for_current_process = command_for_process(process_number, cmd) output = open("|#{command_for_current_process}", "r") { |output| show_output(output, silence) } exitstatus = $?.exitstatus if silence $stdout.print output $stdout.flush end puts "\n****** PROCESS #{process_number} COMPLETED ******\n\n" {:stdout => output, :exit_status => exitstatus} end |
.run_tests(test_files, process_number, options) ⇒ Object
8 9 10 11 |
# File 'lib/parallel_calabash/runner.rb', line 8 def run_tests(test_files, process_number, ) cmd = [base_command, [:apk_path], [:cucumber_options], *test_files].compact*' ' execute_command_for_process(process_number, cmd, [:mute_output]) end |
.show_output(output, silence) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/parallel_calabash/runner.rb', line 35 def show_output(output, silence) result = "" loop do begin read = output.readpartial(1000000) # read whatever chunk we can get result << read unless silence $stdout.print read $stdout.flush end end end rescue EOFError result end |