parallel_tests 0.3.3 → 0.3.4
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.markdown +1 -0
- data/VERSION +1 -1
- data/lib/parallel_cucumber.rb +3 -3
- data/lib/parallel_specs.rb +2 -2
- data/lib/parallel_tests.rb +11 -16
- data/parallel_tests.gemspec +2 -2
- data/spec/spec_helper.rb +7 -17
- metadata +3 -3
data/README.markdown
CHANGED
@@ -107,6 +107,7 @@ inspired by [pivotal labs](http://pivotallabs.com/users/miked/blog/articles/849-
|
|
107
107
|
- [Charles Finkel](http://charlesfinkel.com/)
|
108
108
|
- [Jason Morrison](http://jayunit.net)
|
109
109
|
- [Joakim Kolsjö](http://www.rubyblocks.se)
|
110
|
+
- [Kevin Scaldeferri](http://kevin.scaldeferri.com/blog/)
|
110
111
|
- [Kpumuk](http://kpumuk.info/)
|
111
112
|
- [Maksim Horbu](http://github.com/mhorbul)
|
112
113
|
- [Rohan Deshpande](http://github.com/rdeshpande)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.4
|
data/lib/parallel_cucumber.rb
CHANGED
@@ -2,8 +2,8 @@ require File.join(File.dirname(__FILE__), 'parallel_tests')
|
|
2
2
|
|
3
3
|
class ParallelCucumber < ParallelTests
|
4
4
|
def self.run_tests(test_files, process_number, options)
|
5
|
-
color = ($stdout.tty? ? '
|
6
|
-
cmd = "
|
5
|
+
color = ($stdout.tty? ? 'AUTOTEST=1 ; export AUTOTEST ;' : '')#display color when we are in a terminal
|
6
|
+
cmd = "RAILS_ENV=test ; export RAILS_ENV ; #{color} #{executable} #{options} #{test_files*' '}"
|
7
7
|
execute_command(cmd, process_number)
|
8
8
|
end
|
9
9
|
|
@@ -22,7 +22,7 @@ class ParallelCucumber < ParallelTests
|
|
22
22
|
def self.line_is_result?(line)
|
23
23
|
line =~ /^\d+ (steps|scenarios)/
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
def self.line_is_failure?(line)
|
27
27
|
line =~ /^\d+ (steps|scenarios).*(\d{2,}|[1-9]) failed/
|
28
28
|
end
|
data/lib/parallel_specs.rb
CHANGED
@@ -4,8 +4,8 @@ class ParallelSpecs < ParallelTests
|
|
4
4
|
def self.run_tests(test_files, process_number, options)
|
5
5
|
spec_opts = ['spec/parallel_spec.opts', 'spec/spec.opts'].detect{|f| File.file?(f) }
|
6
6
|
spec_opts = (spec_opts ? "-O #{spec_opts}" : nil)
|
7
|
-
color = ($stdout.tty? ? '
|
8
|
-
cmd = "
|
7
|
+
color = ($stdout.tty? ? 'RSPEC_COLOR=1 ; export RSPEC_COLOR ;' : '')#display color when we are in a terminal
|
8
|
+
cmd = "RAILS_ENV=test ; export RAILS_ENV ; #{color} #{executable} #{options} #{spec_opts} #{test_files*' '}"
|
9
9
|
execute_command(cmd, process_number)
|
10
10
|
end
|
11
11
|
|
data/lib/parallel_tests.rb
CHANGED
@@ -21,30 +21,25 @@ class ParallelTests
|
|
21
21
|
def self.tests_in_groups(root, num)
|
22
22
|
tests_with_sizes = slow_specs_first(find_tests_with_sizes(root))
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
# always add to smallest group
|
25
|
+
groups = Array.new(num){{:tests => [], :size => 0}}
|
26
26
|
tests_with_sizes.each do |test, size|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
current_group += 1
|
31
|
-
else
|
32
|
-
current_size += size
|
33
|
-
end
|
34
|
-
groups[current_group] ||= []
|
35
|
-
groups[current_group] << test
|
27
|
+
smallest = groups.sort_by{|g| g[:size] }.first
|
28
|
+
smallest[:tests] << test
|
29
|
+
smallest[:size] += size
|
36
30
|
end
|
37
|
-
|
31
|
+
|
32
|
+
groups.map{|g| g[:tests] }
|
38
33
|
end
|
39
34
|
|
40
35
|
def self.run_tests(test_files, process_number, options)
|
41
36
|
require_list = test_files.map { |filename| "\"#{filename}\"" }.join(",")
|
42
|
-
cmd = "
|
37
|
+
cmd = "RAILS_ENV=test ; export RAILS_ENV ; ruby -Itest #{options} -e '[#{require_list}].each {|f| require f }'"
|
43
38
|
execute_command(cmd, process_number)
|
44
39
|
end
|
45
40
|
|
46
41
|
def self.execute_command(cmd, process_number)
|
47
|
-
cmd = "
|
42
|
+
cmd = "TEST_ENV_NUMBER=#{test_env_number(process_number)} ; export TEST_ENV_NUMBER; #{cmd}"
|
48
43
|
f = open("|#{cmd}", 'r')
|
49
44
|
all = ''
|
50
45
|
while char = f.getc
|
@@ -78,11 +73,11 @@ class ParallelTests
|
|
78
73
|
def self.slow_specs_first(tests)
|
79
74
|
tests.sort_by{|test, size| size }.reverse
|
80
75
|
end
|
81
|
-
|
76
|
+
|
82
77
|
def self.line_is_result?(line)
|
83
78
|
line =~ /\d+ failure/
|
84
79
|
end
|
85
|
-
|
80
|
+
|
86
81
|
def self.line_is_failure?(line)
|
87
82
|
line =~ /(\d{2,}|[1-9]) (failure|error)/
|
88
83
|
end
|
data/parallel_tests.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{parallel_tests}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.4"
|
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{2010-03-
|
12
|
+
s.date = %q{2010-03-27}
|
13
13
|
s.email = %q{grosser.michael@gmail.com}
|
14
14
|
s.executables = ["parallel_test", "parallel_spec", "parallel_cucumber"]
|
15
15
|
s.extra_rdoc_files = [
|
data/spec/spec_helper.rb
CHANGED
@@ -38,26 +38,17 @@ def test_tests_in_groups(klass, folder, suffix)
|
|
38
38
|
|
39
39
|
it "partitions them into groups by equal size" do
|
40
40
|
groups = klass.tests_in_groups(test_root, 2)
|
41
|
-
groups.
|
42
|
-
size_of(groups[0]).should == 400
|
43
|
-
size_of(groups[1]).should == 400
|
41
|
+
groups.map{|g| size_of(g)}.should == [400, 400]
|
44
42
|
end
|
45
43
|
|
46
44
|
it 'should partition correctly with a group size of 4' do
|
47
45
|
groups = klass.tests_in_groups(test_root, 4)
|
48
|
-
groups.
|
49
|
-
size_of(groups[0]).should == 200
|
50
|
-
size_of(groups[1]).should == 200
|
51
|
-
size_of(groups[2]).should == 200
|
52
|
-
size_of(groups[3]).should == 200
|
46
|
+
groups.map{|g| size_of(g)}.should == [200, 200, 200, 200]
|
53
47
|
end
|
54
48
|
|
55
49
|
it 'should partition correctly with an uneven group size' do
|
56
50
|
groups = klass.tests_in_groups(test_root, 3)
|
57
|
-
groups.
|
58
|
-
size_of(groups[0]).should == 300
|
59
|
-
size_of(groups[1]).should == 300
|
60
|
-
size_of(groups[2]).should == 200
|
51
|
+
groups.map{|g| size_of(g)}.should =~ [300, 300, 200]
|
61
52
|
end
|
62
53
|
|
63
54
|
it "partitions by runtime when runtime-data is available" do
|
@@ -68,11 +59,10 @@ def test_tests_in_groups(klass, folder, suffix)
|
|
68
59
|
|
69
60
|
groups = klass.tests_in_groups(test_root, 2)
|
70
61
|
groups.size.should == 2
|
71
|
-
# 10 +
|
72
|
-
groups[0].should == [@files[0],@files[
|
73
|
-
# 6+
|
74
|
-
|
75
|
-
groups[1].should == [@files[6],@files[5],@files[4],@files[3],@files[2],@files[1]]
|
62
|
+
# 10 + 5 + 3 + 1 = 19
|
63
|
+
groups[0].should == [@files[0],@files[5],@files[3],@files[1]]
|
64
|
+
# 7 + 6 + 4 + 2 = 19
|
65
|
+
groups[1].should == [@files[7],@files[6],@files[4],@files[2]]
|
76
66
|
end
|
77
67
|
end
|
78
68
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 4
|
9
|
+
version: 0.3.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Michael Grosser
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-27 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|