Permalink
Browse files

simplify output fetch option and kill chunk timeout

  • Loading branch information...
1 parent ff454a2 commit af62ab4e31d9fa09dc6481a79d7164af90d7763a @grosser committed Jul 21, 2012
Showing with 8 additions and 28 deletions.
  1. +0 −1 Readme.md
  2. +0 −1 lib/parallel_tests/cli.rb
  3. +7 −25 lib/parallel_tests/test/runner.rb
  4. +1 −1 spec/integration_spec.rb
View
@@ -132,7 +132,6 @@ Options are:
-o, --test-options '[OPTIONS]' execute test commands with those options
-t, --type [TYPE] test(default) / rspec / cucumber
--non-parallel execute same commands but do not in parallel, needs --exec
- --chunk-timeout [TIMEOUT] timeout before re-printing the output of a child-process
--no-symlinks Do not traverse symbolic links to find test files
-v, --version Show Version
-h, --help Show this.
@@ -97,7 +97,6 @@ def self.parse_options!(argv)
opts.on("-o", "--test-options '[OPTIONS]'", "execute test commands with those options") { |arg| options[:test_options] = arg }
opts.on("-t", "--type [TYPE]", "test(default) / rspec / cucumber") { |type| options[:type] = type }
opts.on("--non-parallel", "execute same commands but do not in parallel, needs --exec") { options[:non_parallel] = true }
- opts.on("--chunk-timeout [TIMEOUT]", "timeout before re-printing the output of a child-process") { |timeout| options[:chunk_timeout] = timeout.to_f }
opts.on("--no-symlinks", "Do not traverse symbolic links to find test files") { options[:symlinks] = false }
opts.on("-v", "--version", "Show Version") { puts ParallelTests::VERSION; exit }
opts.on("-h", "--help", "Show this.") { puts opts; exit }
@@ -42,7 +42,7 @@ def self.tests_in_groups(tests, num_groups, options={})
def self.execute_command(cmd, process_number, options)
cmd = "TEST_ENV_NUMBER=#{test_env_number(process_number)} ; export TEST_ENV_NUMBER; #{cmd}"
f = open("|#{cmd}", 'r')
- output = fetch_output(f, options)
+ output = fetch_output(f)
f.close
{:stdout => output, :exit_status => $?.exitstatus}
end
@@ -77,31 +77,13 @@ def self.sum_up_results(results)
end
# read output of the process and print in in chucks
- def self.fetch_output(process, options)
+ def self.fetch_output(process)
all = ''
- buffer = ''
- timeout = options[:chunk_timeout] || 0.2
- flushed = Time.now.to_f
-
- while char = process.getc
- char = (char.is_a?(Fixnum) ? char.chr : char) # 1.8 <-> 1.9
- all << char
-
- # print in chunks so large blocks stay together
- now = Time.now.to_f
- buffer << char
- if flushed + timeout < now
- $stdout.print buffer
- $stdout.flush
- buffer = ''
- flushed = now
- end
- end
-
- # print the remainder
- $stdout.print buffer
- $stdout.flush
-
+ while buffer = process.readpartial(1000000)
+ all << buffer
+ $stdout.print buffer
+ $stdout.flush
+ end rescue EOFError
all
end
@@ -39,7 +39,7 @@ def ensure_folder(folder)
def run_tests(test_folder, options={})
ensure_folder folder
processes = "-n #{options[:processes]||2}" unless options[:processes] == false
- command = "cd #{folder} && #{options[:export]} #{executable(options)} #{test_folder} --chunk-timeout 999 #{processes} #{options[:add]} 2>&1"
+ command = "cd #{folder} && #{options[:export]} #{executable(options)} #{test_folder} #{processes} #{options[:add]} 2>&1"
result = `#{command}`
raise "FAILED #{command}\n#{result}" if $?.success? == !!options[:fail]
result

0 comments on commit af62ab4

Please sign in to comment.