parallel_tests 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +1 -0
- data/VERSION +1 -1
- data/lib/parallel_cucumber.rb +1 -1
- data/lib/parallel_specs.rb +1 -1
- data/lib/parallel_tests.rb +16 -0
- data/lib/tasks/parallel_tests.rake +1 -1
- data/parallel_tests.gemspec +1 -1
- data/spec/parallel_cucumber_spec.rb +1 -1
- data/spec/parallel_specs_spec.rb +1 -1
- data/spec/parallel_tests_spec.rb +30 -1
- data/spec/spec_helper.rb +23 -1
- metadata +2 -2
data/README.markdown
CHANGED
@@ -108,6 +108,7 @@ inspired by [pivotal labs](http://pivotallabs.com/users/miked/blog/articles/849-
|
|
108
108
|
|
109
109
|
###Contributors (alphabetical)
|
110
110
|
- [Charles Finkel](http://charlesfinkel.com/)
|
111
|
+
- [Indrek Juhkam](http://urgas.eu)
|
111
112
|
- [Jason Morrison](http://jayunit.net)
|
112
113
|
- [Joakim Kolsjö](http://www.rubyblocks.se)
|
113
114
|
- [Kevin Scaldeferri](http://kevin.scaldeferri.com/blog/)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.2
|
data/lib/parallel_cucumber.rb
CHANGED
data/lib/parallel_specs.rb
CHANGED
data/lib/parallel_tests.rb
CHANGED
@@ -65,6 +65,22 @@ class ParallelTests
|
|
65
65
|
|
66
66
|
protected
|
67
67
|
|
68
|
+
# copied from http://github.com/carlhuda/bundler Bundler::SharedHelpers#find_gemfile
|
69
|
+
def self.bundler_enabled?
|
70
|
+
return true if Object.const_defined?(:Bundler)
|
71
|
+
|
72
|
+
previous = nil
|
73
|
+
current = File.expand_path(Dir.pwd)
|
74
|
+
|
75
|
+
until !File.directory?(current) || current == previous
|
76
|
+
filename = File.join(current, "Gemfile")
|
77
|
+
return true if File.exists?(filename)
|
78
|
+
current, previous = File.expand_path("..", current), current
|
79
|
+
end
|
80
|
+
|
81
|
+
false
|
82
|
+
end
|
83
|
+
|
68
84
|
def self.line_is_result?(line)
|
69
85
|
line =~ /\d+ failure/
|
70
86
|
end
|
@@ -25,7 +25,7 @@ namespace :parallel do
|
|
25
25
|
['test', 'spec', 'features'].each do |type|
|
26
26
|
desc "run #{type} in parallel with parallel:#{type}[num_cpus]"
|
27
27
|
task type, :count, :path_prefix, :options do |t,args|
|
28
|
-
$LOAD_PATH << File.join(File.dirname(__FILE__), '..')
|
28
|
+
$LOAD_PATH << File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
29
29
|
require "parallel_tests"
|
30
30
|
count, prefix, options = ParallelTests.parse_rake_args(args)
|
31
31
|
exec "#{File.join(File.dirname(__FILE__), '..', '..', 'bin', 'parallel_test')} --type #{type} -n #{count} -p '#{prefix}' -r '#{RAILS_ROOT}' -o '#{options}'"
|
data/parallel_tests.gemspec
CHANGED
@@ -27,7 +27,7 @@ describe ParallelCucumber do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it "runs bundle exec cucumber when on bundler 0.9" do
|
30
|
-
|
30
|
+
ParallelCucumber.stub!(:bundler_enabled?).and_return true
|
31
31
|
ParallelCucumber.should_receive(:open).with{|x,y| x =~ %r{bundle exec cucumber}}.and_return mock(:getc=>false)
|
32
32
|
ParallelCucumber.run_tests(['xxx'],1,'')
|
33
33
|
end
|
data/spec/parallel_specs_spec.rb
CHANGED
@@ -34,7 +34,7 @@ describe ParallelSpecs do
|
|
34
34
|
end
|
35
35
|
|
36
36
|
it "run bundle exec spec when on bundler 0.9" do
|
37
|
-
|
37
|
+
ParallelSpecs.stub!(:bundler_enabled?).and_return true
|
38
38
|
ParallelSpecs.should_receive(:open).with{|x,y| x =~ %r{bundle exec spec}}.and_return mock(:getc=>false)
|
39
39
|
ParallelSpecs.run_tests(['xxx'],1,'')
|
40
40
|
end
|
data/spec/parallel_tests_spec.rb
CHANGED
@@ -11,7 +11,7 @@ describe ParallelTests do
|
|
11
11
|
|
12
12
|
it "should default to the prefix" do
|
13
13
|
args = {:count => "models"}
|
14
|
-
ParallelTests.parse_rake_args(args).should == [
|
14
|
+
ParallelTests.parse_rake_args(args).should == [Parallel.processor_count, "models", ""]
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should return the count and prefix" do
|
@@ -137,6 +137,35 @@ EOF
|
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
|
+
describe :bundler_enabled? do
|
141
|
+
it "should return false" do
|
142
|
+
use_temporary_directory_for do
|
143
|
+
ParallelTests.send(:bundler_enabled?).should == false
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should return true when there is a constant called Bundler" do
|
148
|
+
use_temporary_directory_for do
|
149
|
+
Object.stub!(:const_defined?).with(:Bundler).and_return true
|
150
|
+
ParallelTests.send(:bundler_enabled?).should == true
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should be true when there is a Gemfile" do
|
155
|
+
use_temporary_directory_for do
|
156
|
+
FileUtils.touch("Gemfile")
|
157
|
+
ParallelTests.send(:bundler_enabled?).should == true
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should be true when there is a Gemfile in the parent directory" do
|
162
|
+
use_temporary_directory_for do
|
163
|
+
FileUtils.touch(File.join("..", "Gemfile"))
|
164
|
+
ParallelTests.send(:bundler_enabled?).should == true
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
140
169
|
it "has a version" do
|
141
170
|
ParallelTests::VERSION.should =~ /^\d+\.\d+\.\d+$/
|
142
171
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -11,6 +11,28 @@ def size_of(group)
|
|
11
11
|
group.inject(0) { |sum, test| sum += File.stat(test).size }
|
12
12
|
end
|
13
13
|
|
14
|
+
# Uses /tmp/parallel_tests/application as the cwd so we can create and remove
|
15
|
+
# files as we want to. After execution it changes cwd back to the original one.
|
16
|
+
def use_temporary_directory_for
|
17
|
+
dir = File.join("/tmp", "parallel_tests")
|
18
|
+
new_dir = File.join(dir, "application")
|
19
|
+
|
20
|
+
begin
|
21
|
+
# just in case the temporary dir already exists
|
22
|
+
FileUtils.rm_rf(dir) if File.exists?(dir)
|
23
|
+
|
24
|
+
# create the temporary directory
|
25
|
+
FileUtils.mkdir_p(new_dir)
|
26
|
+
|
27
|
+
# chdir changes cwd back to the original one after it is done
|
28
|
+
Dir.chdir(new_dir) do
|
29
|
+
yield
|
30
|
+
end
|
31
|
+
ensure
|
32
|
+
FileUtils.rm_rf(dir) if File.exists?(dir)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
14
36
|
def test_tests_in_groups(klass, folder, suffix)
|
15
37
|
test_root = "#{FAKE_RAILS_ROOT}/#{folder}"
|
16
38
|
|
@@ -79,4 +101,4 @@ def test_tests_in_groups(klass, folder, suffix)
|
|
79
101
|
groups[1].should == ["file2.rb", "file4.rb"]
|
80
102
|
end
|
81
103
|
end
|
82
|
-
end
|
104
|
+
end
|