parallel_tests 0.4.16 → 0.4.17

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.md CHANGED
@@ -76,7 +76,7 @@ Add to your `spec/parallel_spec.opts` (or `spec/spec.opts`) :
76
76
  RSpec 1.x:
77
77
  --format progress
78
78
  --format ParallelSpecs::SpecRuntimeLogger:tmp/parallel_profile.log
79
- RSpec 2.x:
79
+ RSpec >= 2.2:
80
80
  Installed as plugin: -I vendor/plugins/parallel_tests/lib
81
81
  --format progress
82
82
  --format ParallelSpecs::SpecRuntimeLogger --out tmp/parallel_profile.log
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.16
1
+ 0.4.17
data/bin/parallel_test CHANGED
@@ -24,7 +24,8 @@ BANNER
24
24
  opts.on("-e", '--exec [COMMAND]', "execute this code parallel and with ENV['TEST_ENV_NUM']"){|path| options[:execute] = path }
25
25
  opts.on("-o", "--test-options '[OPTIONS]'", "execute test commands with those options"){|arg| options[:test_options] = arg }
26
26
  opts.on("-t", "--type [TYPE]", "which type of tests to run? test, spec or features"){|type| options[:type] = type }
27
- opts.on("--non-parallel", "execute same commands but do not in parallel, needs --exec"){|type| options[:non_parallel] = true }
27
+ opts.on("--non-parallel", "execute same commands but do not in parallel, needs --exec"){ options[:non_parallel] = true }
28
+ opts.on("--chunk-timeout [TIMEOUT]", "timeout before re-printing the output of a child-process"){|timeout| options[:chunk_timeout] = timeout.to_f }
28
29
  opts.on('-v', '--version', 'Show Version'){ puts ParallelTests::VERSION; exit}
29
30
  opts.on("-h", "--help", "Show this.") { puts opts; exit }
30
31
  end.parse!
@@ -39,11 +40,11 @@ if options[:execute]
39
40
  runs = (0...num_processes).to_a
40
41
  results = if options[:non_parallel]
41
42
  runs.map do |i|
42
- ParallelTests.execute_command(options[:execute], i)
43
+ ParallelTests.execute_command(options[:execute], i, options)
43
44
  end
44
45
  else
45
46
  Parallel.map(runs, :in_processes => num_processes) do |i|
46
- ParallelTests.execute_command(options[:execute], i)
47
+ ParallelTests.execute_command(options[:execute], i, options)
47
48
  end
48
49
  end.flatten
49
50
  abort if results.any?{|r| r[:exit_status] != 0 }
@@ -72,7 +73,7 @@ else
72
73
  puts "#{num_processes} processes for #{num_tests} #{name}s, ~ #{num_tests / groups.size} #{name}s per process"
73
74
 
74
75
  test_results = Parallel.map(groups, :in_processes => num_processes) do |group|
75
- klass.run_tests(group, groups.index(group), options[:test_options])
76
+ klass.run_tests(group, groups.index(group), options)
76
77
  end
77
78
 
78
79
  #parse and print results
@@ -88,4 +89,4 @@ else
88
89
  #exit with correct status code so rake parallel:test && echo 123 works
89
90
  failed = test_results.any?{|result| result[:exit_status] != 0 }
90
91
  abort "#{name.capitalize}s Failed" if failed
91
- end
92
+ end
@@ -3,8 +3,8 @@ require File.join(File.dirname(__FILE__), 'parallel_tests')
3
3
  class ParallelCucumber < ParallelTests
4
4
  def self.run_tests(test_files, process_number, options)
5
5
  color = ($stdout.tty? ? 'AUTOTEST=1 ; export AUTOTEST ;' : '')#display color when we are in a terminal
6
- cmd = "#{color} #{executable} #{options} #{test_files*' '}"
7
- execute_command(cmd, process_number)
6
+ cmd = "#{color} #{executable} #{options[:test_options]} #{test_files*' '}"
7
+ execute_command(cmd, process_number, options)
8
8
  end
9
9
 
10
10
  def self.executable
@@ -4,8 +4,8 @@ class ParallelSpecs < ParallelTests
4
4
  def self.run_tests(test_files, process_number, options)
5
5
  exe = executable # expensive, so we cache
6
6
  version = (exe =~ /\brspec\b/ ? 2 : 1)
7
- cmd = "#{rspec_1_color if version == 1}#{exe} #{options} #{rspec_2_color if version == 2}#{spec_opts(version)} #{test_files*' '}"
8
- execute_command(cmd, process_number)
7
+ cmd = "#{rspec_1_color if version == 1}#{exe} #{options[:test_options]} #{rspec_2_color if version == 2}#{spec_opts(version)} #{test_files*' '}"
8
+ execute_command(cmd, process_number, options)
9
9
  end
10
10
 
11
11
  def self.executable
@@ -17,7 +17,6 @@ class ParallelSpecs::SpecRuntimeLogger < ParallelSpecs::SpecRuntimeLoggerBase
17
17
  FileUtils.mkdir_p(File.dirname(output))
18
18
  File.open(output, 'w'){} # overwrite previous results
19
19
  @output = File.open(output, 'a')
20
- puts 'string'
21
20
  elsif File === output
22
21
  output.close # close file opened with 'w'
23
22
  @output = File.open(output.path, 'a')
@@ -30,22 +30,16 @@ class ParallelTests
30
30
 
31
31
  def self.run_tests(test_files, process_number, options)
32
32
  require_list = test_files.map { |filename| "\"#{filename}\"" }.join(",")
33
- cmd = "ruby -Itest #{options} -e '[#{require_list}].each {|f| require f }'"
34
- execute_command(cmd, process_number)
33
+ cmd = "ruby -Itest #{options[:test_options]} -e '[#{require_list}].each {|f| require f }'"
34
+ execute_command(cmd, process_number, options)
35
35
  end
36
36
 
37
- def self.execute_command(cmd, process_number)
37
+ def self.execute_command(cmd, process_number, options)
38
38
  cmd = "TEST_ENV_NUMBER=#{test_env_number(process_number)} ; export TEST_ENV_NUMBER; #{cmd}"
39
39
  f = open("|#{cmd}", 'r')
40
- all = ''
41
- while char = f.getc
42
- char = (char.is_a?(Fixnum) ? char.chr : char) # 1.8 <-> 1.9
43
- all << char
44
- print char
45
- STDOUT.flush
46
- end
40
+ output = fetch_output(f, options)
47
41
  f.close
48
- {:stdout => all, :exit_status => $?.exitstatus}
42
+ {:stdout => output, :exit_status => $?.exitstatus}
49
43
  end
50
44
 
51
45
  def self.find_results(test_output)
@@ -62,6 +56,35 @@ class ParallelTests
62
56
 
63
57
  protected
64
58
 
59
+ # read output of the process and print in in chucks
60
+ def self.fetch_output(process, options)
61
+ all = ''
62
+ buffer = ''
63
+ timeout = options[:chunk_timeout] || 0.2
64
+ flushed = Time.now.to_f
65
+
66
+ while char = process.getc
67
+ char = (char.is_a?(Fixnum) ? char.chr : char) # 1.8 <-> 1.9
68
+ all << char
69
+
70
+ # print in chunks so large blocks stay together
71
+ now = Time.now.to_f
72
+ buffer << char
73
+ if flushed + timeout < now
74
+ print buffer
75
+ STDOUT.flush
76
+ buffer = ''
77
+ flushed = now
78
+ end
79
+ end
80
+
81
+ # print the remainder
82
+ print buffer
83
+ STDOUT.flush
84
+
85
+ all
86
+ end
87
+
65
88
  # copied from http://github.com/carlhuda/bundler Bundler::SharedHelpers#find_gemfile
66
89
  def self.bundler_enabled?
67
90
  return true if Object.const_defined?(:Bundler)
@@ -5,13 +5,13 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{parallel_tests}
8
- s.version = "0.4.16"
8
+ s.version = "0.4.17"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Grosser"]
12
- s.date = %q{2011-04-29}
12
+ s.date = %q{2011-05-12}
13
13
  s.email = %q{grosser.michael@gmail.com}
14
- s.executables = ["parallel_spec", "parallel_cucumber", "parallel_test"]
14
+ s.executables = ["parallel_cucumber", "parallel_spec", "parallel_test"]
15
15
  s.files = [
16
16
  ".gitignore",
17
17
  "Gemfile",
@@ -40,14 +40,14 @@ Gem::Specification.new do |s|
40
40
  s.homepage = %q{http://github.com/grosser/parallel_tests}
41
41
  s.rdoc_options = ["--charset=UTF-8"]
42
42
  s.require_paths = ["lib"]
43
- s.rubygems_version = %q{1.4.2}
43
+ s.rubygems_version = %q{1.6.2}
44
44
  s.summary = %q{Run tests / specs / features in parallel}
45
45
  s.test_files = [
46
- "spec/parallel_cucumber_spec.rb",
46
+ "spec/parallel_tests_spec.rb",
47
47
  "spec/integration_spec.rb",
48
48
  "spec/parallel_specs_spec.rb",
49
- "spec/parallel_tests_spec.rb",
50
- "spec/spec_helper.rb"
49
+ "spec/spec_helper.rb",
50
+ "spec/parallel_cucumber_spec.rb"
51
51
  ]
52
52
 
53
53
  if s.respond_to? :specification_version then
@@ -29,7 +29,7 @@ describe 'CLI' do
29
29
  end
30
30
 
31
31
  def run_specs(options={})
32
- `cd #{folder} && #{executable} -t spec -n #{options[:processes]||2} #{options[:add]} 2>&1`
32
+ `cd #{folder} && #{executable} --chunk-timeout 999 -t spec -n #{options[:processes]||2} #{options[:add]} 2>&1`
33
33
  end
34
34
 
35
35
  it "runs tests in parallel" do
@@ -111,4 +111,4 @@ describe 'CLI' do
111
111
  result = run_specs(:add => "--test-options ' --version'", :processes => 2)
112
112
  result.should =~ /\d+\.\d+\.\d+.*\d+\.\d+\.\d+/m # prints version twice
113
113
  end
114
- end
114
+ end
@@ -46,7 +46,7 @@ describe ParallelCucumber do
46
46
 
47
47
  it "uses options passed in" do
48
48
  ParallelCucumber.should_receive(:open).with{|x,y| x =~ %r{script/cucumber -p default}}.and_return mocked_process
49
- ParallelCucumber.run_tests(['xxx'],1,'-p default')
49
+ ParallelCucumber.run_tests(['xxx'],1,:test_options => '-p default')
50
50
  end
51
51
  end
52
52
 
@@ -69,4 +69,4 @@ EOF
69
69
  ParallelCucumber.find_results(output).should == ["7 scenarios (3 failed, 4 passed)", "33 steps (3 failed, 2 skipped, 28 passed)", "4 scenarios (4 passed)", "40 steps (40 passed)"]
70
70
  end
71
71
  end
72
- end
72
+ end
@@ -118,7 +118,7 @@ describe ParallelSpecs do
118
118
 
119
119
  it "uses options passed in" do
120
120
  ParallelSpecs.should_receive(:open).with{|x,y| x =~ %r{rspec -f n}}.and_return mocked_process
121
- ParallelSpecs.run_tests(['xxx'],1,'-f n')
121
+ ParallelSpecs.run_tests(['xxx'],1, :test_options => '-f n')
122
122
  end
123
123
 
124
124
  it "returns the output" do
@@ -38,7 +38,7 @@ describe ParallelTests do
38
38
 
39
39
  it "uses options" do
40
40
  ParallelTests.should_receive(:open).with{|x,y| x=~ %r{ruby -Itest -v}}.and_return mocked_process
41
- ParallelTests.run_tests(['xxx'],1,'-v')
41
+ ParallelTests.run_tests(['xxx'],1,:test_options => '-v')
42
42
  end
43
43
 
44
44
  it "returns the output" do
@@ -139,4 +139,4 @@ EOF
139
139
  it "has a version" do
140
140
  ParallelTests::VERSION.should =~ /^\d+\.\d+\.\d+$/
141
141
  end
142
- end
142
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel_tests
3
3
  version: !ruby/object:Gem::Version
4
- hash: 47
4
+ hash: 45
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 16
10
- version: 0.4.16
9
+ - 17
10
+ version: 0.4.17
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Grosser
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-29 00:00:00 +02:00
18
+ date: 2011-05-12 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -28,15 +28,15 @@ dependencies:
28
28
  segments:
29
29
  - 0
30
30
  version: "0"
31
- type: :runtime
32
31
  requirement: *id001
33
- name: parallel
34
32
  prerelease: false
33
+ type: :runtime
34
+ name: parallel
35
35
  description:
36
36
  email: grosser.michael@gmail.com
37
37
  executables:
38
- - parallel_spec
39
38
  - parallel_cucumber
39
+ - parallel_spec
40
40
  - parallel_test
41
41
  extensions: []
42
42
 
@@ -96,13 +96,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  requirements: []
97
97
 
98
98
  rubyforge_project:
99
- rubygems_version: 1.4.2
99
+ rubygems_version: 1.6.2
100
100
  signing_key:
101
101
  specification_version: 3
102
102
  summary: Run tests / specs / features in parallel
103
103
  test_files:
104
- - spec/parallel_cucumber_spec.rb
104
+ - spec/parallel_tests_spec.rb
105
105
  - spec/integration_spec.rb
106
106
  - spec/parallel_specs_spec.rb
107
- - spec/parallel_tests_spec.rb
108
107
  - spec/spec_helper.rb
108
+ - spec/parallel_cucumber_spec.rb