parallel_tests 0.6.9 → 0.6.10

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.9
1
+ 0.6.10
@@ -20,6 +20,7 @@ class ParallelSpecs < ParallelTests
20
20
  cmd or raise("Can't find executables rspec or spec")
21
21
  end
22
22
 
23
+ # legacy <-> people log to this file using rspec options
23
24
  def self.runtime_log
24
25
  'tmp/parallel_profile.log'
25
26
  end
@@ -1,5 +1,4 @@
1
- require 'parallel_specs'
2
- require File.join(File.dirname(__FILE__), 'spec_logger_base')
1
+ require 'parallel_specs/spec_logger_base'
3
2
 
4
3
  class ParallelSpecs::SpecFailuresLogger < ParallelSpecs::SpecLoggerBase
5
4
  def initialize(options, output=nil)
@@ -1,5 +1,4 @@
1
- require 'parallel_specs'
2
- require File.join(File.dirname(__FILE__), 'spec_logger_base')
1
+ require 'parallel_specs/spec_logger_base'
3
2
 
4
3
  class ParallelSpecs::SpecRuntimeLogger < ParallelSpecs::SpecLoggerBase
5
4
  def initialize(options, output=nil)
@@ -20,9 +19,11 @@ class ParallelSpecs::SpecRuntimeLogger < ParallelSpecs::SpecLoggerBase
20
19
  return unless ENV['TEST_ENV_NUMBER'] #only record when running in parallel
21
20
  # TODO: Figure out why sometimes time can be less than 0
22
21
  lock_output do
23
- @output.puts @example_times.map { |file, time| "#{file}:#{time > 0 ? time : 0}" }
22
+ @example_times.each do |file, time|
23
+ relative_path = file.sub(/^#{Regexp.escape Dir.pwd}\//,'')
24
+ @output.puts "#{relative_path}:#{time > 0 ? time : 0}"
25
+ end
24
26
  end
25
27
  @output.flush
26
28
  end
27
-
28
29
  end
@@ -1,5 +1,4 @@
1
- require 'parallel_specs'
2
- require File.join(File.dirname(__FILE__), 'spec_logger_base')
1
+ require 'parallel_specs/spec_logger_base'
3
2
 
4
3
  class ParallelSpecs::SpecSummaryLogger < ParallelSpecs::SpecLoggerBase
5
4
  def initialize(options, output=nil)
@@ -62,7 +62,7 @@ class ParallelTests
62
62
  end
63
63
 
64
64
  def self.runtime_log
65
- '__foo__'
65
+ 'tmp/parallel_runtime_test.log'
66
66
  end
67
67
 
68
68
  def self.summarize_results(results)
@@ -139,7 +139,7 @@ class ParallelTests
139
139
  times = Hash.new(1)
140
140
  lines.each do |line|
141
141
  test, time = line.split(":")
142
- times[test] = time.to_f
142
+ times[File.expand_path(test)] = time.to_f
143
143
  end
144
144
  tests.sort.map{|test| [test, times[test]] }
145
145
  else # use file sizes
@@ -18,7 +18,6 @@ class ParallelTests
18
18
  # add all files that should run in a single process to one group
19
19
  (options[:single_process]||[]).each do |pattern|
20
20
  matched, items_with_sizes = items_with_sizes.partition{|item, size| item =~ pattern }
21
- puts matched.inspect
22
21
  smallest = smallest_group(groups)
23
22
  matched.each{|item,size| add_to_group(smallest, item, size) }
24
23
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "parallel_tests"
8
- s.version = "0.6.9"
8
+ s.version = "0.6.10"
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 = "2011-11-02"
12
+ s.date = "2011-11-08"
13
13
  s.email = "grosser.michael@gmail.com"
14
14
  s.executables = ["parallel_cucumber", "parallel_spec", "parallel_test"]
15
15
  s.files = [
@@ -36,6 +36,7 @@ Gem::Specification.new do |s|
36
36
  "parallel_tests.gemspec",
37
37
  "spec/integration_spec.rb",
38
38
  "spec/parallel_cucumber_spec.rb",
39
+ "spec/parallel_specs/spec_runtime_logger_spec.rb",
39
40
  "spec/parallel_specs_spec.rb",
40
41
  "spec/parallel_tests_spec.rb",
41
42
  "spec/spec_helper.rb"
@@ -96,7 +96,7 @@ describe 'CLI' do
96
96
  write "spec/xxx#{i}_spec.rb", 'describe("it"){it("should"){sleep 5}}; $stderr.puts ENV["TEST_ENV_NUMBER"]'
97
97
  }
98
98
  t = Time.now
99
- puts run_tests(:processes => 2)
99
+ run_tests(:processes => 2)
100
100
  expected = 10
101
101
  (Time.now - t).should <= expected
102
102
  end
@@ -0,0 +1,57 @@
1
+ require 'spec_helper'
2
+
3
+ describe ParallelSpecs::SpecRuntimeLogger do
4
+ before do
5
+ # pretend we run in parallel or the logger will log nothing
6
+ ENV['TEST_ENV_NUMBER'] = ''
7
+ end
8
+
9
+ after do
10
+ ENV.delete 'TEST_ENV_NUMBER'
11
+ end
12
+
13
+ def log_for_a_file
14
+ Tempfile.open('xxx') do |temp|
15
+ temp.close
16
+ f = File.open(temp.path,'w')
17
+ logger = if block_given?
18
+ yield(f)
19
+ else
20
+ ParallelSpecs::SpecRuntimeLogger.new(f)
21
+ end
22
+ logger.example_started
23
+ logger.example_passed(mock(:location => "#{Dir.pwd}/spec/foo.rb:123"))
24
+ logger.start_dump
25
+
26
+ #f.close
27
+ return File.read(f.path)
28
+ end
29
+ end
30
+
31
+ it "logs runtime with relative paths" do
32
+ log_for_a_file.should =~ %r{^spec/foo.rb:0.\d+$}m
33
+ end
34
+
35
+ it "does not log if we do not run in parallel" do
36
+ ENV.delete 'TEST_ENV_NUMBER'
37
+ log_for_a_file.should == ''
38
+ end
39
+
40
+ it "appends to a given file" do
41
+ result = log_for_a_file do |f|
42
+ f.write 'FooBar'
43
+ ParallelSpecs::SpecRuntimeLogger.new(f)
44
+ end
45
+ result.should include('FooBar')
46
+ result.should include('foo.rb')
47
+ end
48
+
49
+ it "overwrites a given path" do
50
+ result = log_for_a_file do |f|
51
+ f.write 'FooBar'
52
+ ParallelSpecs::SpecRuntimeLogger.new(f.path)
53
+ end
54
+ result.should_not include('FooBar')
55
+ result.should include('foo.rb')
56
+ end
57
+ end
@@ -180,24 +180,6 @@ EOF
180
180
  @failure1 = mock( 'example', :location => '/path/to/example:123', :header => 'header', :exception => @exception1 )
181
181
  end
182
182
 
183
- describe ParallelSpecs::SpecRuntimeLogger do
184
- before :each do
185
- ENV['TEST_ENV_NUMBER'] = '1'
186
- @logger = ParallelSpecs::SpecRuntimeLogger.new( @output )
187
- end
188
-
189
- it "collects runtime information" do
190
- @logger.example_started
191
- @logger.example_passed( @example1 )
192
-
193
- @logger.start_dump
194
-
195
- @output.output.size.should == 1
196
- @output.output[0].size.should == 1
197
- @output.output[0][0].should =~ %r(/path/to/example:([\d\.e\-]+))
198
- end
199
- end
200
-
201
183
  describe ParallelSpecs::SpecSummaryLogger do
202
184
  before :each do
203
185
  @logger = ParallelSpecs::SpecSummaryLogger.new( @output )
@@ -4,7 +4,9 @@ require 'rubygems'
4
4
 
5
5
  FAKE_RAILS_ROOT = '/tmp/pspecs/fixtures'
6
6
 
7
+ require 'tempfile'
7
8
  require 'parallel_specs'
9
+ require 'parallel_specs/spec_runtime_logger'
8
10
  require 'parallel_cucumber'
9
11
 
10
12
  def mocked_process
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel_tests
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.9
4
+ version: 0.6.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-02 00:00:00.000000000 Z
12
+ date: 2011-11-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: parallel
16
- requirement: &83901750 !ruby/object:Gem::Requirement
16
+ requirement: &78420700 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *83901750
24
+ version_requirements: *78420700
25
25
  description:
26
26
  email: grosser.michael@gmail.com
27
27
  executables:
@@ -54,6 +54,7 @@ files:
54
54
  - parallel_tests.gemspec
55
55
  - spec/integration_spec.rb
56
56
  - spec/parallel_cucumber_spec.rb
57
+ - spec/parallel_specs/spec_runtime_logger_spec.rb
57
58
  - spec/parallel_specs_spec.rb
58
59
  - spec/parallel_tests_spec.rb
59
60
  - spec/spec_helper.rb
@@ -71,7 +72,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
71
72
  version: '0'
72
73
  segments:
73
74
  - 0
74
- hash: 784152591
75
+ hash: -622498067
75
76
  required_rubygems_version: !ruby/object:Gem::Requirement
76
77
  none: false
77
78
  requirements: