parallel_tests 0.6.15 → 0.6.16

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,6 +3,7 @@ source :rubygems
3
3
  gem 'parallel'
4
4
 
5
5
  group :dev do
6
+ gem 'test-unit', :platform => :ruby_19
6
7
  gem 'rspec', '>=2.4'
7
8
  gem 'rake'
8
9
  gem 'jeweler'
@@ -17,6 +17,7 @@ GEM
17
17
  rspec-expectations (2.6.0)
18
18
  diff-lcs (~> 1.1.2)
19
19
  rspec-mocks (2.6.0)
20
+ test-unit (2.4.4)
20
21
 
21
22
  PLATFORMS
22
23
  ruby
@@ -26,3 +27,4 @@ DEPENDENCIES
26
27
  parallel
27
28
  rake
28
29
  rspec (>= 2.4)
30
+ test-unit
data/Readme.md CHANGED
@@ -81,7 +81,7 @@ Example output
81
81
 
82
82
  Took 29.925333 seconds
83
83
 
84
- Spec Loggers
84
+ Loggers
85
85
  ===================
86
86
 
87
87
  Even process runtimes
@@ -89,7 +89,7 @@ Even process runtimes
89
89
 
90
90
  Log test runtime to give each process the same runtime.
91
91
 
92
- Add to your `spec/parallel_spec.opts` (or `spec/spec.opts`) :
92
+ Rspec: Add to your `spec/parallel_spec.opts` (or `spec/spec.opts`) :
93
93
 
94
94
  RSpec 1.x:
95
95
  --format progress
@@ -100,6 +100,10 @@ Add to your `spec/parallel_spec.opts` (or `spec/spec.opts`) :
100
100
  --format progress
101
101
  --format ParallelSpecs::SpecRuntimeLogger --out tmp/parallel_profile.log
102
102
 
103
+ Test::Unit: Add to your `test_helper.rb`:
104
+ require 'parallel_tests/runtime_logger'
105
+
106
+
103
107
  SpecSummaryLogger
104
108
  --------------------
105
109
 
@@ -189,7 +193,6 @@ TIPS
189
193
  - [Capybara setup](https://github.com/grosser/parallel_tests/wiki)
190
194
  - [Sphinx setup](https://github.com/grosser/parallel_tests/wiki)
191
195
  - [Capistrano setup](https://github.com/grosser/parallel_tests/wiki/Remotely-with-capistrano) let your tests run on a big box instead of your laptop
192
- - [Test::Unit runtime logger](https://gist.github.com/1333414) some basic plumbing done (needs some love and a pull-request)
193
196
  - [SQL schema format] use :ruby schema format to get faster parallel:prepare`
194
197
  - [ActiveRecord] if you do not have `db:abort_if_pending_migrations` add this to your Rakefile: `task('db:abort_if_pending_migrations'){}`
195
198
  - `export PARALLEL_TEST_PROCESSORS=X` in your environment and parallel_tests will use this number of processors by default
@@ -229,6 +232,7 @@ inspired by [pivotal labs](http://pivotallabs.com/users/miked/blog/articles/849-
229
232
  - [Geoffrey Hichborn](https://github.com/phene)
230
233
  - [Trae Robrock](https://github.com/trobrock)
231
234
  - [Lawrence Wang](https://github.com/levity)
235
+ - [Sean Walbran](https://github.com/seanwalbran)
232
236
 
233
237
  [Michael Grosser](http://grosser.it)<br/>
234
238
  michael@grosser.it<br/>
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.15
1
+ 0.6.16
@@ -0,0 +1,78 @@
1
+ class ParallelTests::RuntimeLogger
2
+ @@has_started = false
3
+
4
+ def self.log(test, start_time, end_time)
5
+ return if test.is_a? Test::Unit::TestSuite # don't log for suites-of-suites
6
+
7
+ if !@@has_started # make empty log file
8
+ File.open(ParallelTests.runtime_log, 'w') do end
9
+ @@has_started = true
10
+ end
11
+
12
+ File.open(ParallelTests.runtime_log, 'a') do |output|
13
+ begin
14
+ output.flock File::LOCK_EX
15
+ output.puts(self.message(test, start_time, end_time))
16
+ ensure
17
+ output.flock File::LOCK_UN
18
+ end
19
+ end
20
+ end
21
+
22
+ def self.message(test, start_time, end_time)
23
+ delta="%.2f" % (end_time.to_f-start_time.to_f)
24
+ filename=class_directory(test.class) + class_to_filename(test.class) + ".rb"
25
+ message="#{filename}:#{delta}"
26
+ end
27
+
28
+ # Note: this is a best guess at conventional test directory structure, and may need
29
+ # tweaking / post-processing to match correctly for any given project
30
+ def self.class_directory(suspect)
31
+ result = "test/"
32
+
33
+ if defined?(Rails)
34
+ result += case suspect.superclass.name
35
+ when "ActionDispatch::IntegrationTest"
36
+ "integration/"
37
+ when "ActionDispatch::PerformanceTest"
38
+ "performance/"
39
+ when "ActionController::TestCase"
40
+ "functional/"
41
+ when "ActionView::TestCase"
42
+ "unit/helpers/"
43
+ else
44
+ "unit/"
45
+ end
46
+ end
47
+ result
48
+ end
49
+
50
+ # based on https://github.com/grosser/single_test/blob/master/lib/single_test.rb#L117
51
+ def self.class_to_filename(suspect)
52
+ word = suspect.to_s.dup
53
+ return word unless word.match /^[A-Z]/ and not word.match %r{/[a-z]}
54
+
55
+ word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
56
+ word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
57
+ word.gsub!(/\:\:/,'/')
58
+ word.tr!("-", "_")
59
+ word.downcase!
60
+ word
61
+ end
62
+
63
+ end
64
+
65
+ require 'test/unit/testsuite'
66
+ class Test::Unit::TestSuite
67
+
68
+ alias :run_without_timing :run unless defined? @@timing_installed
69
+
70
+ def run(result, &progress_block)
71
+ start_time=Time.now
72
+ run_without_timing(result, &progress_block)
73
+ end_time=Time.now
74
+ ParallelTests::RuntimeLogger.log(self.tests.first, start_time, end_time)
75
+ end
76
+ @@timing_installed = true
77
+
78
+ end
@@ -5,13 +5,13 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "parallel_tests"
8
- s.version = "0.6.15"
8
+ s.version = "0.6.16"
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 = "2012-01-12"
12
+ s.date = "2012-01-13"
13
13
  s.email = "grosser.michael@gmail.com"
14
- s.executables = ["parallel_cucumber", "parallel_spec", "parallel_test"]
14
+ s.executables = ["parallel_cucumber", "parallel_test", "parallel_spec"]
15
15
  s.files = [
16
16
  "Gemfile",
17
17
  "Gemfile.lock",
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
31
31
  "lib/parallel_tests.rb",
32
32
  "lib/parallel_tests/grouper.rb",
33
33
  "lib/parallel_tests/railtie.rb",
34
+ "lib/parallel_tests/runtime_logger.rb",
34
35
  "lib/parallel_tests/tasks.rb",
35
36
  "lib/tasks/parallel_tests.rake",
36
37
  "parallel_tests.gemspec",
@@ -40,12 +41,13 @@ Gem::Specification.new do |s|
40
41
  "spec/parallel_specs/spec_runtime_logger_spec.rb",
41
42
  "spec/parallel_specs/spec_summary_logger_spec.rb",
42
43
  "spec/parallel_specs_spec.rb",
44
+ "spec/parallel_tests/runtime_logger_spec.rb",
43
45
  "spec/parallel_tests_spec.rb",
44
46
  "spec/spec_helper.rb"
45
47
  ]
46
48
  s.homepage = "http://github.com/grosser/parallel_tests"
47
49
  s.require_paths = ["lib"]
48
- s.rubygems_version = "1.8.10"
50
+ s.rubygems_version = "1.8.15"
49
51
  s.summary = "Run tests / specs / features in parallel"
50
52
 
51
53
  if s.respond_to? :specification_version then
@@ -0,0 +1,74 @@
1
+ require 'spec_helper'
2
+
3
+ describe ParallelTests::RuntimeLogger do
4
+
5
+ describe :writing do
6
+ it "overwrites the runtime_log file on first log invocation" do
7
+ class FakeTest
8
+ end
9
+ test = FakeTest.new
10
+ time = Time.now
11
+ File.open(ParallelTests.runtime_log, 'w'){ |f| f.puts("FooBar") }
12
+ ParallelTests::RuntimeLogger.send(:class_variable_set,:@@has_started, false)
13
+ ParallelTests::RuntimeLogger.log(test, time, Time.at(time.to_f+2.00))
14
+ result = File.read(ParallelTests.runtime_log)
15
+ result.should_not include('FooBar')
16
+ result.should include('test/fake_test.rb:2.00')
17
+ end
18
+
19
+ it "appends to the runtime_log file after first log invocation" do
20
+ class FakeTest
21
+ end
22
+ test = FakeTest.new
23
+ class OtherFakeTest
24
+ end
25
+ other_test = OtherFakeTest.new
26
+
27
+ time = Time.now
28
+ File.open(ParallelTests.runtime_log, 'w'){ |f| f.puts("FooBar") }
29
+ ParallelTests::RuntimeLogger.send(:class_variable_set,:@@has_started, false)
30
+ ParallelTests::RuntimeLogger.log(test, time, Time.at(time.to_f+2.00))
31
+ ParallelTests::RuntimeLogger.log(other_test, time, Time.at(time.to_f+2.00))
32
+ result = File.read(ParallelTests.runtime_log)
33
+ result.should_not include('FooBar')
34
+ result.should include('test/fake_test.rb:2.00')
35
+ result.should include('test/other_fake_test.rb:2.00')
36
+ end
37
+
38
+ end
39
+
40
+ describe :formatting do
41
+ it "formats results for simple test names" do
42
+ class FakeTest
43
+ end
44
+ test = FakeTest.new
45
+ time = Time.now
46
+ ParallelTests::RuntimeLogger.message(test, time, Time.at(time.to_f+2.00)).should == 'test/fake_test.rb:2.00'
47
+ end
48
+
49
+ it "formats results for complex test names" do
50
+ class AVeryComplex
51
+ class FakeTest
52
+ end
53
+ end
54
+ test = AVeryComplex::FakeTest.new
55
+ time = Time.now
56
+ ParallelTests::RuntimeLogger.message(test, time, Time.at(time.to_f+2.00)).should == 'test/a_very_complex/fake_test.rb:2.00'
57
+ end
58
+
59
+ it "guesses subdirectory structure for rails test classes" do
60
+ module Rails
61
+ end
62
+ class ActionController
63
+ class TestCase
64
+ end
65
+ end
66
+ class FakeControllerTest < ActionController::TestCase
67
+ end
68
+ test = FakeControllerTest.new
69
+ time = Time.now
70
+ ParallelTests::RuntimeLogger.message(test, time, Time.at(time.to_f+2.00)).should == 'test/functional/fake_controller_test.rb:2.00'
71
+ end
72
+ end
73
+
74
+ end
@@ -9,6 +9,7 @@ require 'parallel_specs'
9
9
  require 'parallel_specs/spec_runtime_logger'
10
10
  require 'parallel_specs/spec_summary_logger'
11
11
  require 'parallel_cucumber'
12
+ require 'parallel_tests/runtime_logger'
12
13
 
13
14
  OutputLogger = Struct.new(:output) do
14
15
  attr_reader :flock, :flush
metadata CHANGED
@@ -1,36 +1,47 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: parallel_tests
3
- version: !ruby/object:Gem::Version
4
- version: 0.6.15
3
+ version: !ruby/object:Gem::Version
4
+ hash: 39
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 6
9
+ - 16
10
+ version: 0.6.16
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Michael Grosser
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-01-12 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: parallel
16
- requirement: &69308050 !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
17
+
18
+ date: 2012-01-13 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
23
21
  prerelease: false
24
- version_requirements: *69308050
22
+ type: :runtime
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ name: parallel
33
+ version_requirements: *id001
25
34
  description:
26
35
  email: grosser.michael@gmail.com
27
- executables:
36
+ executables:
28
37
  - parallel_cucumber
29
- - parallel_spec
30
38
  - parallel_test
39
+ - parallel_spec
31
40
  extensions: []
41
+
32
42
  extra_rdoc_files: []
33
- files:
43
+
44
+ files:
34
45
  - Gemfile
35
46
  - Gemfile.lock
36
47
  - Rakefile
@@ -49,6 +60,7 @@ files:
49
60
  - lib/parallel_tests.rb
50
61
  - lib/parallel_tests/grouper.rb
51
62
  - lib/parallel_tests/railtie.rb
63
+ - lib/parallel_tests/runtime_logger.rb
52
64
  - lib/parallel_tests/tasks.rb
53
65
  - lib/tasks/parallel_tests.rake
54
66
  - parallel_tests.gemspec
@@ -58,33 +70,41 @@ files:
58
70
  - spec/parallel_specs/spec_runtime_logger_spec.rb
59
71
  - spec/parallel_specs/spec_summary_logger_spec.rb
60
72
  - spec/parallel_specs_spec.rb
73
+ - spec/parallel_tests/runtime_logger_spec.rb
61
74
  - spec/parallel_tests_spec.rb
62
75
  - spec/spec_helper.rb
63
76
  homepage: http://github.com/grosser/parallel_tests
64
77
  licenses: []
78
+
65
79
  post_install_message:
66
80
  rdoc_options: []
67
- require_paths:
81
+
82
+ require_paths:
68
83
  - lib
69
- required_ruby_version: !ruby/object:Gem::Requirement
84
+ required_ruby_version: !ruby/object:Gem::Requirement
70
85
  none: false
71
- requirements:
72
- - - ! '>='
73
- - !ruby/object:Gem::Version
74
- version: '0'
75
- segments:
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
76
91
  - 0
77
- hash: -947870483
78
- required_rubygems_version: !ruby/object:Gem::Requirement
92
+ version: "0"
93
+ required_rubygems_version: !ruby/object:Gem::Requirement
79
94
  none: false
80
- requirements:
81
- - - ! '>='
82
- - !ruby/object:Gem::Version
83
- version: '0'
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ hash: 3
99
+ segments:
100
+ - 0
101
+ version: "0"
84
102
  requirements: []
103
+
85
104
  rubyforge_project:
86
- rubygems_version: 1.8.10
105
+ rubygems_version: 1.8.15
87
106
  signing_key:
88
107
  specification_version: 3
89
108
  summary: Run tests / specs / features in parallel
90
109
  test_files: []
110
+