testbot 0.6.9 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ 0.7.0
2
+
3
+ Added per project rvm support. Using this you can run testbot using system ruby
4
+ while being able to run test processes using the project rvm environment. This
5
+ is also useful if you have several projects with different rvm rubies and gemsets.
6
+
1
7
  0.6.9
2
8
 
3
9
  Removed dependency on macaddr as that does not work on some platforms.
@@ -67,7 +67,7 @@ Using testbot with Rails 2:
67
67
 
68
68
  # Add testbot to your Gemfile if you use bundler. You also need the plugin because
69
69
  # Rails 2 does not load raketasks from gems.
70
- ruby script/plugin install git://github.com/joakimk/testbot.git -r 'refs/tags/v0.6.9'
70
+ ruby script/plugin install git://github.com/joakimk/testbot.git -r 'refs/tags/v0.7.0'
71
71
  script/generate testbot --connect 192.168.0.100
72
72
 
73
73
  rake testbot:spec (or :rspec, :test, :features)
@@ -126,14 +126,18 @@ module Testbot::Runner
126
126
  end
127
127
 
128
128
  def before_run(job)
129
- using_bundler = RubyEnv.bundler?(job.project)
130
- bundler_cmd = using_bundler ? "bundle exec" : ""
129
+ rvm_prefix = RubyEnv.rvm_prefix(job.project)
130
+ bundler_cmd = (RubyEnv.bundler?(job.project) ? [rvm_prefix, "bundle &&", rvm_prefix, "bundle exec"] : [rvm_prefix]).compact.join(" ")
131
131
  command_prefix = "cd #{job.project}; RAILS_ENV=test TEST_INSTANCES=#{@config.max_instances} #{bundler_cmd}"
132
132
 
133
- # todo: exit if this fails, report back, etc.
134
- system("cd #{job.project}; bundle") if using_bundler
135
- system "#{command_prefix} rake testbot:before_run" if File.exists?("#{job.project}/lib/tasks/testbot.rake")
136
- system "#{command_prefix} ruby config/testbot/before_run.rb" if File.exists?("#{job.project}/config/testbot/before_run.rb")
133
+ if File.exists?("#{job.project}/lib/tasks/testbot.rake")
134
+ system "#{command_prefix} rake testbot:before_run"
135
+ elsif File.exists?("#{job.project}/config/testbot/before_run.rb")
136
+ system "#{command_prefix} ruby config/testbot/before_run.rb"
137
+ else
138
+ # workaround to bundle within the correct env
139
+ system "#{command_prefix} ruby -e ''"
140
+ end
137
141
  end
138
142
 
139
143
  def first_job_from_build?
@@ -1,5 +1,4 @@
1
1
  class RubyEnv
2
-
3
2
  def self.bundler?(project_path)
4
3
  gem_exists?("bundler") && File.exists?("#{project_path}/Gemfile")
5
4
  end
@@ -27,10 +26,22 @@ class RubyEnv
27
26
  end
28
27
 
29
28
  if bundler?(project_path)
30
- "#{ruby_interpreter} -S bundle exec #{command}".strip
29
+ "#{rvm_prefix(project_path)} #{ruby_interpreter} -S bundle exec #{command}".strip
31
30
  else
32
- "#{ruby_interpreter} -S #{command}".strip
31
+ "#{rvm_prefix(project_path)} #{ruby_interpreter} -S #{command}".strip
33
32
  end
34
33
  end
35
34
 
35
+ def self.rvm_prefix(project_path)
36
+ if rvm?
37
+ rvmrc_path = File.join project_path, ".rvmrc"
38
+ if File.exists?(rvmrc_path)
39
+ File.read(rvmrc_path).to_s.strip + " exec"
40
+ end
41
+ end
42
+ end
43
+
44
+ def self.rvm?
45
+ system("rvm info") != nil
46
+ end
36
47
  end
@@ -1,7 +1,7 @@
1
1
  module Testbot
2
2
  # Don't forget to update readme and changelog
3
3
  def self.version
4
- version = "0.6.9"
4
+ version = "0.7.0"
5
5
  dev_version_file = File.join(File.dirname(__FILE__), '..', '..', 'DEV_VERSION')
6
6
  if File.exists?(dev_version_file)
7
7
  version += File.read(dev_version_file)
@@ -22,7 +22,7 @@ class IntegrationTest < Test::Unit::TestCase
22
22
  system "rm -rf tmp; mkdir -p tmp; cp -rf test/fixtures/local tmp/local"
23
23
  system "export INTEGRATION_TEST=true; bin/testbot --runner --connect 127.0.0.1 --working_dir tmp/runner > /dev/null"
24
24
  system "export INTEGRATION_TEST=true; bin/testbot --server > /dev/null"
25
-
25
+
26
26
  # For debug
27
27
  # Thread.new do
28
28
  # system "export INTEGRATION_TEST=true; bin/testbot --runner run --connect 127.0.0.1 --working_dir tmp/runner"
@@ -30,6 +30,7 @@ module Testbot::Runner
30
30
  with("export RAILS_ENV=test; export TEST_ENV_NUMBER=; cd project; export RSPEC_COLOR=true; ruby -S bundle exec rspec spec/foo_spec.rb spec/bar_spec.rb").
31
31
  and_return('result text')
32
32
  flexmock(RubyEnv).should_receive(:bundler?).returns(true)
33
+ flexmock(RubyEnv).should_receive(:rvm?).returns(false)
33
34
  job.run(0)
34
35
  end
35
36
 
@@ -53,6 +54,7 @@ module Testbot::Runner
53
54
  flexmock(job).should_receive(:run_and_return_result).
54
55
  with(/TEST_ENV_NUMBER=2/).
55
56
  and_return('result text')
57
+ flexmock(RubyEnv).should_receive(:rvm?).returns(false)
56
58
  job.run(1)
57
59
  end
58
60
 
@@ -63,6 +65,7 @@ module Testbot::Runner
63
65
  stub_duration(10.55)
64
66
  expect_put_with(10, "result text", "successful", 1055)
65
67
  flexmock(job).should_receive(:run_and_return_result).and_return('result text')
68
+ flexmock(RubyEnv).should_receive(:rvm?).returns(false)
66
69
  job.run(0)
67
70
  end
68
71
 
@@ -10,40 +10,42 @@ module Testbot::Runner
10
10
  should "use bundle exec in when calling rake testbot:before_run if bundler is present" do
11
11
  job = flexmock(:job, :project => "/path")
12
12
  flexmock(RubyEnv).should_receive(:bundler?).with("/path").returns(true)
13
-
13
+ flexmock(RubyEnv).should_receive(:rvm?).returns(false)
14
+
14
15
  runner = Runner.new({:max_instances => 1})
15
16
  flexmock(File).should_receive(:exists?).with("/path/lib/tasks/testbot.rake").and_return(true)
16
17
  flexmock(File).should_receive(:exists?).with("/path/config/testbot/before_run.rb").and_return(false)
18
+ flexmock(File).should_receive(:exists?).with("/path/.rvmrc").and_return(false)
17
19
  flexmock(runner)
18
- flexmock(runner).should_receive(:system).with("cd /path; bundle").once
19
- flexmock(runner).should_receive(:system).with("cd /path; RAILS_ENV=test TEST_INSTANCES=1 bundle exec rake testbot:before_run").once
20
+ flexmock(runner).should_receive(:system).with("cd /path; RAILS_ENV=test TEST_INSTANCES=1 bundle && bundle exec rake testbot:before_run").once
20
21
  runner.send(:before_run, job)
21
22
  end
22
23
 
23
24
  should "be able to use a plain ruby before_run file" do
24
25
  job = flexmock(:job, :project => "/path")
25
26
  flexmock(RubyEnv).should_receive(:bundler?).with("/path").returns(true)
26
-
27
+ flexmock(RubyEnv).should_receive(:rvm?).returns(false)
28
+
27
29
  runner = Runner.new({:max_instances => 1})
28
30
  flexmock(File).should_receive(:exists?).with("/path/lib/tasks/testbot.rake").and_return(false)
29
31
  flexmock(File).should_receive(:exists?).with("/path/config/testbot/before_run.rb").and_return(true)
30
32
  flexmock(runner)
31
- flexmock(runner).should_receive(:system).with("cd /path; bundle").once
32
- flexmock(runner).should_receive(:system).with("cd /path; RAILS_ENV=test TEST_INSTANCES=1 bundle exec ruby config/testbot/before_run.rb").once
33
+ flexmock(runner).should_receive(:system).with("cd /path; RAILS_ENV=test TEST_INSTANCES=1 bundle && bundle exec ruby config/testbot/before_run.rb").once
33
34
  runner.send(:before_run, job)
34
35
  end
35
36
 
36
37
  should "be able to run without bundler" do
37
38
  job = flexmock(:job, :project => "/path")
38
39
  flexmock(RubyEnv).should_receive(:bundler?).with("/path").returns(false)
39
-
40
+ flexmock(RubyEnv).should_receive(:rvm?).returns(false)
41
+
40
42
  runner = Runner.new({:max_instances => 1})
41
43
  flexmock(File).should_receive(:exists?).with("/path/lib/tasks/testbot.rake").and_return(false)
42
44
  flexmock(File).should_receive(:exists?).with("/path/config/testbot/before_run.rb").and_return(true)
43
45
  flexmock(runner)
44
46
  flexmock(runner).should_receive(:system).with("cd /path; RAILS_ENV=test TEST_INSTANCES=1 ruby config/testbot/before_run.rb").once
45
47
  runner.send(:before_run, job)
46
- end
48
+ end
47
49
  end
48
50
  end
49
51
 
@@ -4,7 +4,12 @@ require 'shoulda'
4
4
  require 'flexmock/test_unit'
5
5
 
6
6
  class RubyEnvTest < Test::Unit::TestCase
7
-
7
+
8
+ def setup
9
+ # Can't override a stub in flexmock?
10
+ def RubyEnv.rvm?; false; end
11
+ end
12
+
8
13
  context "self.bundler?" do
9
14
 
10
15
  should "return true if bundler is installed and there is a Gemfile" do
@@ -26,6 +31,21 @@ class RubyEnvTest < Test::Unit::TestCase
26
31
 
27
32
  end
28
33
 
34
+ context "self.rvm_prefix" do
35
+
36
+ should "return rvm prefix if rvm is installed" do
37
+ def RubyEnv.rvm?; true; end
38
+ flexmock(File).should_receive(:exists?).with("path/to/project/.rvmrc").once.and_return(true)
39
+ flexmock(File).should_receive(:read).with("path/to/project/.rvmrc").once.and_return("rvm 1.8.7\n")
40
+ assert_equal "rvm 1.8.7 exec", RubyEnv.rvm_prefix("path/to/project")
41
+ end
42
+
43
+ should "return nil if rvm is not installed" do
44
+ assert_equal nil, RubyEnv.rvm_prefix("path/to/project")
45
+ end
46
+
47
+ end
48
+
29
49
  context "self.ruby_command" do
30
50
 
31
51
  should "use ruby by default" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: testbot
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 6
9
- - 9
10
- version: 0.6.9
8
+ - 7
9
+ - 0
10
+ version: 0.7.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - "Joakim Kolsj\xC3\xB6"
@@ -15,13 +15,13 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-05-30 00:00:00 +02:00
18
+ date: 2012-11-20 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: sinatra
22
+ type: :runtime
23
23
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
27
  - - ">="
@@ -32,12 +32,12 @@ dependencies:
32
32
  - 0
33
33
  - 0
34
34
  version: 1.0.0
35
- type: :runtime
36
- version_requirements: *id001
35
+ name: sinatra
36
+ requirement: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- name: httparty
38
+ type: :runtime
39
39
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
40
+ version_requirements: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ">="
@@ -48,12 +48,12 @@ dependencies:
48
48
  - 6
49
49
  - 1
50
50
  version: 0.6.1
51
- type: :runtime
52
- version_requirements: *id002
51
+ name: httparty
52
+ requirement: *id002
53
53
  - !ruby/object:Gem::Dependency
54
- name: net-ssh
54
+ type: :runtime
55
55
  prerelease: false
56
- requirement: &id003 !ruby/object:Gem::Requirement
56
+ version_requirements: &id003 !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
59
  - - ">="
@@ -64,12 +64,12 @@ dependencies:
64
64
  - 0
65
65
  - 23
66
66
  version: 2.0.23
67
- type: :runtime
68
- version_requirements: *id003
67
+ name: net-ssh
68
+ requirement: *id003
69
69
  - !ruby/object:Gem::Dependency
70
- name: json_pure
70
+ type: :runtime
71
71
  prerelease: false
72
- requirement: &id004 !ruby/object:Gem::Requirement
72
+ version_requirements: &id004 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ">="
@@ -80,12 +80,12 @@ dependencies:
80
80
  - 4
81
81
  - 6
82
82
  version: 1.4.6
83
- type: :runtime
84
- version_requirements: *id004
83
+ name: json_pure
84
+ requirement: *id004
85
85
  - !ruby/object:Gem::Dependency
86
- name: daemons
86
+ type: :runtime
87
87
  prerelease: false
88
- requirement: &id005 !ruby/object:Gem::Requirement
88
+ version_requirements: &id005 !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements:
91
91
  - - ">="
@@ -96,12 +96,12 @@ dependencies:
96
96
  - 0
97
97
  - 10
98
98
  version: 1.0.10
99
- type: :runtime
100
- version_requirements: *id005
99
+ name: daemons
100
+ requirement: *id005
101
101
  - !ruby/object:Gem::Dependency
102
- name: acts_as_rails3_generator
102
+ type: :runtime
103
103
  prerelease: false
104
- requirement: &id006 !ruby/object:Gem::Requirement
104
+ version_requirements: &id006 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ">="
@@ -110,12 +110,12 @@ dependencies:
110
110
  segments:
111
111
  - 0
112
112
  version: "0"
113
- type: :runtime
114
- version_requirements: *id006
113
+ name: acts_as_rails3_generator
114
+ requirement: *id006
115
115
  - !ruby/object:Gem::Dependency
116
- name: posix-spawn
116
+ type: :runtime
117
117
  prerelease: false
118
- requirement: &id007 !ruby/object:Gem::Requirement
118
+ version_requirements: &id007 !ruby/object:Gem::Requirement
119
119
  none: false
120
120
  requirements:
121
121
  - - ">="
@@ -126,12 +126,12 @@ dependencies:
126
126
  - 3
127
127
  - 6
128
128
  version: 0.3.6
129
- type: :runtime
130
- version_requirements: *id007
129
+ name: posix-spawn
130
+ requirement: *id007
131
131
  - !ruby/object:Gem::Dependency
132
- name: shoulda
132
+ type: :development
133
133
  prerelease: false
134
- requirement: &id008 !ruby/object:Gem::Requirement
134
+ version_requirements: &id008 !ruby/object:Gem::Requirement
135
135
  none: false
136
136
  requirements:
137
137
  - - ">="
@@ -140,12 +140,12 @@ dependencies:
140
140
  segments:
141
141
  - 0
142
142
  version: "0"
143
- type: :development
144
- version_requirements: *id008
143
+ name: shoulda
144
+ requirement: *id008
145
145
  - !ruby/object:Gem::Dependency
146
- name: rack-test
146
+ type: :development
147
147
  prerelease: false
148
- requirement: &id009 !ruby/object:Gem::Requirement
148
+ version_requirements: &id009 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ">="
@@ -154,12 +154,12 @@ dependencies:
154
154
  segments:
155
155
  - 0
156
156
  version: "0"
157
- type: :development
158
- version_requirements: *id009
157
+ name: rack-test
158
+ requirement: *id009
159
159
  - !ruby/object:Gem::Dependency
160
- name: flexmock
160
+ type: :development
161
161
  prerelease: false
162
- requirement: &id010 !ruby/object:Gem::Requirement
162
+ version_requirements: &id010 !ruby/object:Gem::Requirement
163
163
  none: false
164
164
  requirements:
165
165
  - - ">="
@@ -168,12 +168,12 @@ dependencies:
168
168
  segments:
169
169
  - 0
170
170
  version: "0"
171
- type: :development
172
- version_requirements: *id010
171
+ name: flexmock
172
+ requirement: *id010
173
173
  - !ruby/object:Gem::Dependency
174
- name: rvm
174
+ type: :development
175
175
  prerelease: false
176
- requirement: &id011 !ruby/object:Gem::Requirement
176
+ version_requirements: &id011 !ruby/object:Gem::Requirement
177
177
  none: false
178
178
  requirements:
179
179
  - - ">="
@@ -182,12 +182,12 @@ dependencies:
182
182
  segments:
183
183
  - 0
184
184
  version: "0"
185
- type: :development
186
- version_requirements: *id011
185
+ name: rvm
186
+ requirement: *id011
187
187
  - !ruby/object:Gem::Dependency
188
- name: rake
188
+ type: :development
189
189
  prerelease: false
190
- requirement: &id012 !ruby/object:Gem::Requirement
190
+ version_requirements: &id012 !ruby/object:Gem::Requirement
191
191
  none: false
192
192
  requirements:
193
193
  - - "="
@@ -198,12 +198,12 @@ dependencies:
198
198
  - 8
199
199
  - 7
200
200
  version: 0.8.7
201
- type: :development
202
- version_requirements: *id012
201
+ name: rake
202
+ requirement: *id012
203
203
  - !ruby/object:Gem::Dependency
204
- name: bundler
204
+ type: :development
205
205
  prerelease: false
206
- requirement: &id013 !ruby/object:Gem::Requirement
206
+ version_requirements: &id013 !ruby/object:Gem::Requirement
207
207
  none: false
208
208
  requirements:
209
209
  - - ">="
@@ -212,12 +212,12 @@ dependencies:
212
212
  segments:
213
213
  - 0
214
214
  version: "0"
215
- type: :development
216
- version_requirements: *id013
215
+ name: bundler
216
+ requirement: *id013
217
217
  - !ruby/object:Gem::Dependency
218
- name: guard
218
+ type: :development
219
219
  prerelease: false
220
- requirement: &id014 !ruby/object:Gem::Requirement
220
+ version_requirements: &id014 !ruby/object:Gem::Requirement
221
221
  none: false
222
222
  requirements:
223
223
  - - ">="
@@ -226,12 +226,12 @@ dependencies:
226
226
  segments:
227
227
  - 0
228
228
  version: "0"
229
- type: :development
230
- version_requirements: *id014
229
+ name: guard
230
+ requirement: *id014
231
231
  - !ruby/object:Gem::Dependency
232
- name: guard-test
232
+ type: :development
233
233
  prerelease: false
234
- requirement: &id015 !ruby/object:Gem::Requirement
234
+ version_requirements: &id015 !ruby/object:Gem::Requirement
235
235
  none: false
236
236
  requirements:
237
237
  - - ">="
@@ -240,8 +240,8 @@ dependencies:
240
240
  segments:
241
241
  - 0
242
242
  version: "0"
243
- type: :development
244
- version_requirements: *id015
243
+ name: guard-test
244
+ requirement: *id015
245
245
  description: Testbot is a test distribution tool that works with Rails, RSpec, RSpec2, Test::Unit and Cucumber.
246
246
  email:
247
247
  - joakim.kolsjo@gmail.com