buildr 1.3.3-java → 1.3.4-java
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/CHANGELOG +76 -0
- data/NOTICE +1 -1
- data/README.rdoc +9 -21
- data/Rakefile +17 -34
- data/_buildr +3 -12
- data/{doc/print.toc.yaml → _jbuildr} +14 -14
- data/addon/buildr/cobertura.rb +5 -219
- data/addon/buildr/drb.rb +281 -0
- data/addon/buildr/emma.rb +5 -221
- data/addon/buildr/nailgun.rb +93 -689
- data/bin/buildr +0 -9
- data/buildr.buildfile +4 -4
- data/buildr.gemspec +27 -21
- data/doc/_layouts/default.html +82 -0
- data/doc/_layouts/preface.html +22 -0
- data/doc/{pages/artifacts.textile → artifacts.textile} +82 -42
- data/doc/{pages/building.textile → building.textile} +89 -47
- data/doc/{pages/contributing.textile → contributing.textile} +53 -45
- data/doc/css/default.css +6 -5
- data/doc/css/print.css +17 -24
- data/doc/css/syntax.css +7 -36
- data/doc/download.textile +68 -0
- data/doc/{pages/extending.textile → extending.textile} +45 -24
- data/doc/{pages/getting_started.textile → getting_started.textile} +158 -88
- data/doc/images/asf-logo.gif +0 -0
- data/doc/images/note.png +0 -0
- data/doc/index.textile +47 -0
- data/doc/{pages/languages.textile → languages.textile} +108 -54
- data/doc/mailing_lists.textile +25 -0
- data/doc/{pages/more_stuff.textile → more_stuff.textile} +152 -73
- data/doc/{pages/packaging.textile → packaging.textile} +181 -96
- data/doc/preface.textile +28 -0
- data/doc/{pages/projects.textile → projects.textile} +55 -40
- data/doc/scripts/buildr-git.rb +364 -264
- data/doc/scripts/gitflow.rb +296 -0
- data/doc/scripts/install-jruby.sh +2 -2
- data/doc/scripts/install-linux.sh +6 -6
- data/doc/scripts/install-osx.sh +2 -2
- data/doc/{pages/settings_profiles.textile → settings_profiles.textile} +83 -45
- data/doc/{pages/testing.textile → testing.textile} +77 -41
- data/lib/buildr.rb +5 -5
- data/lib/buildr/core.rb +2 -0
- data/lib/buildr/core/application.rb +321 -151
- data/lib/buildr/core/build.rb +298 -167
- data/lib/buildr/core/checks.rb +4 -132
- data/lib/buildr/core/common.rb +1 -5
- data/lib/buildr/core/compile.rb +3 -9
- data/lib/buildr/core/environment.rb +12 -3
- data/lib/buildr/core/filter.rb +20 -18
- data/lib/buildr/core/generate.rb +36 -36
- data/lib/buildr/core/help.rb +2 -1
- data/lib/buildr/core/osx.rb +46 -0
- data/lib/buildr/core/progressbar.rb +1 -1
- data/lib/buildr/core/project.rb +7 -34
- data/lib/buildr/core/test.rb +12 -6
- data/lib/buildr/core/transports.rb +13 -11
- data/lib/buildr/core/util.rb +14 -23
- data/lib/buildr/groovy/bdd.rb +3 -2
- data/lib/buildr/groovy/compiler.rb +1 -1
- data/lib/buildr/ide/eclipse.rb +31 -21
- data/lib/buildr/ide/idea.rb +3 -2
- data/lib/buildr/ide/idea7x.rb +6 -4
- data/lib/buildr/java/ant.rb +3 -1
- data/lib/buildr/java/bdd.rb +9 -7
- data/lib/buildr/java/cobertura.rb +243 -0
- data/lib/buildr/java/compiler.rb +5 -4
- data/lib/buildr/java/emma.rb +244 -0
- data/lib/buildr/java/packaging.rb +11 -8
- data/lib/buildr/java/pom.rb +0 -4
- data/lib/buildr/java/rjb.rb +1 -1
- data/lib/buildr/java/test_result.rb +5 -7
- data/lib/buildr/java/tests.rb +17 -11
- data/lib/buildr/packaging.rb +5 -2
- data/lib/buildr/packaging/archive.rb +488 -0
- data/lib/buildr/packaging/artifact.rb +48 -29
- data/lib/buildr/packaging/artifact_namespace.rb +6 -6
- data/lib/buildr/packaging/gems.rb +4 -4
- data/lib/buildr/packaging/package.rb +3 -2
- data/lib/buildr/packaging/tar.rb +85 -3
- data/lib/buildr/packaging/version_requirement.rb +172 -0
- data/lib/buildr/packaging/zip.rb +24 -682
- data/lib/buildr/packaging/ziptask.rb +313 -0
- data/lib/buildr/scala.rb +5 -0
- data/lib/buildr/scala/bdd.rb +100 -0
- data/lib/buildr/scala/compiler.rb +45 -4
- data/lib/buildr/scala/tests.rb +12 -59
- data/rakelib/checks.rake +57 -0
- data/rakelib/doc.rake +58 -68
- data/rakelib/jekylltask.rb +110 -0
- data/rakelib/package.rake +35 -37
- data/rakelib/release.rake +119 -35
- data/rakelib/rspec.rake +29 -39
- data/rakelib/setup.rake +21 -59
- data/rakelib/stage.rake +184 -26
- data/spec/addon/drb_spec.rb +328 -0
- data/spec/core/application_spec.rb +32 -25
- data/spec/core/build_spec.rb +336 -126
- data/spec/core/checks_spec.rb +292 -310
- data/spec/core/common_spec.rb +8 -2
- data/spec/core/compile_spec.rb +17 -1
- data/spec/core/generate_spec.rb +3 -3
- data/spec/core/project_spec.rb +18 -10
- data/spec/core/test_spec.rb +8 -1
- data/spec/core/transport_spec.rb +40 -3
- data/spec/core/util_spec.rb +67 -0
- data/spec/ide/eclipse_spec.rb +96 -28
- data/spec/ide/idea7x_spec.rb +84 -0
- data/spec/java/ant.rb +5 -0
- data/spec/java/bdd_spec.rb +12 -3
- data/spec/{addon → java}/cobertura_spec.rb +6 -6
- data/spec/{addon → java}/emma_spec.rb +5 -6
- data/spec/java/java_spec.rb +12 -2
- data/spec/java/packaging_spec.rb +31 -2
- data/spec/{addon → java}/test_coverage_spec.rb +3 -3
- data/spec/java/tests_spec.rb +5 -0
- data/spec/packaging/archive_spec.rb +11 -1
- data/spec/{core → packaging}/artifact_namespace_spec.rb +10 -2
- data/spec/packaging/artifact_spec.rb +44 -3
- data/spec/packaging/packaging_spec.rb +1 -1
- data/spec/sandbox.rb +17 -14
- data/spec/scala/bdd_spec.rb +150 -0
- data/spec/scala/compiler_spec.rb +27 -0
- data/spec/scala/scala.rb +38 -0
- data/spec/scala/tests_spec.rb +78 -33
- data/spec/spec_helpers.rb +29 -5
- data/spec/version_requirement_spec.rb +6 -0
- metadata +176 -172
- data/DISCLAIMER +0 -7
- data/doc/images/apache-incubator-logo.png +0 -0
- data/doc/pages/download.textile +0 -51
- data/doc/pages/index.textile +0 -42
- data/doc/pages/mailing_lists.textile +0 -17
- data/doc/pages/recipes.textile +0 -103
- data/doc/pages/troubleshooting.textile +0 -103
- data/doc/pages/whats_new.textile +0 -323
- data/doc/print.haml +0 -51
- data/doc/site.haml +0 -56
- data/doc/site.toc.yaml +0 -47
- data/etc/git-svn-authors +0 -16
- data/lib/buildr/core/application_cli.rb +0 -139
- data/rakelib/apache.rake +0 -191
- data/rakelib/changelog.rake +0 -57
- data/rakelib/rubyforge.rake +0 -53
- data/rakelib/scm.rake +0 -49
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with this
|
|
3
|
+
# work for additional information regarding copyright ownership. The ASF
|
|
4
|
+
# licenses this file to you under the Apache License, Version 2.0 (the
|
|
5
|
+
# "License"); you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
13
|
+
# License for the specific language governing permissions and limitations under
|
|
14
|
+
# the License.
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
require File.expand_path('../spec_helpers', File.dirname(__FILE__))
|
|
18
|
+
require 'stringio'
|
|
19
|
+
Sandbox.require_optional_extension 'buildr/drb'
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
describe Buildr::DRbApplication do
|
|
23
|
+
|
|
24
|
+
module DRbHelper
|
|
25
|
+
attr_accessor :app, :drb, :cfg
|
|
26
|
+
|
|
27
|
+
def use_stdio(stdin = nil, stdout = nil, stderr = nil)
|
|
28
|
+
stdin ||= StringIO.new
|
|
29
|
+
stdout ||= StringIO.new
|
|
30
|
+
stderr ||= StringIO.new
|
|
31
|
+
cfg.update :in => stdin, :out => stdout, :err => stderr
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def remote_run(*argv)
|
|
35
|
+
cfg.update :argv => argv
|
|
36
|
+
drb.remote_run(cfg)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def output
|
|
40
|
+
cfg[:out].string
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def write_buildfile(content = nil)
|
|
44
|
+
write 'buildfile', content || %q{
|
|
45
|
+
define('foo') do
|
|
46
|
+
|
|
47
|
+
rule '.rbc' => '.rb' do |t|
|
|
48
|
+
$stdout.puts "#{t.name} from #{t.source}"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
task('hello') do
|
|
52
|
+
$stdout.puts 'hi'
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
task('empty')
|
|
56
|
+
|
|
57
|
+
task('no') do
|
|
58
|
+
task('empty').enhance ['delete_me']
|
|
59
|
+
task('empty') { $stdout.puts 'no' }
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
task('delete_me')
|
|
63
|
+
|
|
64
|
+
task('create') do
|
|
65
|
+
Rake::Task.define_task('created')
|
|
66
|
+
rule '.rbc' => '.rb' do |t|
|
|
67
|
+
$stdout.puts "#{t.name} from #{t.source}"
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
task('exists') do
|
|
72
|
+
$stdout.puts !!Buildr.application.lookup('created')
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
task('setopt', :name, :value) do |task, args|
|
|
76
|
+
Buildr.application.options.send("#{args[:name]}=", args[:value])
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
}
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
include DRbHelper
|
|
84
|
+
|
|
85
|
+
before(:each) do
|
|
86
|
+
@in, @out, @err = $stdin, $stdout, $stderr
|
|
87
|
+
@cfg = {
|
|
88
|
+
:dir => Dir.pwd, :argv => [],
|
|
89
|
+
:in => @in, :out => @out, :err => @err
|
|
90
|
+
}
|
|
91
|
+
@drb = Buildr::DRbApplication.clone
|
|
92
|
+
@drb.send :setup
|
|
93
|
+
@app = Buildr.application
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
after(:each) do
|
|
97
|
+
$stdin, $stdout, $stderr = @in, @out, @err
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
describe '.run' do
|
|
101
|
+
it 'starts server if no server is running' do
|
|
102
|
+
drb.should_receive(:connect).and_raise DRb::DRbConnError
|
|
103
|
+
drb.should_receive(:run_server!)
|
|
104
|
+
drb.should_not_receive(:run_client)
|
|
105
|
+
drb.run
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it 'connects to an already started server' do
|
|
109
|
+
drb.should_receive(:connect).and_return "client"
|
|
110
|
+
drb.should_receive(:run_client).with "client"
|
|
111
|
+
drb.should_not_receive(:run_server!)
|
|
112
|
+
drb.run
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
describe '.remote_run' do
|
|
117
|
+
|
|
118
|
+
describe 'stdout' do
|
|
119
|
+
it 'is redirected to client' do
|
|
120
|
+
use_stdio
|
|
121
|
+
Buildr.application.should_receive(:remote_run) do
|
|
122
|
+
$stdout.puts "HELLO"
|
|
123
|
+
end
|
|
124
|
+
remote_run
|
|
125
|
+
output.should eql("HELLO\n")
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
describe 'stderr' do
|
|
130
|
+
it 'is redirected to client' do
|
|
131
|
+
use_stdio
|
|
132
|
+
Buildr.application.should_receive(:remote_run) do
|
|
133
|
+
$stderr.puts "HELLO"
|
|
134
|
+
end
|
|
135
|
+
remote_run
|
|
136
|
+
cfg[:err].string.should eql("HELLO\n")
|
|
137
|
+
end
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
describe 'stdin' do
|
|
141
|
+
it 'is redirected to client' do
|
|
142
|
+
use_stdio
|
|
143
|
+
cfg[:in].should_receive(:gets).and_return("HELLO\n")
|
|
144
|
+
result = nil
|
|
145
|
+
Buildr.application.should_receive(:remote_run) do
|
|
146
|
+
result = $stdin.gets
|
|
147
|
+
end
|
|
148
|
+
remote_run
|
|
149
|
+
result.should eql("HELLO\n")
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
describe 'server ARGV' do
|
|
154
|
+
it 'is replaced with client argv' do
|
|
155
|
+
Buildr.application.should_receive(:remote_run) do
|
|
156
|
+
ARGV.should eql(['hello'])
|
|
157
|
+
end
|
|
158
|
+
remote_run 'hello'
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
describe 'without buildfile loaded' do
|
|
163
|
+
before(:each) do
|
|
164
|
+
app.instance_eval { @rakefile = nil }
|
|
165
|
+
write_buildfile
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
it 'should load the buildfile' do
|
|
169
|
+
app.should_receive(:top_level)
|
|
170
|
+
lambda { remote_run }.should run_task('foo')
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
describe 'with unmodified buildfile' do
|
|
175
|
+
|
|
176
|
+
before(:each) do
|
|
177
|
+
write_buildfile
|
|
178
|
+
app.options.rakelib = []
|
|
179
|
+
app.send :load_buildfile
|
|
180
|
+
drb.save_snapshot(app)
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
it 'should not reload the buildfile' do
|
|
184
|
+
app.should_not_receive(:reload_buildfile)
|
|
185
|
+
app.should_receive(:top_level)
|
|
186
|
+
remote_run
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
it 'should not define projects again' do
|
|
190
|
+
use_stdio
|
|
191
|
+
lambda { 2.times { remote_run 'foo:hello' } }.should_not run_task('foo')
|
|
192
|
+
output.should eql("hi\nhi\n")
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
it 'should restore task actions' do
|
|
196
|
+
use_stdio
|
|
197
|
+
remote_run 'foo:empty'
|
|
198
|
+
output.should be_empty
|
|
199
|
+
2.times { remote_run 'foo:no' }
|
|
200
|
+
remote_run 'foo:empty'
|
|
201
|
+
actions = app.lookup('foo:empty').instance_eval { @actions }
|
|
202
|
+
actions.should be_empty # as originally defined
|
|
203
|
+
output.should be_empty
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
it 'should restore task prerequisites' do
|
|
207
|
+
use_stdio
|
|
208
|
+
remote_run 'foo:empty'
|
|
209
|
+
output.should be_empty
|
|
210
|
+
2.times { remote_run 'foo:no' }
|
|
211
|
+
remote_run 'foo:empty'
|
|
212
|
+
pres = app.lookup('foo:empty').send(:prerequisites).map(&:to_s)
|
|
213
|
+
pres.should be_empty # as originally defined
|
|
214
|
+
output.should be_empty
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
it 'should drop runtime created tasks' do
|
|
218
|
+
remote_run 'foo:create'
|
|
219
|
+
app.lookup('created').should_not be_nil
|
|
220
|
+
remote_run 'foo:empty'
|
|
221
|
+
app.lookup('created').should be_nil
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
it 'should restore options' do
|
|
225
|
+
remote_run 'foo:setopt[bar,baz]'
|
|
226
|
+
app.options.bar.should eql("baz")
|
|
227
|
+
remote_run 'foo:empty'
|
|
228
|
+
app.options.bar.should be_nil
|
|
229
|
+
end
|
|
230
|
+
|
|
231
|
+
it 'should restore rules' do
|
|
232
|
+
orig = app.instance_eval { @rules.size }
|
|
233
|
+
remote_run 'foo:create'
|
|
234
|
+
app.instance_eval { @rules.size }.should eql(orig + 1)
|
|
235
|
+
remote_run 'foo:empty'
|
|
236
|
+
app.instance_eval { @rules.size }.should eql(orig)
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
describe 'with modified buildfile' do
|
|
242
|
+
|
|
243
|
+
before(:each) do
|
|
244
|
+
write_buildfile
|
|
245
|
+
app.options.rakelib = []
|
|
246
|
+
app.send :load_buildfile
|
|
247
|
+
drb.save_snapshot(app)
|
|
248
|
+
app.instance_eval { @last_loaded = Time.now - 10 }
|
|
249
|
+
write_buildfile %q{
|
|
250
|
+
rule '.rbc' => '.rb' do |t|
|
|
251
|
+
$stdout.puts "#{t.name} from #{t.source}"
|
|
252
|
+
end
|
|
253
|
+
define('foo') do
|
|
254
|
+
task('hello') do
|
|
255
|
+
$stdout.puts 'bye'
|
|
256
|
+
end
|
|
257
|
+
task('empty')
|
|
258
|
+
define('bar') do
|
|
259
|
+
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
}
|
|
263
|
+
end
|
|
264
|
+
|
|
265
|
+
it 'should reload the buildfile' do
|
|
266
|
+
app.should_receive(:reload_buildfile)
|
|
267
|
+
app.should_receive(:top_level)
|
|
268
|
+
remote_run
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
it 'should redefine projects' do
|
|
272
|
+
lambda { remote_run }.should run_tasks('foo', 'foo:bar')
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
it 'should remove tasks deleted from buildfile' do
|
|
276
|
+
app.lookup('foo:delete_me').should_not be_nil
|
|
277
|
+
remote_run
|
|
278
|
+
app.lookup('foo:delete_me').should be_nil
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
it 'should redefine tasks actions' do
|
|
282
|
+
actions = app.lookup('foo:empty').instance_eval { @actions }
|
|
283
|
+
actions.should be_empty # no action
|
|
284
|
+
app.lookup('foo:no').invoke # enhance the empty task
|
|
285
|
+
actions = app.lookup('foo:empty').instance_eval { @actions }
|
|
286
|
+
actions.should_not be_empty
|
|
287
|
+
remote_run # cause to reload the buildfile
|
|
288
|
+
actions = app.lookup('foo:empty').instance_eval { @actions }
|
|
289
|
+
actions.should be_empty # as defined on the new buildfile
|
|
290
|
+
end
|
|
291
|
+
|
|
292
|
+
it 'should redefine task prerequisites' do
|
|
293
|
+
pres = app.lookup('foo:empty').send(:prerequisites).map(&:to_s)
|
|
294
|
+
pres.should be_empty # no action
|
|
295
|
+
app.lookup('foo:no').invoke # enhance the empty task
|
|
296
|
+
pres = app.lookup('foo:empty').send(:prerequisites).map(&:to_s)
|
|
297
|
+
pres.should_not be_empty
|
|
298
|
+
remote_run # cause to reload the buildfile
|
|
299
|
+
pres = app.lookup('foo:empty').send(:prerequisites).map(&:to_s)
|
|
300
|
+
pres.should be_empty # as defined on the new buildfile
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
it 'should drop runtime created tasks' do
|
|
304
|
+
app.lookup('foo:create').invoke
|
|
305
|
+
app.lookup('created').should_not be_nil
|
|
306
|
+
remote_run 'foo:empty'
|
|
307
|
+
app.lookup('created').should be_nil
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
it 'should restore options' do
|
|
311
|
+
app.options.bar = 'baz'
|
|
312
|
+
remote_run 'foo:empty'
|
|
313
|
+
app.options.bar.should be_nil
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
it 'should redefine rules' do
|
|
317
|
+
orig = app.instance_eval { @rules.size }
|
|
318
|
+
app.lookup('foo:create').invoke
|
|
319
|
+
app.instance_eval { @rules.size }.should eql(orig + 1)
|
|
320
|
+
remote_run 'foo:empty'
|
|
321
|
+
app.instance_eval { @rules.size }.should eql(orig)
|
|
322
|
+
end
|
|
323
|
+
|
|
324
|
+
end
|
|
325
|
+
|
|
326
|
+
end
|
|
327
|
+
end
|
|
328
|
+
|
|
@@ -31,44 +31,58 @@ describe Buildr::Application do
|
|
|
31
31
|
|
|
32
32
|
describe '#run' do
|
|
33
33
|
it 'should execute *_load methods in order' do
|
|
34
|
-
|
|
35
|
-
order = [:find_buildfile, :load_gems, :load_artifacts, :load_tasks,
|
|
36
|
-
:load_requires, :load_buildfile, :load_imports, :top_level]
|
|
34
|
+
order = [:load_gems, :load_artifact_ns, :load_tasks, :raw_load_buildfile]
|
|
37
35
|
order.each { |method| Buildr.application.should_receive(method).ordered }
|
|
38
36
|
Buildr.application.stub!(:exit) # With this, shows the correct error instead of SystemExit.
|
|
39
37
|
Buildr.application.run
|
|
40
38
|
end
|
|
39
|
+
|
|
40
|
+
it 'should load imports after loading buildfile' do
|
|
41
|
+
method = Buildr.application.method(:raw_load_buildfile)
|
|
42
|
+
Buildr.application.should_receive(:raw_load_buildfile) do
|
|
43
|
+
Buildr.application.should_receive(:load_imports)
|
|
44
|
+
method.call
|
|
45
|
+
end
|
|
46
|
+
Buildr.application.stub!(:exit) # With this, shows the correct error instead of SystemExit.
|
|
47
|
+
Buildr.application.run
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'should evaluate all projects after loading buildfile' do
|
|
51
|
+
Buildr.application.should_receive(:load_imports) do
|
|
52
|
+
Buildr.should_receive(:projects)
|
|
53
|
+
end
|
|
54
|
+
Buildr.application.stub!(:exit) # With this, shows the correct error instead of SystemExit.
|
|
55
|
+
Buildr.application.run
|
|
56
|
+
end
|
|
41
57
|
end
|
|
42
58
|
|
|
43
59
|
describe 'environment' do
|
|
44
60
|
it 'should return value of BUILDR_ENV' do
|
|
45
61
|
ENV['BUILDR_ENV'] = 'qa'
|
|
46
|
-
Buildr
|
|
62
|
+
Buildr.application.environment.should eql('qa')
|
|
47
63
|
end
|
|
48
64
|
|
|
49
65
|
it 'should default to development' do
|
|
50
|
-
Buildr
|
|
66
|
+
Buildr.application.environment.should eql('development')
|
|
51
67
|
end
|
|
52
68
|
|
|
53
69
|
it 'should set environment name from -e argument' do
|
|
54
70
|
ARGV.push('-e', 'test')
|
|
55
|
-
Buildr
|
|
71
|
+
Buildr.application.send(:handle_options)
|
|
72
|
+
Buildr.application.environment.should eql('test')
|
|
56
73
|
ENV['BUILDR_ENV'].should eql('test')
|
|
57
74
|
end
|
|
58
75
|
|
|
59
76
|
it 'should be echoed to user' do
|
|
60
77
|
write 'buildfile'
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
after do
|
|
65
|
-
ENV['BUILDR_ENV'] = nil
|
|
78
|
+
ENV['BUILDR_ENV'] = 'spec'
|
|
79
|
+
Buildr.application.send(:handle_options)
|
|
80
|
+
lambda { Buildr.application.send :load_buildfile }.should show(%r{(in .*, spec)})
|
|
66
81
|
end
|
|
67
82
|
end
|
|
68
83
|
|
|
69
84
|
describe 'gems' do
|
|
70
85
|
before do
|
|
71
|
-
Buildr.application.private_methods(true).should include('load_gems')
|
|
72
86
|
class << Buildr.application
|
|
73
87
|
public :load_gems
|
|
74
88
|
end
|
|
@@ -77,8 +91,8 @@ describe Buildr::Application do
|
|
|
77
91
|
def load_with_yaml
|
|
78
92
|
write 'build.yaml', <<-YAML
|
|
79
93
|
gems:
|
|
80
|
-
-
|
|
81
|
-
-
|
|
94
|
+
- rake
|
|
95
|
+
- rspec >= 1.2
|
|
82
96
|
YAML
|
|
83
97
|
Buildr.application.load_gems
|
|
84
98
|
end
|
|
@@ -100,7 +114,7 @@ describe Buildr::Application do
|
|
|
100
114
|
|
|
101
115
|
it 'should parse Gem name correctly' do
|
|
102
116
|
load_with_yaml
|
|
103
|
-
Buildr.application.gems.map(&:name).should include('
|
|
117
|
+
Buildr.application.gems.map(&:name).should include('rspec', 'rake')
|
|
104
118
|
end
|
|
105
119
|
|
|
106
120
|
it 'should find installed version of Gem' do
|
|
@@ -112,7 +126,6 @@ describe Buildr::Application do
|
|
|
112
126
|
|
|
113
127
|
describe 'load_gems' do
|
|
114
128
|
before do
|
|
115
|
-
Buildr.application.private_methods(true).should include('load_gems')
|
|
116
129
|
class << Buildr.application
|
|
117
130
|
public :load_gems
|
|
118
131
|
end
|
|
@@ -312,6 +325,9 @@ describe Buildr, 'settings' do
|
|
|
312
325
|
end
|
|
313
326
|
|
|
314
327
|
describe 'profile' do
|
|
328
|
+
before do
|
|
329
|
+
end
|
|
330
|
+
|
|
315
331
|
it 'should be empty hash if no profiles.yaml' do
|
|
316
332
|
Buildr.settings.profile.should == {}
|
|
317
333
|
end
|
|
@@ -376,15 +392,6 @@ describe Buildr, 'settings' do
|
|
|
376
392
|
Buildr.application.send :load_tasks
|
|
377
393
|
Buildr.application.buildfile.timestamp.should be_close(@buildfile_time + 5, 1)
|
|
378
394
|
end
|
|
379
|
-
|
|
380
|
-
it 'should include explicitly required files as dependencies' do
|
|
381
|
-
write 'some/file.rb'; File.utime(@buildfile_time + 5, @buildfile_time + 5, 'some/file.rb')
|
|
382
|
-
Buildr.application.instance_variable_set(:@requires, ['rbconfig', 'some/file.rb'])
|
|
383
|
-
Buildr.application.send :load_buildfile
|
|
384
|
-
Buildr.application.buildfile.timestamp.should be_close(@buildfile_time + 5, 1)
|
|
385
|
-
Buildr.application.buildfile.prerequisites.should include(File.expand_path('some/file.rb'))
|
|
386
|
-
Buildr.application.buildfile.prerequisites.should_not include('rbconfig')
|
|
387
|
-
end
|
|
388
395
|
end
|
|
389
396
|
end
|
|
390
397
|
|
data/spec/core/build_spec.rb
CHANGED
|
@@ -169,6 +169,10 @@ describe Project, '#target' do
|
|
|
169
169
|
@project.layout[:target] = 'baz'
|
|
170
170
|
@project.target.should eql('baz')
|
|
171
171
|
end
|
|
172
|
+
|
|
173
|
+
it 'should be removed in version 1.5 since it was deprecated in version 1.3' do
|
|
174
|
+
Buildr::VERSION.should < '1.5'
|
|
175
|
+
end
|
|
172
176
|
end
|
|
173
177
|
|
|
174
178
|
|
|
@@ -190,226 +194,432 @@ describe Project, '#reports' do
|
|
|
190
194
|
@project.layout[:reports] = 'baz'
|
|
191
195
|
@project.reports.should eql('baz')
|
|
192
196
|
end
|
|
197
|
+
|
|
198
|
+
it 'should be removed in version 1.5 since it was deprecated in version 1.3' do
|
|
199
|
+
Buildr::VERSION.should < '1.5'
|
|
200
|
+
end
|
|
193
201
|
end
|
|
194
202
|
|
|
195
203
|
|
|
196
|
-
describe
|
|
197
|
-
|
|
204
|
+
describe Git do
|
|
205
|
+
describe '#uncommitted_files' do
|
|
206
|
+
it 'should return an empty array on a clean repository' do
|
|
207
|
+
Git.should_receive(:`).with('git status').and_return <<-EOF
|
|
208
|
+
# On branch master
|
|
209
|
+
nothing to commit (working directory clean)
|
|
210
|
+
EOF
|
|
211
|
+
Git.uncommitted_files.should be_empty
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
it 'should reject a dirty repository' do
|
|
215
|
+
Git.should_receive(:`).with('git status').and_return <<-EOF
|
|
216
|
+
# On branch master
|
|
217
|
+
#
|
|
218
|
+
# Changed but not updated:
|
|
219
|
+
# (use "git add <file>..." to update what will be committed)
|
|
220
|
+
# (use "git checkout -- <file>..." to discard changes in working directory)
|
|
221
|
+
#
|
|
222
|
+
# modified: lib/buildr.rb
|
|
223
|
+
# modified: spec/buildr_spec.rb
|
|
224
|
+
#
|
|
225
|
+
# Untracked files:
|
|
226
|
+
# (use "git add <file>..." to include in what will be committed)
|
|
227
|
+
#
|
|
228
|
+
# error.log
|
|
229
|
+
EOF
|
|
230
|
+
Git.uncommitted_files.should include('lib/buildr.rb', 'error.log')
|
|
231
|
+
end
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
describe '#remote' do
|
|
235
|
+
it 'should return the name of the corresponding remote' do
|
|
236
|
+
Git.should_receive(:git).with('config', '--get', 'branch.master.remote').and_return "origin\n"
|
|
237
|
+
Git.should_receive(:git).with('remote').and_return "upstream\norigin\n"
|
|
238
|
+
Git.send(:remote, 'master').should == 'origin'
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
it 'should return nil if no remote for the given branch' do
|
|
242
|
+
Git.should_receive(:git).with('config', '--get', 'branch.master.remote').and_return "\n"
|
|
243
|
+
Git.should_not_receive(:git).with('remote')
|
|
244
|
+
Git.send(:remote, 'master').should be_nil
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
describe '#current_branch' do
|
|
249
|
+
it 'should return the current branch' do
|
|
250
|
+
Git.should_receive(:git).with('branch').and_return(" master\n* a-clever-idea\n ze-great-idea")
|
|
251
|
+
Git.send(:current_branch).should == 'a-clever-idea'
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
end # of Git
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
describe Svn do
|
|
259
|
+
describe '#tag' do
|
|
260
|
+
it 'should remove any existing tag with the same name' do
|
|
261
|
+
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
|
|
262
|
+
Svn.stub!(:copy)
|
|
263
|
+
Svn.should_receive(:remove).with('http://my.repo.org/foo/tags/1.0.0', 'Removing old copy')
|
|
264
|
+
|
|
265
|
+
Svn.tag '1.0.0'
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
it 'should do an svn copy with the release version' do
|
|
269
|
+
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
|
|
270
|
+
Svn.stub!(:remove)
|
|
271
|
+
Svn.should_receive(:copy).with(Dir.pwd, 'http://my.repo.org/foo/tags/1.0.0', 'Release 1.0.0')
|
|
272
|
+
|
|
273
|
+
Svn.tag '1.0.0'
|
|
274
|
+
end
|
|
275
|
+
end
|
|
276
|
+
|
|
277
|
+
# Reference: http://svnbook.red-bean.com/en/1.4/svn.reposadmin.planning.html#svn.reposadmin.projects.chooselayout
|
|
278
|
+
describe '#tag_url' do
|
|
279
|
+
it 'should accept to tag foo/trunk' do
|
|
280
|
+
Svn.tag_url('http://my.repo.org/foo/trunk', '1.0.0').should == 'http://my.repo.org/foo/tags/1.0.0'
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
it 'should accept to tag foo/branches/1.0' do
|
|
284
|
+
Svn.tag_url('http://my.repo.org/foo/branches/1.0', '1.0.1').should == 'http://my.repo.org/foo/tags/1.0.1'
|
|
285
|
+
end
|
|
286
|
+
|
|
287
|
+
it 'should accept to tag trunk/foo' do
|
|
288
|
+
Svn.tag_url('http://my.repo.org/trunk/foo', '1.0.0').should == 'http://my.repo.org/tags/foo/1.0.0'
|
|
289
|
+
end
|
|
290
|
+
|
|
291
|
+
it 'should accept to tag branches/foo/1.0' do
|
|
292
|
+
Svn.tag_url('http://my.repo.org/branches/foo/1.0', '1.0.0').should == 'http://my.repo.org/tags/foo/1.0.0'
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
describe '#repo_url' do
|
|
296
|
+
it 'should extract the SVN URL from svn info' do
|
|
297
|
+
Svn.should_receive(:svn).and_return <<-XML
|
|
298
|
+
<?xml version="1.0"?>
|
|
299
|
+
<info>
|
|
300
|
+
<entry
|
|
301
|
+
kind="dir"
|
|
302
|
+
path="."
|
|
303
|
+
revision="724987">
|
|
304
|
+
<url>http://my.repo.org/foo/trunk</url>
|
|
305
|
+
<repository>
|
|
306
|
+
<root>http://my.repo.org</root>
|
|
307
|
+
<uuid>13f79535-47bb-0310-9956-ffa450edef68</uuid>
|
|
308
|
+
</repository>
|
|
309
|
+
<wc-info>
|
|
310
|
+
<schedule>normal</schedule>
|
|
311
|
+
<depth>infinity</depth>
|
|
312
|
+
</wc-info>
|
|
313
|
+
<commit
|
|
314
|
+
revision="724955">
|
|
315
|
+
<author>boisvert</author>
|
|
316
|
+
<date>2008-12-10T01:53:51.240936Z</date>
|
|
317
|
+
</commit>
|
|
318
|
+
</entry>
|
|
319
|
+
</info>
|
|
320
|
+
XML
|
|
321
|
+
Svn.repo_url.should == 'http://my.repo.org/foo/trunk'
|
|
322
|
+
end
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
end # of Buildr::Svn
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
describe 'a release process', :shared=>true do
|
|
331
|
+
|
|
198
332
|
describe '#make' do
|
|
199
333
|
before do
|
|
200
334
|
write 'buildfile', "VERSION_NUMBER = '1.0.0-SNAPSHOT'"
|
|
201
335
|
# Prevent a real call to a spawned buildr process.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
Svn.stub!(:copy)
|
|
207
|
-
Svn.stub!(:commit)
|
|
336
|
+
@release.stub!(:buildr)
|
|
337
|
+
@release.stub!(:check)
|
|
338
|
+
@release.should_receive(:ruby).with('-S', 'buildr', "_#{Buildr::VERSION}_", '--buildfile', File.expand_path('buildfile.next'),
|
|
339
|
+
'--environment', 'development', 'clean', 'upload', 'DEBUG=no')
|
|
208
340
|
end
|
|
209
341
|
|
|
210
342
|
it 'should tag a release with the release version' do
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
343
|
+
@release.stub!(:update_version_to_next)
|
|
344
|
+
@release.should_receive(:tag_release).with('1.0.0')
|
|
345
|
+
@release.make
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
it 'should not alter the buildfile before tagging' do
|
|
349
|
+
@release.stub!(:update_version_to_next)
|
|
350
|
+
@release.should_receive(:tag_release).with('1.0.0')
|
|
351
|
+
@release.make
|
|
352
|
+
file('buildfile').should contain('VERSION_NUMBER = "1.0.0"')
|
|
215
353
|
end
|
|
216
354
|
|
|
217
355
|
it 'should update the buildfile with the next version number' do
|
|
218
|
-
|
|
356
|
+
@release.stub!(:tag_release)
|
|
357
|
+
@release.make
|
|
219
358
|
file('buildfile').should contain('VERSION_NUMBER = "1.0.1-SNAPSHOT"')
|
|
220
359
|
end
|
|
221
360
|
|
|
222
361
|
it 'should commit the updated buildfile' do
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
Release.make
|
|
362
|
+
@release.stub!(:tag_release)
|
|
363
|
+
@release.make
|
|
364
|
+
file('buildfile').should contain('VERSION_NUMBER = "1.0.1-SNAPSHOT"')
|
|
227
365
|
end
|
|
228
366
|
end
|
|
229
367
|
|
|
230
|
-
|
|
231
|
-
describe '#check' do
|
|
368
|
+
describe '#resolve_tag' do
|
|
232
369
|
before do
|
|
233
|
-
|
|
234
|
-
end
|
|
235
|
-
|
|
236
|
-
it 'should accept to release from the trunk' do
|
|
237
|
-
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
|
|
238
|
-
lambda { Release.check }.should_not raise_error
|
|
370
|
+
@release.stub!(:extract_version).and_return('1.0.0')
|
|
239
371
|
end
|
|
240
372
|
|
|
241
|
-
it 'should
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
end
|
|
245
|
-
|
|
246
|
-
it 'should reject releasing from a tag' do
|
|
247
|
-
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/tags/1.0.0')
|
|
248
|
-
lambda { Release.check }.should raise_error(RuntimeError, "SVN URL must contain 'trunk' or 'branches/...'")
|
|
373
|
+
it 'should return tag specified by tag_name' do
|
|
374
|
+
@release.tag_name = 'first'
|
|
375
|
+
@release.send(:resolve_tag).should == 'first'
|
|
249
376
|
end
|
|
250
|
-
|
|
251
|
-
it 'should
|
|
252
|
-
|
|
253
|
-
|
|
377
|
+
|
|
378
|
+
it 'should use tag returned by tag_name if tag_name is a proc' do
|
|
379
|
+
@release.tag_name = lambda { |version| "buildr-#{version}" }
|
|
380
|
+
@release.send(:resolve_tag).should == 'buildr-1.0.0'
|
|
254
381
|
end
|
|
382
|
+
after { @release.tag_name = nil }
|
|
383
|
+
end
|
|
255
384
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
lambda {
|
|
260
|
-
"Uncommitted SVN files violate the First Principle Of Release!\n" +
|
|
261
|
-
"M foo.rb")
|
|
385
|
+
describe '#tag_release' do
|
|
386
|
+
it 'should inform the user' do
|
|
387
|
+
@release.stub!(:extract_version).and_return('1.0.0')
|
|
388
|
+
lambda { @release.tag_release('1.0.0') }.should show_info('Tagging release 1.0.0')
|
|
262
389
|
end
|
|
263
390
|
end
|
|
264
|
-
|
|
265
|
-
|
|
391
|
+
|
|
266
392
|
describe '#extract_version' do
|
|
267
393
|
it 'should extract VERSION_NUMBER with single quotes' do
|
|
268
394
|
write 'buildfile', "VERSION_NUMBER = '1.0.0-SNAPSHOT'"
|
|
269
|
-
|
|
395
|
+
@release.extract_version.should == '1.0.0-SNAPSHOT'
|
|
270
396
|
end
|
|
271
397
|
|
|
272
398
|
it 'should extract VERSION_NUMBER with double quotes' do
|
|
273
399
|
write 'buildfile', %{VERSION_NUMBER = "1.0.1-SNAPSHOT"}
|
|
274
|
-
|
|
400
|
+
@release.extract_version.should == '1.0.1-SNAPSHOT'
|
|
275
401
|
end
|
|
276
402
|
|
|
277
403
|
it 'should extract VERSION_NUMBER without any spaces' do
|
|
278
404
|
write 'buildfile', "VERSION_NUMBER='1.0.2-SNAPSHOT'"
|
|
279
|
-
|
|
405
|
+
@release.extract_version.should == '1.0.2-SNAPSHOT'
|
|
280
406
|
end
|
|
281
407
|
|
|
282
408
|
it 'should extract THIS_VERSION as an alternative to VERSION_NUMBER' do
|
|
283
409
|
write 'buildfile', "THIS_VERSION = '1.0.3-SNAPSHOT'"
|
|
284
|
-
|
|
410
|
+
@release.extract_version.should == '1.0.3-SNAPSHOT'
|
|
285
411
|
end
|
|
286
412
|
|
|
287
413
|
it 'should complain if no current version number' do
|
|
288
414
|
write 'buildfile', 'define foo'
|
|
289
|
-
lambda {
|
|
415
|
+
lambda { @release.extract_version }.should raise_error('Looking for THIS_VERSION = "..." in your Buildfile, none found')
|
|
290
416
|
end
|
|
291
417
|
end
|
|
292
418
|
|
|
419
|
+
describe '#with_release_candidate_version' do
|
|
420
|
+
before do
|
|
421
|
+
Buildr.application.stub!(:buildfile).and_return(file('buildfile'))
|
|
422
|
+
write 'buildfile', "THIS_VERSION = '1.1.0-SNAPSHOT'"
|
|
423
|
+
end
|
|
424
|
+
|
|
425
|
+
it 'should yield the name of the release candidate buildfile' do
|
|
426
|
+
@release.send :with_release_candidate_version do |new_filename|
|
|
427
|
+
File.read(new_filename).should == %{THIS_VERSION = "1.1.0"}
|
|
428
|
+
end
|
|
429
|
+
end
|
|
293
430
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
431
|
+
it 'should yield a name different from the original buildfile' do
|
|
432
|
+
@release.send :with_release_candidate_version do |new_filename|
|
|
433
|
+
new_filename.should_not point_to_path('buildfile')
|
|
434
|
+
end
|
|
298
435
|
end
|
|
436
|
+
end
|
|
299
437
|
|
|
300
|
-
|
|
301
|
-
|
|
438
|
+
describe '#update_version_to_next' do
|
|
439
|
+
before do
|
|
440
|
+
write 'buildfile', 'THIS_VERSION = "1.0.0"'
|
|
302
441
|
end
|
|
303
442
|
|
|
304
|
-
it 'should
|
|
305
|
-
|
|
443
|
+
it 'should update the buildfile with a new version number' do
|
|
444
|
+
@release.send :update_version_to_next
|
|
445
|
+
file('buildfile').should contain('THIS_VERSION = "1.0.1-SNAPSHOT"')
|
|
306
446
|
end
|
|
307
447
|
|
|
308
|
-
it 'should
|
|
309
|
-
|
|
448
|
+
it 'should commit the new buildfile on the trunk' do
|
|
449
|
+
@release.should_receive(:message).and_return('Changed version number to 1.0.1-SNAPSHOT')
|
|
450
|
+
@release.update_version_to_next
|
|
310
451
|
end
|
|
311
|
-
|
|
312
|
-
it 'should use
|
|
313
|
-
|
|
314
|
-
|
|
452
|
+
|
|
453
|
+
it 'should use the commit message specified by commit_message' do
|
|
454
|
+
@release.commit_message = 'Here is my custom message'
|
|
455
|
+
@release.should_receive(:message).and_return('Here is my custom message')
|
|
456
|
+
@release.update_version_to_next
|
|
315
457
|
end
|
|
316
458
|
|
|
317
|
-
it 'should use
|
|
318
|
-
|
|
319
|
-
|
|
459
|
+
it 'should use the commit message returned by commit_message if commit_message is a proc' do
|
|
460
|
+
@release.commit_message = lambda { |new_version|
|
|
461
|
+
new_version.should == '1.0.1-SNAPSHOT'
|
|
462
|
+
"increment version number to #{new_version}"
|
|
463
|
+
}
|
|
464
|
+
@release.should_receive(:message).and_return('increment version number to 1.0.1-SNAPSHOT')
|
|
465
|
+
@release.update_version_to_next
|
|
466
|
+
end
|
|
467
|
+
|
|
468
|
+
it 'should inform the user of the new version' do
|
|
469
|
+
lambda { @release.update_version_to_next }.should show_info('Current version is now 1.0.1-SNAPSHOT')
|
|
320
470
|
end
|
|
321
|
-
|
|
322
|
-
after { Release.tag_name = nil }
|
|
323
471
|
end
|
|
324
472
|
|
|
473
|
+
end
|
|
325
474
|
|
|
326
|
-
|
|
475
|
+
|
|
476
|
+
describe GitRelease do
|
|
477
|
+
it_should_behave_like 'a release process'
|
|
478
|
+
|
|
479
|
+
before do
|
|
480
|
+
@release = GitRelease.new
|
|
481
|
+
Git.stub!(:git)
|
|
482
|
+
Git.stub!(:current_branch).and_return('master')
|
|
483
|
+
end
|
|
484
|
+
|
|
485
|
+
describe '#applies_to?' do
|
|
486
|
+
it 'should reject a non-git repo' do
|
|
487
|
+
GitRelease.applies_to?.should be_false
|
|
488
|
+
end
|
|
489
|
+
|
|
490
|
+
it 'should accept a git repo' do
|
|
491
|
+
FileUtils.mkdir '.git'
|
|
492
|
+
FileUtils.touch File.join('.git', 'config')
|
|
493
|
+
GitRelease.applies_to?.should be_true
|
|
494
|
+
end
|
|
495
|
+
end
|
|
496
|
+
|
|
497
|
+
describe '#release_check' do
|
|
327
498
|
before do
|
|
328
|
-
|
|
329
|
-
write 'buildfile', "THIS_VERSION = '1.1.0-SNAPSHOT'"
|
|
499
|
+
@release = GitRelease.new
|
|
330
500
|
end
|
|
331
501
|
|
|
332
|
-
it 'should
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
502
|
+
it 'should accept a clean repository' do
|
|
503
|
+
Git.should_receive(:`).with('git status').and_return <<-EOF
|
|
504
|
+
# On branch master
|
|
505
|
+
nothing to commit (working directory clean)
|
|
506
|
+
EOF
|
|
507
|
+
Git.should_receive(:remote).and_return('master')
|
|
508
|
+
lambda { @release.check }.should_not raise_error
|
|
336
509
|
end
|
|
337
510
|
|
|
338
|
-
it 'should
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
511
|
+
it 'should reject a dirty repository' do
|
|
512
|
+
Git.should_receive(:`).with('git status').and_return <<-EOF
|
|
513
|
+
# On branch master
|
|
514
|
+
# Untracked files:
|
|
515
|
+
# (use "git add <file>..." to include in what will be committed)
|
|
516
|
+
#
|
|
517
|
+
# foo.temp
|
|
518
|
+
EOF
|
|
519
|
+
lambda { @release.check }.should raise_error(RuntimeError, /uncommitted files/i)
|
|
342
520
|
end
|
|
343
|
-
end
|
|
344
521
|
|
|
522
|
+
it 'should reject a repository not tracking remote branch' do
|
|
523
|
+
Git.should_receive(:uncommitted_files).and_return([])
|
|
524
|
+
Git.should_receive(:remote).and_return(nil)
|
|
525
|
+
lambda{ @release.check }.should raise_error(RuntimeError,
|
|
526
|
+
"You are releasing from a local branch that does not track a remote!")
|
|
527
|
+
end
|
|
528
|
+
end
|
|
345
529
|
|
|
346
530
|
describe '#tag_release' do
|
|
347
531
|
before do
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
532
|
+
@release = GitRelease.new
|
|
533
|
+
@release.stub!(:extract_version).and_return('1.0.1')
|
|
534
|
+
@release.stub!(:resolve_tag).and_return('TEST_TAG')
|
|
535
|
+
Git.stub!(:git).with('tag', '-a', 'TEST_TAG', '-m', '[buildr] Cutting release TEST_TAG')
|
|
536
|
+
Git.stub!(:git).with('push', 'origin', 'tag', 'TEST_TAG')
|
|
537
|
+
Git.stub!(:commit)
|
|
538
|
+
Git.stub!(:push)
|
|
539
|
+
Git.stub!(:remote).and_return('origin')
|
|
352
540
|
end
|
|
353
541
|
|
|
354
|
-
it 'should tag the
|
|
355
|
-
|
|
356
|
-
|
|
542
|
+
it 'should delete any existing tag with the same name' do
|
|
543
|
+
Git.should_receive(:git).with('tag', '-d', 'TEST_TAG')
|
|
544
|
+
Git.should_receive(:git).with('push', 'origin', ':refs/tags/TEST_TAG')
|
|
545
|
+
@release.tag_release 'TEST_TAG'
|
|
357
546
|
end
|
|
358
547
|
|
|
359
|
-
it 'should
|
|
360
|
-
|
|
361
|
-
|
|
548
|
+
it 'should commit the buildfile before tagging' do
|
|
549
|
+
Git.should_receive(:commit).with(File.basename(Buildr.application.buildfile.to_s), "Changed version number to 1.0.1")
|
|
550
|
+
@release.tag_release 'TEST_TAG'
|
|
362
551
|
end
|
|
363
552
|
|
|
364
|
-
it 'should
|
|
365
|
-
|
|
366
|
-
|
|
553
|
+
it 'should push the tag if a remote is tracked' do
|
|
554
|
+
Git.should_receive(:git).with('tag', '-d', 'TEST_TAG')
|
|
555
|
+
Git.should_receive(:git).with('push', 'origin', ':refs/tags/TEST_TAG')
|
|
556
|
+
Git.should_receive(:git).with('tag', '-a', 'TEST_TAG', '-m', '[buildr] Cutting release TEST_TAG')
|
|
557
|
+
Git.should_receive(:git).with('push', 'origin', 'tag', 'TEST_TAG')
|
|
558
|
+
@release.tag_release 'TEST_TAG'
|
|
367
559
|
end
|
|
368
560
|
|
|
369
|
-
it 'should
|
|
370
|
-
|
|
561
|
+
it 'should NOT push the tag if no remote is tracked' do
|
|
562
|
+
Git.stub!(:remote).and_return(nil)
|
|
563
|
+
Git.should_not_receive(:git).with('push', 'origin', 'tag', 'TEST_TAG')
|
|
564
|
+
@release.tag_release 'TEST_TAG'
|
|
371
565
|
end
|
|
372
566
|
end
|
|
567
|
+
end
|
|
568
|
+
|
|
373
569
|
|
|
570
|
+
describe SvnRelease do
|
|
571
|
+
it_should_behave_like 'a release process'
|
|
374
572
|
|
|
375
|
-
|
|
573
|
+
before do
|
|
574
|
+
@release = SvnRelease.new
|
|
575
|
+
Svn.stub!(:svn)
|
|
576
|
+
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
|
|
577
|
+
Svn.stub!(:tag)
|
|
578
|
+
end
|
|
579
|
+
|
|
580
|
+
describe '#applies_to?' do
|
|
581
|
+
it 'should reject a non-git repo' do
|
|
582
|
+
SvnRelease.applies_to?.should be_false
|
|
583
|
+
end
|
|
584
|
+
|
|
585
|
+
it 'should accept a git repo' do
|
|
586
|
+
FileUtils.touch '.svn'
|
|
587
|
+
SvnRelease.applies_to?.should be_true
|
|
588
|
+
end
|
|
589
|
+
end
|
|
590
|
+
|
|
591
|
+
describe '#check' do
|
|
376
592
|
before do
|
|
377
|
-
|
|
378
|
-
|
|
593
|
+
Svn.stub!(:uncommitted_files).and_return([])
|
|
594
|
+
@release = SvnRelease.new
|
|
379
595
|
end
|
|
380
596
|
|
|
381
|
-
it 'should
|
|
382
|
-
|
|
383
|
-
|
|
597
|
+
it 'should accept to release from the trunk' do
|
|
598
|
+
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
|
|
599
|
+
lambda { @release.check }.should_not raise_error
|
|
384
600
|
end
|
|
385
601
|
|
|
386
|
-
it 'should
|
|
387
|
-
Svn.
|
|
388
|
-
|
|
602
|
+
it 'should accept to release from a branch' do
|
|
603
|
+
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/branches/1.0')
|
|
604
|
+
lambda { @release.check }.should_not raise_error
|
|
389
605
|
end
|
|
390
606
|
|
|
391
|
-
it 'should
|
|
392
|
-
|
|
607
|
+
it 'should reject releasing from a tag' do
|
|
608
|
+
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/tags/1.0.0')
|
|
609
|
+
lambda { @release.check }.should raise_error(RuntimeError, "SVN URL must contain 'trunk' or 'branches/...'")
|
|
393
610
|
end
|
|
394
|
-
end
|
|
395
|
-
|
|
396
|
-
end
|
|
397
611
|
|
|
612
|
+
it 'should reject a non standard repository layout' do
|
|
613
|
+
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/bar')
|
|
614
|
+
lambda { @release.check }.should raise_error(RuntimeError, "SVN URL must contain 'trunk' or 'branches/...'")
|
|
615
|
+
end
|
|
398
616
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
Revision: 112
|
|
407
|
-
Node Kind: directory
|
|
408
|
-
Schedule: normal
|
|
409
|
-
Last Changed Author: Lacton
|
|
410
|
-
Last Changed Rev: 110
|
|
411
|
-
Last Changed Date: 2008-08-19 12:00:00 +0200 (Tue, 19 Aug 2008)
|
|
412
|
-
EOF
|
|
413
|
-
Svn.repo_url.should == 'http://my.repo.org/foo/trunk'
|
|
617
|
+
it 'should reject an uncommitted file' do
|
|
618
|
+
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
|
|
619
|
+
Svn.stub!(:uncommitted_files).and_return(['foo.rb'])
|
|
620
|
+
lambda { @release.check }.should raise_error(RuntimeError,
|
|
621
|
+
"Uncommitted files violate the First Principle Of Release!\n" +
|
|
622
|
+
"foo.rb")
|
|
623
|
+
end
|
|
414
624
|
end
|
|
415
|
-
end
|
|
625
|
+
end
|