buildr 1.3.5-x86-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +998 -0
- data/LICENSE +176 -0
- data/NOTICE +26 -0
- data/README.rdoc +134 -0
- data/Rakefile +45 -0
- data/_buildr +29 -0
- data/_jbuildr +29 -0
- data/addon/buildr/antlr.rb +65 -0
- data/addon/buildr/cobertura.rb +22 -0
- data/addon/buildr/drb.rb +281 -0
- data/addon/buildr/emma.rb +22 -0
- data/addon/buildr/hibernate.rb +142 -0
- data/addon/buildr/javacc.rb +85 -0
- data/addon/buildr/jdepend.rb +60 -0
- data/addon/buildr/jetty.rb +248 -0
- data/addon/buildr/jibx.rb +86 -0
- data/addon/buildr/nailgun.rb +221 -0
- data/addon/buildr/openjpa.rb +90 -0
- data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.java +41 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.java +144 -0
- data/addon/buildr/xmlbeans.rb +93 -0
- data/bin/buildr +19 -0
- data/buildr.buildfile +58 -0
- data/buildr.gemspec +65 -0
- data/doc/_config.yml +1 -0
- data/doc/_layouts/default.html +88 -0
- data/doc/_layouts/preface.html +22 -0
- data/doc/artifacts.textile +211 -0
- data/doc/building.textile +244 -0
- data/doc/contributing.textile +252 -0
- data/doc/css/default.css +236 -0
- data/doc/css/print.css +101 -0
- data/doc/css/syntax.css +23 -0
- data/doc/download.textile +79 -0
- data/doc/extending.textile +186 -0
- data/doc/images/1442160941-frontcover.jpg +0 -0
- data/doc/images/asf-logo.gif +0 -0
- data/doc/images/asf-logo.png +0 -0
- data/doc/images/buildr-hires.png +0 -0
- data/doc/images/buildr.png +0 -0
- data/doc/images/favicon.png +0 -0
- data/doc/images/growl-icon.tiff +0 -0
- data/doc/images/note.png +0 -0
- data/doc/images/project-structure.png +0 -0
- data/doc/images/tip.png +0 -0
- data/doc/images/zbuildr.png +0 -0
- data/doc/images/zbuildr.tif +0 -0
- data/doc/index.textile +69 -0
- data/doc/installing.textile +266 -0
- data/doc/languages.textile +459 -0
- data/doc/mailing_lists.textile +25 -0
- data/doc/more_stuff.textile +457 -0
- data/doc/packaging.textile +430 -0
- data/doc/preface.textile +54 -0
- data/doc/projects.textile +271 -0
- data/doc/quick_start.textile +210 -0
- data/doc/scripts/buildr-git.rb +512 -0
- data/doc/scripts/gitflow.rb +296 -0
- data/doc/scripts/install-jruby.sh +44 -0
- data/doc/scripts/install-linux.sh +72 -0
- data/doc/scripts/install-osx.sh +52 -0
- data/doc/settings_profiles.textile +280 -0
- data/doc/testing.textile +222 -0
- data/etc/KEYS +151 -0
- data/lib/buildr.rb +36 -0
- data/lib/buildr/core.rb +35 -0
- data/lib/buildr/core/application.rb +656 -0
- data/lib/buildr/core/build.rb +452 -0
- data/lib/buildr/core/checks.rb +254 -0
- data/lib/buildr/core/common.rb +150 -0
- data/lib/buildr/core/compile.rb +608 -0
- data/lib/buildr/core/environment.rb +129 -0
- data/lib/buildr/core/filter.rb +362 -0
- data/lib/buildr/core/generate.rb +195 -0
- data/lib/buildr/core/help.rb +119 -0
- data/lib/buildr/core/osx.rb +46 -0
- data/lib/buildr/core/progressbar.rb +156 -0
- data/lib/buildr/core/project.rb +866 -0
- data/lib/buildr/core/shell.rb +198 -0
- data/lib/buildr/core/test.rb +723 -0
- data/lib/buildr/core/transports.rb +559 -0
- data/lib/buildr/core/util.rb +449 -0
- data/lib/buildr/groovy.rb +19 -0
- data/lib/buildr/groovy/bdd.rb +106 -0
- data/lib/buildr/groovy/compiler.rb +138 -0
- data/lib/buildr/groovy/shell.rb +48 -0
- data/lib/buildr/ide.rb +19 -0
- data/lib/buildr/ide/eclipse.rb +334 -0
- data/lib/buildr/ide/eclipse/java.rb +53 -0
- data/lib/buildr/ide/eclipse/plugin.rb +68 -0
- data/lib/buildr/ide/eclipse/scala.rb +66 -0
- data/lib/buildr/ide/idea.ipr.template +300 -0
- data/lib/buildr/ide/idea.rb +190 -0
- data/lib/buildr/ide/idea7x.ipr.template +290 -0
- data/lib/buildr/ide/idea7x.rb +212 -0
- data/lib/buildr/java.rb +23 -0
- data/lib/buildr/java/ant.rb +94 -0
- data/lib/buildr/java/bdd.rb +459 -0
- data/lib/buildr/java/cobertura.rb +274 -0
- data/lib/buildr/java/commands.rb +213 -0
- data/lib/buildr/java/compiler.rb +349 -0
- data/lib/buildr/java/deprecated.rb +141 -0
- data/lib/buildr/java/emma.rb +244 -0
- data/lib/buildr/java/jruby.rb +117 -0
- data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +137 -0
- data/lib/buildr/java/packaging.rb +716 -0
- data/lib/buildr/java/pom.rb +174 -0
- data/lib/buildr/java/rjb.rb +155 -0
- data/lib/buildr/java/test_result.rb +353 -0
- data/lib/buildr/java/tests.rb +333 -0
- data/lib/buildr/java/version_requirement.rb +172 -0
- data/lib/buildr/packaging.rb +24 -0
- data/lib/buildr/packaging/archive.rb +488 -0
- data/lib/buildr/packaging/artifact.rb +749 -0
- data/lib/buildr/packaging/artifact_namespace.rb +972 -0
- data/lib/buildr/packaging/artifact_search.rb +140 -0
- data/lib/buildr/packaging/gems.rb +102 -0
- data/lib/buildr/packaging/package.rb +238 -0
- data/lib/buildr/packaging/tar.rb +186 -0
- data/lib/buildr/packaging/version_requirement.rb +172 -0
- data/lib/buildr/packaging/zip.rb +73 -0
- data/lib/buildr/packaging/ziptask.rb +316 -0
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/scala.rb +25 -0
- data/lib/buildr/scala/bdd.rb +109 -0
- data/lib/buildr/scala/compiler.rb +195 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +35 -0
- data/lib/buildr/scala/shell.rb +55 -0
- data/lib/buildr/scala/tests.rb +157 -0
- data/lib/buildr/shell.rb +180 -0
- data/rakelib/checks.rake +57 -0
- data/rakelib/doc.rake +92 -0
- data/rakelib/jekylltask.rb +120 -0
- data/rakelib/package.rake +73 -0
- data/rakelib/release.rake +149 -0
- data/rakelib/rspec.rake +73 -0
- data/rakelib/setup.rake +54 -0
- data/rakelib/stage.rake +213 -0
- data/rakelib/stage.rake~ +213 -0
- data/spec/addon/drb_spec.rb +328 -0
- data/spec/core/application_spec.rb +502 -0
- data/spec/core/build_spec.rb +677 -0
- data/spec/core/checks_spec.rb +519 -0
- data/spec/core/common_spec.rb +670 -0
- data/spec/core/compile_spec.rb +583 -0
- data/spec/core/extension_spec.rb +93 -0
- data/spec/core/generate_spec.rb +33 -0
- data/spec/core/project_spec.rb +762 -0
- data/spec/core/test_spec.rb +1098 -0
- data/spec/core/transport_spec.rb +537 -0
- data/spec/core/util_spec.rb +67 -0
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/groovy/compiler_spec.rb +240 -0
- data/spec/ide/eclipse_spec.rb +501 -0
- data/spec/ide/idea7x_spec.rb +84 -0
- data/spec/java/ant_spec.rb +33 -0
- data/spec/java/bdd_spec.rb +382 -0
- data/spec/java/cobertura_spec.rb +85 -0
- data/spec/java/compiler_spec.rb +446 -0
- data/spec/java/emma_spec.rb +119 -0
- data/spec/java/java_spec.rb +124 -0
- data/spec/java/packaging_spec.rb +1134 -0
- data/spec/java/test_coverage_helper.rb +257 -0
- data/spec/java/tests_spec.rb +493 -0
- data/spec/packaging/archive_spec.rb +527 -0
- data/spec/packaging/artifact_namespace_spec.rb +654 -0
- data/spec/packaging/artifact_spec.rb +795 -0
- data/spec/packaging/packaging_helper.rb +63 -0
- data/spec/packaging/packaging_spec.rb +684 -0
- data/spec/sandbox.rb +142 -0
- data/spec/scala/bdd_spec.rb +119 -0
- data/spec/scala/compiler_spec.rb +284 -0
- data/spec/scala/scala.rb +38 -0
- data/spec/scala/tests_spec.rb +261 -0
- data/spec/spec_helpers.rb +340 -0
- data/spec/version_requirement_spec.rb +129 -0
- metadata +383 -0
@@ -0,0 +1,677 @@
|
|
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.join(File.dirname(__FILE__), '../spec_helpers')
|
18
|
+
|
19
|
+
|
20
|
+
describe 'local task', :shared=>true do
|
21
|
+
it "should execute task for project in current directory" do
|
22
|
+
define 'foobar'
|
23
|
+
lambda { @task.invoke }.should run_task("foobar:#{@task.name}")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should not execute task for projects in other directory" do
|
27
|
+
define 'foobar', :base_dir=>'elsewhere'
|
28
|
+
lambda { task('build').invoke }.should_not run_task('foobar:build')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
describe 'build task' do
|
34
|
+
it_should_behave_like 'local task'
|
35
|
+
before(:each) { @task = task('build') }
|
36
|
+
end
|
37
|
+
|
38
|
+
describe 'clean task' do
|
39
|
+
it_should_behave_like 'local task'
|
40
|
+
before(:each) { @task = task('clean') }
|
41
|
+
end
|
42
|
+
|
43
|
+
describe 'package task' do
|
44
|
+
it_should_behave_like 'local task'
|
45
|
+
before(:each) { @task = task('package') }
|
46
|
+
|
47
|
+
it 'should execute build task as prerequisite' do
|
48
|
+
lambda { @task.invoke }.should run_task('build')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe 'install task' do
|
53
|
+
it_should_behave_like 'local task'
|
54
|
+
before(:each) { @task = task('install') }
|
55
|
+
|
56
|
+
it 'should execute package task as prerequisite' do
|
57
|
+
lambda { @task.invoke }.should run_task('package')
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe 'uninstall task' do
|
62
|
+
it_should_behave_like 'local task'
|
63
|
+
before(:each) { @task = task('uninstall') }
|
64
|
+
end
|
65
|
+
|
66
|
+
describe 'upload task' do
|
67
|
+
it_should_behave_like 'local task'
|
68
|
+
before(:each) { @task = task('upload') }
|
69
|
+
|
70
|
+
it 'should execute package task as prerequisite' do
|
71
|
+
lambda { @task.invoke }.should run_task('package')
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
|
76
|
+
describe Project, '#build' do
|
77
|
+
it 'should return the project\'s build task' do
|
78
|
+
define('foo').build.should eql(task('foo:build'))
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should enhance the project\'s build task' do
|
82
|
+
task 'prereq'
|
83
|
+
task 'action'
|
84
|
+
define 'foo' do
|
85
|
+
build 'prereq' do
|
86
|
+
task('action').invoke
|
87
|
+
end
|
88
|
+
end
|
89
|
+
lambda { project('foo').build.invoke }.should run_tasks('prereq', 'action')
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should execute build task for sub-project' do
|
93
|
+
define 'foo' do
|
94
|
+
define 'bar'
|
95
|
+
end
|
96
|
+
lambda { task('foo:build').invoke }.should run_task('foo:bar:build')
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'should not execute build task of other projects' do
|
100
|
+
define 'foo'
|
101
|
+
define 'bar'
|
102
|
+
lambda { task('foo:build').invoke }.should_not run_task('bar:build')
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
describe Project, '#clean' do
|
108
|
+
it 'should return the project\'s clean task' do
|
109
|
+
define('foo').clean.should eql(task('foo:clean'))
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'should enhance the project\'s clean task' do
|
113
|
+
task 'prereq'
|
114
|
+
task 'action'
|
115
|
+
define 'foo' do
|
116
|
+
clean 'prereq' do
|
117
|
+
task('action').invoke
|
118
|
+
end
|
119
|
+
end
|
120
|
+
lambda { project('foo').clean.invoke }.should run_tasks('prereq', 'action')
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'should remove target directory' do
|
124
|
+
define 'foo' do
|
125
|
+
self.layout[:target] = 'targeted'
|
126
|
+
end
|
127
|
+
mkpath 'targeted'
|
128
|
+
lambda { project('foo').clean.invoke }.should change { File.exist?('targeted') }.from(true).to(false)
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'should remove reports directory' do
|
132
|
+
define 'foo' do
|
133
|
+
self.layout[:reports] = 'reported'
|
134
|
+
end
|
135
|
+
mkpath 'reported'
|
136
|
+
lambda { project('foo').clean.invoke }.should change { File.exist?('reported') }.from(true).to(false)
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'should execute clean task for sub-project' do
|
140
|
+
define 'foo' do
|
141
|
+
define 'bar'
|
142
|
+
end
|
143
|
+
lambda { task('foo:clean').invoke }.should run_task('foo:bar:clean')
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'should not execute clean task of other projects' do
|
147
|
+
define 'foo'
|
148
|
+
define 'bar'
|
149
|
+
lambda { task('foo:clean').invoke }.should_not run_task('bar:clean')
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
|
154
|
+
describe Project, '#target' do
|
155
|
+
before :each do
|
156
|
+
@project = define('foo', :layout=>Layout.new)
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'should default to target' do
|
160
|
+
@project.target.should eql('target')
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'should set layout :target' do
|
164
|
+
@project.target = 'bar'
|
165
|
+
@project.layout.expand(:target).should point_to_path('bar')
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'should come from layout :target' do
|
169
|
+
@project.layout[:target] = 'baz'
|
170
|
+
@project.target.should eql('baz')
|
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
|
176
|
+
end
|
177
|
+
|
178
|
+
|
179
|
+
describe Project, '#reports' do
|
180
|
+
before :each do
|
181
|
+
@project = define('foo', :layout=>Layout.new)
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'should default to reports' do
|
185
|
+
@project.reports.should eql('reports')
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'should set layout :reports' do
|
189
|
+
@project.reports = 'bar'
|
190
|
+
@project.layout.expand(:reports).should point_to_path('bar')
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'should come from layout :reports' do
|
194
|
+
@project.layout[:reports] = 'baz'
|
195
|
+
@project.reports.should eql('baz')
|
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
|
201
|
+
end
|
202
|
+
|
203
|
+
|
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, Git 1.4.2 or former' 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
|
+
|
233
|
+
it 'should reject a dirty repository, Git 1.4.3 or higher' do
|
234
|
+
Git.should_receive(:`).with('git status').and_return <<-EOF
|
235
|
+
# On branch master
|
236
|
+
# Changed but not updated:
|
237
|
+
# (use "git add <file>..." to update what will be committed)
|
238
|
+
#
|
239
|
+
#\tmodified: lib/buildr.rb
|
240
|
+
#\tmodified: spec/buildr_spec.rb
|
241
|
+
#
|
242
|
+
# Untracked files:
|
243
|
+
# (use "git add <file>..." to include in what will be committed)
|
244
|
+
#
|
245
|
+
#\terror.log
|
246
|
+
no changes added to commit (use "git add" and/or "git commit -a")
|
247
|
+
EOF
|
248
|
+
Git.uncommitted_files.should include('lib/buildr.rb', 'error.log')
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
describe '#remote' do
|
253
|
+
it 'should return the name of the corresponding remote' do
|
254
|
+
Git.should_receive(:git).with('config', '--get', 'branch.master.remote').and_return "origin\n"
|
255
|
+
Git.should_receive(:git).with('remote').and_return "upstream\norigin\n"
|
256
|
+
Git.send(:remote, 'master').should == 'origin'
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'should return nil if no remote for the given branch' do
|
260
|
+
Git.should_receive(:git).with('config', '--get', 'branch.master.remote').and_return "\n"
|
261
|
+
Git.should_not_receive(:git).with('remote')
|
262
|
+
Git.send(:remote, 'master').should be_nil
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
describe '#current_branch' do
|
267
|
+
it 'should return the current branch' do
|
268
|
+
Git.should_receive(:git).with('branch').and_return(" master\n* a-clever-idea\n ze-great-idea")
|
269
|
+
Git.send(:current_branch).should == 'a-clever-idea'
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
end # of Git
|
274
|
+
|
275
|
+
|
276
|
+
describe Svn do
|
277
|
+
describe '#tag' do
|
278
|
+
it 'should remove any existing tag with the same name' do
|
279
|
+
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
|
280
|
+
Svn.stub!(:copy)
|
281
|
+
Svn.should_receive(:remove).with('http://my.repo.org/foo/tags/1.0.0', 'Removing old copy')
|
282
|
+
|
283
|
+
Svn.tag '1.0.0'
|
284
|
+
end
|
285
|
+
|
286
|
+
it 'should do an svn copy with the release version' do
|
287
|
+
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
|
288
|
+
Svn.stub!(:remove)
|
289
|
+
Svn.should_receive(:copy).with(Dir.pwd, 'http://my.repo.org/foo/tags/1.0.0', 'Release 1.0.0')
|
290
|
+
|
291
|
+
Svn.tag '1.0.0'
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
# Reference: http://svnbook.red-bean.com/en/1.4/svn.reposadmin.planning.html#svn.reposadmin.projects.chooselayout
|
296
|
+
describe '#tag_url' do
|
297
|
+
it 'should accept to tag foo/trunk' do
|
298
|
+
Svn.tag_url('http://my.repo.org/foo/trunk', '1.0.0').should == 'http://my.repo.org/foo/tags/1.0.0'
|
299
|
+
end
|
300
|
+
|
301
|
+
it 'should accept to tag foo/branches/1.0' do
|
302
|
+
Svn.tag_url('http://my.repo.org/foo/branches/1.0', '1.0.1').should == 'http://my.repo.org/foo/tags/1.0.1'
|
303
|
+
end
|
304
|
+
|
305
|
+
it 'should accept to tag trunk/foo' do
|
306
|
+
Svn.tag_url('http://my.repo.org/trunk/foo', '1.0.0').should == 'http://my.repo.org/tags/foo/1.0.0'
|
307
|
+
end
|
308
|
+
|
309
|
+
it 'should accept to tag branches/foo/1.0' do
|
310
|
+
Svn.tag_url('http://my.repo.org/branches/foo/1.0', '1.0.0').should == 'http://my.repo.org/tags/foo/1.0.0'
|
311
|
+
end
|
312
|
+
|
313
|
+
describe '#repo_url' do
|
314
|
+
it 'should extract the SVN URL from svn info' do
|
315
|
+
Svn.should_receive(:svn).and_return <<-XML
|
316
|
+
<?xml version="1.0"?>
|
317
|
+
<info>
|
318
|
+
<entry
|
319
|
+
kind="dir"
|
320
|
+
path="."
|
321
|
+
revision="724987">
|
322
|
+
<url>http://my.repo.org/foo/trunk</url>
|
323
|
+
<repository>
|
324
|
+
<root>http://my.repo.org</root>
|
325
|
+
<uuid>13f79535-47bb-0310-9956-ffa450edef68</uuid>
|
326
|
+
</repository>
|
327
|
+
<wc-info>
|
328
|
+
<schedule>normal</schedule>
|
329
|
+
<depth>infinity</depth>
|
330
|
+
</wc-info>
|
331
|
+
<commit
|
332
|
+
revision="724955">
|
333
|
+
<author>boisvert</author>
|
334
|
+
<date>2008-12-10T01:53:51.240936Z</date>
|
335
|
+
</commit>
|
336
|
+
</entry>
|
337
|
+
</info>
|
338
|
+
XML
|
339
|
+
Svn.repo_url.should == 'http://my.repo.org/foo/trunk'
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
end
|
344
|
+
|
345
|
+
end # of Buildr::Svn
|
346
|
+
|
347
|
+
|
348
|
+
describe Release do
|
349
|
+
describe 'find' do
|
350
|
+
it 'should return GitRelease if project uses Git' do
|
351
|
+
write '.git/config'
|
352
|
+
Release.find.should be_instance_of(GitRelease)
|
353
|
+
end
|
354
|
+
|
355
|
+
it 'should return SvnRelease if project uses SVN' do
|
356
|
+
write '.svn/xml'
|
357
|
+
Release.find.should be_instance_of(SvnRelease)
|
358
|
+
end
|
359
|
+
|
360
|
+
it 'should return nil if no known release process' do
|
361
|
+
Dir.chdir(Dir.tmpdir) do
|
362
|
+
Release.find.should be_nil
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
366
|
+
after :each do
|
367
|
+
Release.instance_exec { @release = nil }
|
368
|
+
end
|
369
|
+
end
|
370
|
+
end
|
371
|
+
|
372
|
+
|
373
|
+
describe 'a release process', :shared=>true do
|
374
|
+
|
375
|
+
describe '#make' do
|
376
|
+
before do
|
377
|
+
write 'buildfile', "VERSION_NUMBER = '1.0.0-SNAPSHOT'"
|
378
|
+
# Prevent a real call to a spawned buildr process.
|
379
|
+
@release.stub!(:buildr)
|
380
|
+
@release.stub!(:check)
|
381
|
+
@release.should_receive(:ruby).with('-S', 'buildr', "_#{Buildr::VERSION}_", '--buildfile', File.expand_path('buildfile.next'),
|
382
|
+
'--environment', 'development', 'clean', 'upload', 'DEBUG=no')
|
383
|
+
end
|
384
|
+
|
385
|
+
it 'should tag a release with the release version' do
|
386
|
+
@release.stub!(:update_version_to_next)
|
387
|
+
@release.should_receive(:tag_release).with('1.0.0')
|
388
|
+
@release.make
|
389
|
+
end
|
390
|
+
|
391
|
+
it 'should not alter the buildfile before tagging' do
|
392
|
+
@release.stub!(:update_version_to_next)
|
393
|
+
@release.should_receive(:tag_release).with('1.0.0')
|
394
|
+
@release.make
|
395
|
+
file('buildfile').should contain('VERSION_NUMBER = "1.0.0"')
|
396
|
+
end
|
397
|
+
|
398
|
+
it 'should update the buildfile with the next version number' do
|
399
|
+
@release.stub!(:tag_release)
|
400
|
+
@release.make
|
401
|
+
file('buildfile').should contain('VERSION_NUMBER = "1.0.1-SNAPSHOT"')
|
402
|
+
end
|
403
|
+
|
404
|
+
it 'should keep leading zeros in the next version number' do
|
405
|
+
write 'buildfile', "VERSION_NUMBER = '1.0.001-SNAPSHOT'"
|
406
|
+
@release.stub!(:tag_release)
|
407
|
+
@release.make
|
408
|
+
file('buildfile').should contain('VERSION_NUMBER = "1.0.002-SNAPSHOT"')
|
409
|
+
end
|
410
|
+
|
411
|
+
it 'should commit the updated buildfile' do
|
412
|
+
@release.stub!(:tag_release)
|
413
|
+
@release.make
|
414
|
+
file('buildfile').should contain('VERSION_NUMBER = "1.0.1-SNAPSHOT"')
|
415
|
+
end
|
416
|
+
end
|
417
|
+
|
418
|
+
describe '#resolve_tag' do
|
419
|
+
before do
|
420
|
+
@release.stub!(:extract_version).and_return('1.0.0')
|
421
|
+
end
|
422
|
+
|
423
|
+
it 'should return tag specified by tag_name' do
|
424
|
+
@release.tag_name = 'first'
|
425
|
+
@release.send(:resolve_tag).should == 'first'
|
426
|
+
end
|
427
|
+
|
428
|
+
it 'should use tag returned by tag_name if tag_name is a proc' do
|
429
|
+
@release.tag_name = lambda { |version| "buildr-#{version}" }
|
430
|
+
@release.send(:resolve_tag).should == 'buildr-1.0.0'
|
431
|
+
end
|
432
|
+
after { @release.tag_name = nil }
|
433
|
+
end
|
434
|
+
|
435
|
+
describe '#tag_release' do
|
436
|
+
it 'should inform the user' do
|
437
|
+
@release.stub!(:extract_version).and_return('1.0.0')
|
438
|
+
lambda { @release.tag_release('1.0.0') }.should show_info('Tagging release 1.0.0')
|
439
|
+
end
|
440
|
+
end
|
441
|
+
|
442
|
+
describe '#extract_version' do
|
443
|
+
it 'should extract VERSION_NUMBER with single quotes' do
|
444
|
+
write 'buildfile', "VERSION_NUMBER = '1.0.0-SNAPSHOT'"
|
445
|
+
@release.extract_version.should == '1.0.0-SNAPSHOT'
|
446
|
+
end
|
447
|
+
|
448
|
+
it 'should extract VERSION_NUMBER with double quotes' do
|
449
|
+
write 'buildfile', %{VERSION_NUMBER = "1.0.1-SNAPSHOT"}
|
450
|
+
@release.extract_version.should == '1.0.1-SNAPSHOT'
|
451
|
+
end
|
452
|
+
|
453
|
+
it 'should extract VERSION_NUMBER without any spaces' do
|
454
|
+
write 'buildfile', "VERSION_NUMBER='1.0.2-SNAPSHOT'"
|
455
|
+
@release.extract_version.should == '1.0.2-SNAPSHOT'
|
456
|
+
end
|
457
|
+
|
458
|
+
it 'should extract THIS_VERSION as an alternative to VERSION_NUMBER' do
|
459
|
+
write 'buildfile', "THIS_VERSION = '1.0.3-SNAPSHOT'"
|
460
|
+
@release.extract_version.should == '1.0.3-SNAPSHOT'
|
461
|
+
end
|
462
|
+
|
463
|
+
it 'should complain if no current version number' do
|
464
|
+
write 'buildfile', 'define foo'
|
465
|
+
lambda { @release.extract_version }.should raise_error('Looking for THIS_VERSION = "..." in your Buildfile, none found')
|
466
|
+
end
|
467
|
+
end
|
468
|
+
|
469
|
+
describe '#with_release_candidate_version' do
|
470
|
+
before do
|
471
|
+
Buildr.application.stub!(:buildfile).and_return(file('buildfile'))
|
472
|
+
write 'buildfile', "THIS_VERSION = '1.1.0-SNAPSHOT'"
|
473
|
+
end
|
474
|
+
|
475
|
+
it 'should yield the name of the release candidate buildfile' do
|
476
|
+
@release.send :with_release_candidate_version do |new_filename|
|
477
|
+
File.read(new_filename).should == %{THIS_VERSION = "1.1.0"}
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
it 'should yield a name different from the original buildfile' do
|
482
|
+
@release.send :with_release_candidate_version do |new_filename|
|
483
|
+
new_filename.should_not point_to_path('buildfile')
|
484
|
+
end
|
485
|
+
end
|
486
|
+
end
|
487
|
+
|
488
|
+
describe '#update_version_to_next' do
|
489
|
+
before do
|
490
|
+
write 'buildfile', 'THIS_VERSION = "1.0.0"'
|
491
|
+
end
|
492
|
+
|
493
|
+
it 'should update the buildfile with a new version number' do
|
494
|
+
@release.send :update_version_to_next
|
495
|
+
file('buildfile').should contain('THIS_VERSION = "1.0.1-SNAPSHOT"')
|
496
|
+
end
|
497
|
+
|
498
|
+
it 'should commit the new buildfile on the trunk' do
|
499
|
+
@release.should_receive(:message).and_return('Changed version number to 1.0.1-SNAPSHOT')
|
500
|
+
@release.update_version_to_next
|
501
|
+
end
|
502
|
+
|
503
|
+
it 'should use the commit message specified by commit_message' do
|
504
|
+
@release.commit_message = 'Here is my custom message'
|
505
|
+
@release.should_receive(:message).and_return('Here is my custom message')
|
506
|
+
@release.update_version_to_next
|
507
|
+
end
|
508
|
+
|
509
|
+
it 'should use the commit message returned by commit_message if commit_message is a proc' do
|
510
|
+
@release.commit_message = lambda { |new_version|
|
511
|
+
new_version.should == '1.0.1-SNAPSHOT'
|
512
|
+
"increment version number to #{new_version}"
|
513
|
+
}
|
514
|
+
@release.should_receive(:message).and_return('increment version number to 1.0.1-SNAPSHOT')
|
515
|
+
@release.update_version_to_next
|
516
|
+
end
|
517
|
+
|
518
|
+
it 'should inform the user of the new version' do
|
519
|
+
lambda { @release.update_version_to_next }.should show_info('Current version is now 1.0.1-SNAPSHOT')
|
520
|
+
end
|
521
|
+
end
|
522
|
+
|
523
|
+
end
|
524
|
+
|
525
|
+
|
526
|
+
describe GitRelease do
|
527
|
+
it_should_behave_like 'a release process'
|
528
|
+
|
529
|
+
before do
|
530
|
+
@release = GitRelease.new
|
531
|
+
Git.stub!(:git)
|
532
|
+
Git.stub!(:current_branch).and_return('master')
|
533
|
+
end
|
534
|
+
|
535
|
+
describe '#applies_to?' do
|
536
|
+
it 'should reject a non-git repo' do
|
537
|
+
Dir.chdir(Dir.tmpdir) do
|
538
|
+
GitRelease.applies_to?.should be_false
|
539
|
+
end
|
540
|
+
end
|
541
|
+
|
542
|
+
it 'should accept a git repo' do
|
543
|
+
FileUtils.mkdir '.git'
|
544
|
+
FileUtils.touch File.join('.git', 'config')
|
545
|
+
GitRelease.applies_to?.should be_true
|
546
|
+
end
|
547
|
+
end
|
548
|
+
|
549
|
+
describe '#release_check' do
|
550
|
+
before do
|
551
|
+
@release = GitRelease.new
|
552
|
+
end
|
553
|
+
|
554
|
+
it 'should accept a clean repository' do
|
555
|
+
Git.should_receive(:`).with('git status').and_return <<-EOF
|
556
|
+
# On branch master
|
557
|
+
nothing to commit (working directory clean)
|
558
|
+
EOF
|
559
|
+
Git.should_receive(:remote).and_return('master')
|
560
|
+
lambda { @release.check }.should_not raise_error
|
561
|
+
end
|
562
|
+
|
563
|
+
it 'should reject a dirty repository' do
|
564
|
+
Git.should_receive(:`).with('git status').and_return <<-EOF
|
565
|
+
# On branch master
|
566
|
+
# Untracked files:
|
567
|
+
# (use "git add <file>..." to include in what will be committed)
|
568
|
+
#
|
569
|
+
# foo.temp
|
570
|
+
EOF
|
571
|
+
lambda { @release.check }.should raise_error(RuntimeError, /uncommitted files/i)
|
572
|
+
end
|
573
|
+
|
574
|
+
it 'should reject a repository not tracking remote branch' do
|
575
|
+
Git.should_receive(:uncommitted_files).and_return([])
|
576
|
+
Git.should_receive(:remote).and_return(nil)
|
577
|
+
lambda{ @release.check }.should raise_error(RuntimeError,
|
578
|
+
"You are releasing from a local branch that does not track a remote!")
|
579
|
+
end
|
580
|
+
end
|
581
|
+
|
582
|
+
describe '#tag_release' do
|
583
|
+
before do
|
584
|
+
@release = GitRelease.new
|
585
|
+
@release.stub!(:extract_version).and_return('1.0.1')
|
586
|
+
@release.stub!(:resolve_tag).and_return('TEST_TAG')
|
587
|
+
Git.stub!(:git).with('tag', '-a', 'TEST_TAG', '-m', '[buildr] Cutting release TEST_TAG')
|
588
|
+
Git.stub!(:git).with('push', 'origin', 'tag', 'TEST_TAG')
|
589
|
+
Git.stub!(:commit)
|
590
|
+
Git.stub!(:push)
|
591
|
+
Git.stub!(:remote).and_return('origin')
|
592
|
+
end
|
593
|
+
|
594
|
+
it 'should delete any existing tag with the same name' do
|
595
|
+
Git.should_receive(:git).with('tag', '-d', 'TEST_TAG')
|
596
|
+
Git.should_receive(:git).with('push', 'origin', ':refs/tags/TEST_TAG')
|
597
|
+
@release.tag_release 'TEST_TAG'
|
598
|
+
end
|
599
|
+
|
600
|
+
it 'should commit the buildfile before tagging' do
|
601
|
+
Git.should_receive(:commit).with(File.basename(Buildr.application.buildfile.to_s), "Changed version number to 1.0.1")
|
602
|
+
@release.tag_release 'TEST_TAG'
|
603
|
+
end
|
604
|
+
|
605
|
+
it 'should push the tag if a remote is tracked' do
|
606
|
+
Git.should_receive(:git).with('tag', '-d', 'TEST_TAG')
|
607
|
+
Git.should_receive(:git).with('push', 'origin', ':refs/tags/TEST_TAG')
|
608
|
+
Git.should_receive(:git).with('tag', '-a', 'TEST_TAG', '-m', '[buildr] Cutting release TEST_TAG')
|
609
|
+
Git.should_receive(:git).with('push', 'origin', 'tag', 'TEST_TAG')
|
610
|
+
@release.tag_release 'TEST_TAG'
|
611
|
+
end
|
612
|
+
|
613
|
+
it 'should NOT push the tag if no remote is tracked' do
|
614
|
+
Git.stub!(:remote).and_return(nil)
|
615
|
+
Git.should_not_receive(:git).with('push', 'origin', 'tag', 'TEST_TAG')
|
616
|
+
@release.tag_release 'TEST_TAG'
|
617
|
+
end
|
618
|
+
end
|
619
|
+
end
|
620
|
+
|
621
|
+
|
622
|
+
describe SvnRelease do
|
623
|
+
it_should_behave_like 'a release process'
|
624
|
+
|
625
|
+
before do
|
626
|
+
@release = SvnRelease.new
|
627
|
+
Svn.stub!(:svn)
|
628
|
+
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
|
629
|
+
Svn.stub!(:tag)
|
630
|
+
end
|
631
|
+
|
632
|
+
describe '#applies_to?' do
|
633
|
+
it 'should reject a non-git repo' do
|
634
|
+
SvnRelease.applies_to?.should be_false
|
635
|
+
end
|
636
|
+
|
637
|
+
it 'should accept a git repo' do
|
638
|
+
FileUtils.touch '.svn'
|
639
|
+
SvnRelease.applies_to?.should be_true
|
640
|
+
end
|
641
|
+
end
|
642
|
+
|
643
|
+
describe '#check' do
|
644
|
+
before do
|
645
|
+
Svn.stub!(:uncommitted_files).and_return([])
|
646
|
+
@release = SvnRelease.new
|
647
|
+
end
|
648
|
+
|
649
|
+
it 'should accept to release from the trunk' do
|
650
|
+
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
|
651
|
+
lambda { @release.check }.should_not raise_error
|
652
|
+
end
|
653
|
+
|
654
|
+
it 'should accept to release from a branch' do
|
655
|
+
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/branches/1.0')
|
656
|
+
lambda { @release.check }.should_not raise_error
|
657
|
+
end
|
658
|
+
|
659
|
+
it 'should reject releasing from a tag' do
|
660
|
+
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/tags/1.0.0')
|
661
|
+
lambda { @release.check }.should raise_error(RuntimeError, "SVN URL must contain 'trunk' or 'branches/...'")
|
662
|
+
end
|
663
|
+
|
664
|
+
it 'should reject a non standard repository layout' do
|
665
|
+
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/bar')
|
666
|
+
lambda { @release.check }.should raise_error(RuntimeError, "SVN URL must contain 'trunk' or 'branches/...'")
|
667
|
+
end
|
668
|
+
|
669
|
+
it 'should reject an uncommitted file' do
|
670
|
+
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
|
671
|
+
Svn.stub!(:uncommitted_files).and_return(['foo.rb'])
|
672
|
+
lambda { @release.check }.should raise_error(RuntimeError,
|
673
|
+
"Uncommitted files violate the First Principle Of Release!\n" +
|
674
|
+
"foo.rb")
|
675
|
+
end
|
676
|
+
end
|
677
|
+
end
|