parallel_tests 0.4.13 → 0.4.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Readme.md CHANGED
@@ -67,11 +67,17 @@ Example output
67
67
 
68
68
  Took 29.925333 seconds
69
69
 
70
- Even process runtimes (for specs only atm)
70
+ Even process runtimes (for specs only)
71
71
  -----------------
72
+
73
+ Log test runtime to give each process the same test runtime.<br/>
72
74
  Add to your `spec/parallel_spec.opts` (or `spec/spec.opts`) :
73
- --format ParallelSpecs::SpecRuntimeLogger:tmp/parallel_profile.log
74
- It will log test runtime and partition the test-load accordingly.
75
+
76
+ RSpec 1.x:
77
+ --format ParallelSpecs::SpecRuntimeLogger:tmp/parallel_profile.log
78
+ RSpec 2.x:
79
+ Installed as plugin: -I vendor/plugins/parallel_tests/lib
80
+ --format ParallelSpecs::SpecRuntimeLogger --out tmp/parallel_profile.log
75
81
 
76
82
  Setup for non-rails
77
83
  ===================
@@ -150,6 +156,7 @@ inspired by [pivotal labs](http://pivotallabs.com/users/miked/blog/articles/849-
150
156
  - [Fred Wu](http://fredwu.me)
151
157
  - [xxx](https://github.com/xxx)
152
158
  - [Levent Ali](http://purebreeze.com/)
159
+ - [Michael Kintzer](https://github.com/rockrep)
153
160
 
154
161
  [Michael Grosser](http://grosser.it)<br/>
155
162
  michael@grosser.it<br/>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.13
1
+ 0.4.14
@@ -1,7 +1,18 @@
1
- require 'spec/runner/formatter/progress_bar_formatter'
1
+ require 'parallel_specs'
2
+
3
+ begin
4
+ require 'rspec/core/formatters/progress_formatter'
5
+ base = RSpec::Core::Formatters::ProgressFormatter
6
+ rescue LoadError
7
+ require 'spec/runner/formatter/progress_bar_formatter'
8
+ base = Spec::Runner::Formatter::BaseTextFormatter
9
+ end
10
+ ParallelSpecs::SpecRuntimeLoggerBase = base
11
+
12
+ class ParallelSpecs::SpecRuntimeLogger < ParallelSpecs::SpecRuntimeLoggerBase
13
+ def initialize(options, output=nil)
14
+ output ||= options # rspec 2 has output as first argument
2
15
 
3
- class ParallelSpecs::SpecRuntimeLogger < Spec::Runner::Formatter::BaseTextFormatter
4
- def initialize(options, output)
5
16
  if String === output
6
17
  FileUtils.mkdir_p(File.dirname(output))
7
18
  File.open(output,'w'){|f| f.write ''} # clean the file
@@ -10,6 +21,7 @@ class ParallelSpecs::SpecRuntimeLogger < Spec::Runner::Formatter::BaseTextFormat
10
21
  @output = output
11
22
  end
12
23
  @example_times = Hash.new(0)
24
+ @failed_examples = [] # only needed for rspec 2
13
25
  end
14
26
 
15
27
  def example_started(*args)
@@ -24,7 +36,9 @@ class ParallelSpecs::SpecRuntimeLogger < Spec::Runner::Formatter::BaseTextFormat
24
36
  def start_dump(*args)
25
37
  return unless ENV['TEST_ENV_NUMBER'] #only record when running in parallel
26
38
  # TODO: Figure out why sometimes time can be less than 0
27
- @output.puts @example_times.map { |file, time| "#{file}:#{time > 0 ? time : 0}" }
39
+ lock_output do
40
+ @output.puts @example_times.map { |file, time| "#{file}:#{time > 0 ? time : 0}" }
41
+ end
28
42
  @output.flush
29
43
  end
30
44
 
@@ -46,4 +60,18 @@ class ParallelSpecs::SpecRuntimeLogger < Spec::Runner::Formatter::BaseTextFormat
46
60
  def close
47
61
  @output.close if (IO === @output) & (@output != $stdout)
48
62
  end
49
- end
63
+
64
+ # do not let multiple processes get in each others way
65
+ def lock_output
66
+ if File === @output
67
+ begin
68
+ @output.flock File::LOCK_EX
69
+ yield
70
+ ensure
71
+ @output.flock File::LOCK_UN
72
+ end
73
+ else
74
+ yield
75
+ end
76
+ end
77
+ end
@@ -88,11 +88,11 @@ class ParallelTests
88
88
 
89
89
  def self.tests_with_runtime(root)
90
90
  tests = find_tests(root)
91
- runtime_file = File.join(root,'..','tmp','parallel_profile.log')
92
- lines = File.read(runtime_file).split("\n") rescue []
91
+ lines = File.read('tmp/parallel_profile.log').split("\n") rescue []
93
92
 
94
93
  # use recorded test runtime if we got enough data
95
94
  if lines.size * 1.5 > tests.size
95
+ puts "Using recorded test runtime"
96
96
  times = Hash.new(1)
97
97
  lines.each do |line|
98
98
  test, time = line.split(":")
@@ -111,4 +111,4 @@ class ParallelTests
111
111
  Dir["#{root}**/**/*#{self.test_suffix}"]
112
112
  end
113
113
  end
114
- end
114
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{parallel_tests}
8
- s.version = "0.4.13"
8
+ s.version = "0.4.14"
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-17}
12
+ s.date = %q{2011-04-27}
13
13
  s.email = %q{grosser.michael@gmail.com}
14
14
  s.executables = ["parallel_spec", "parallel_cucumber", "parallel_test"]
15
15
  s.files = [
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: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 13
10
- version: 0.4.13
9
+ - 14
10
+ version: 0.4.14
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-17 00:00:00 +02:00
18
+ date: 2011-04-27 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency