vic-buildr 1.3.1 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +90 -8
- data/{README → README.rdoc} +29 -16
- data/Rakefile +17 -19
- data/_buildr +50 -0
- data/addon/buildr/cobertura.rb +47 -44
- data/addon/buildr/emma.rb +237 -0
- data/addon/buildr/jetty.rb +1 -1
- data/addon/buildr/nailgun.rb +581 -661
- data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.class +0 -0
- data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.java +0 -0
- data/addon/buildr/xmlbeans.rb +1 -1
- data/bin/buildr +9 -2
- data/buildr.buildfile +53 -0
- data/buildr.gemspec +23 -15
- data/doc/css/default.css +51 -48
- data/doc/css/print.css +60 -55
- data/doc/css/syntax.css +40 -31
- data/doc/images/growl-icon.tiff +0 -0
- data/doc/images/project-structure.png +0 -0
- data/doc/pages/artifacts.textile +46 -156
- data/doc/pages/building.textile +63 -324
- data/doc/pages/contributing.textile +116 -88
- data/doc/pages/download.textile +20 -15
- data/doc/pages/extending.textile +27 -81
- data/doc/pages/getting_started.textile +47 -111
- data/doc/pages/index.textile +19 -37
- data/doc/pages/languages.textile +407 -0
- data/doc/pages/more_stuff.textile +92 -173
- data/doc/pages/packaging.textile +72 -237
- data/doc/pages/projects.textile +58 -233
- data/doc/pages/recipes.textile +19 -43
- data/doc/pages/settings_profiles.textile +39 -104
- data/doc/pages/testing.textile +41 -304
- data/doc/pages/troubleshooting.textile +29 -47
- data/doc/pages/whats_new.textile +66 -157
- data/doc/print.haml +0 -1
- data/doc/print.toc.yaml +1 -0
- data/doc/scripts/buildr-git.rb +1 -1
- data/doc/scripts/install-jruby.sh +1 -1
- data/doc/scripts/install-linux.sh +4 -4
- data/doc/site.toc.yaml +8 -5
- data/{KEYS → etc/KEYS} +0 -0
- data/etc/git-svn-authors +16 -0
- data/lib/buildr.rb +2 -13
- data/lib/buildr/core/application.rb +200 -95
- data/lib/buildr/core/application_cli.rb +6 -1
- data/lib/buildr/core/build.rb +140 -91
- data/lib/buildr/core/checks.rb +5 -5
- data/lib/buildr/core/common.rb +1 -1
- data/lib/buildr/core/compile.rb +14 -12
- data/lib/buildr/core/filter.rb +151 -46
- data/lib/buildr/core/generate.rb +9 -7
- data/lib/buildr/core/progressbar.rb +1 -1
- data/lib/buildr/core/project.rb +8 -7
- data/lib/buildr/core/test.rb +54 -29
- data/lib/buildr/core/transports.rb +25 -20
- data/lib/buildr/core/util.rb +80 -26
- data/lib/buildr/groovy.rb +18 -0
- data/lib/buildr/groovy/bdd.rb +105 -0
- data/lib/buildr/groovy/compiler.rb +138 -0
- data/lib/buildr/ide/eclipse.rb +102 -71
- data/lib/buildr/ide/idea.rb +7 -12
- data/lib/buildr/ide/idea7x.rb +20 -20
- data/lib/buildr/java.rb +4 -7
- data/lib/buildr/java/ant.rb +26 -5
- data/lib/buildr/java/bdd.rb +447 -0
- data/lib/buildr/java/commands.rb +8 -9
- data/lib/buildr/java/{compilers.rb → compiler.rb} +8 -90
- data/lib/buildr/java/jruby.rb +29 -11
- data/lib/buildr/java/jtestr_runner.rb.erb +114 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +4 -1
- data/lib/buildr/java/packaging.rb +23 -16
- data/lib/buildr/java/pom.rb +1 -1
- data/lib/buildr/java/rjb.rb +21 -8
- data/lib/buildr/java/test_result.rb +277 -0
- data/lib/buildr/java/{test_frameworks.rb → tests.rb} +121 -88
- data/lib/buildr/packaging/artifact.rb +12 -11
- data/lib/buildr/packaging/artifact_namespace.rb +7 -4
- data/lib/buildr/packaging/gems.rb +3 -3
- data/lib/buildr/packaging/zip.rb +13 -10
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/scala.rb +19 -0
- data/lib/buildr/scala/compiler.rb +109 -0
- data/lib/buildr/scala/tests.rb +203 -0
- data/rakelib/apache.rake +31 -41
- data/rakelib/doc.rake +2 -2
- data/rakelib/package.rake +31 -2
- data/rakelib/rspec.rake +22 -20
- data/rakelib/rubyforge.rake +1 -0
- data/rakelib/setup.rake +34 -9
- data/spec/addon/cobertura_spec.rb +77 -0
- data/spec/addon/emma_spec.rb +120 -0
- data/spec/addon/test_coverage_spec.rb +249 -0
- data/spec/{application_spec.rb → core/application_spec.rb} +82 -4
- data/spec/{artifact_namespace_spec.rb → core/artifact_namespace_spec.rb} +12 -1
- data/spec/core/build_spec.rb +415 -0
- data/spec/{checks_spec.rb → core/checks_spec.rb} +1 -1
- data/spec/{common_spec.rb → core/common_spec.rb} +119 -30
- data/spec/{compile_spec.rb → core/compile_spec.rb} +17 -13
- data/spec/{project_spec.rb → core/project_spec.rb} +9 -6
- data/spec/{test_spec.rb → core/test_spec.rb} +226 -32
- data/spec/{transport_spec.rb → core/transport_spec.rb} +35 -23
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/{groovy_compilers_spec.rb → groovy/compiler_spec.rb} +1 -1
- data/spec/ide/eclipse_spec.rb +243 -0
- data/spec/{java_spec.rb → java/ant.rb} +7 -17
- data/spec/java/bdd_spec.rb +358 -0
- data/spec/{java_compilers_spec.rb → java/compiler_spec.rb} +1 -1
- data/spec/java/java_spec.rb +88 -0
- data/spec/{java_packaging_spec.rb → java/packaging_spec.rb} +65 -4
- data/spec/{java_test_frameworks_spec.rb → java/tests_spec.rb} +50 -10
- data/spec/{archive_spec.rb → packaging/archive_spec.rb} +12 -2
- data/spec/{artifact_spec.rb → packaging/artifact_spec.rb} +10 -3
- data/spec/{packaging_helper.rb → packaging/packaging_helper.rb} +0 -0
- data/spec/{packaging_spec.rb → packaging/packaging_spec.rb} +1 -1
- data/spec/sandbox.rb +25 -4
- data/spec/{scala_compilers_spec.rb → scala/compiler_spec.rb} +1 -1
- data/spec/scala/tests_spec.rb +215 -0
- data/spec/spec_helpers.rb +38 -17
- metadata +119 -69
- data/lib/buildr/java/bdd_frameworks.rb +0 -265
- data/lib/buildr/java/groovyc.rb +0 -137
- data/spec/build_spec.rb +0 -193
- data/spec/java_bdd_frameworks_spec.rb +0 -238
- data/spec/spec.opts +0 -6
@@ -0,0 +1,249 @@
|
|
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
|
+
module TestCoverageHelper
|
21
|
+
def write_test options
|
22
|
+
write File.join(options[:in], "#{options[:for]}Test.java"),
|
23
|
+
"public class #{options[:for]}Test extends junit.framework.TestCase { public void test#{options[:for]}() { new #{options[:for]}(); } }"
|
24
|
+
end
|
25
|
+
|
26
|
+
# Rspec matcher using file glob patterns.
|
27
|
+
class FileNamePatternMatcher
|
28
|
+
def initialize(pattern)
|
29
|
+
@expected_pattern = pattern
|
30
|
+
@pattern_matcher = lambda { |filename| File.fnmatch? pattern, filename }
|
31
|
+
end
|
32
|
+
|
33
|
+
def matches?(directory)
|
34
|
+
@actual_filenames = Dir[File.join(directory,'*')]
|
35
|
+
@actual_filenames.any? &@pattern_matcher
|
36
|
+
end
|
37
|
+
|
38
|
+
def failure_message
|
39
|
+
"Expected to find at least one element matching '#{@expected_pattern}' among #{@actual_filenames.inspect}, but found none"
|
40
|
+
end
|
41
|
+
|
42
|
+
def negative_failure_message
|
43
|
+
"Expected to find no element matching '#{@expected_pattern}' among #{@actual_filenames.inspect}, but found matching element(s) #{@actual_filenames.select(&@pattern_matcher).inspect}"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Test if a directory contains at least one file matching a given glob pattern.
|
48
|
+
#
|
49
|
+
# For example, to check that a directory contains at least one HTML file:
|
50
|
+
# '/path/to/some/directory'.should have_files_matching('*.html')
|
51
|
+
def have_files_matching pattern
|
52
|
+
FileNamePatternMatcher.new pattern
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe 'test coverage tool', :shared=>true do
|
57
|
+
include TestCoverageHelper
|
58
|
+
|
59
|
+
def toolname
|
60
|
+
@tool_module.name.split('::').last.downcase
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_coverage_config
|
64
|
+
project('foo').send(toolname)
|
65
|
+
end
|
66
|
+
|
67
|
+
describe 'project-specific' do
|
68
|
+
|
69
|
+
before do
|
70
|
+
write 'src/main/java/Foo.java', 'public class Foo {}'
|
71
|
+
write_test :for=>'Foo', :in=>'src/test/java'
|
72
|
+
end
|
73
|
+
|
74
|
+
describe 'clean' do
|
75
|
+
before { define('foo') }
|
76
|
+
|
77
|
+
it 'should remove the instrumented directory' do
|
78
|
+
mkdir_p test_coverage_config.instrumented_dir.to_s
|
79
|
+
task('foo:clean').invoke
|
80
|
+
file(test_coverage_config.instrumented_dir).should_not exist
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'should remove the reporting directory' do
|
84
|
+
mkdir_p test_coverage_config.report_dir
|
85
|
+
task('foo:clean').invoke
|
86
|
+
file(test_coverage_config.report_dir).should_not exist
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe 'instrumented directory' do
|
91
|
+
it 'should have a default value' do
|
92
|
+
define('foo')
|
93
|
+
test_coverage_config.instrumented_dir.should point_to_path('target/instrumented/classes')
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should be overridable' do
|
97
|
+
toolname = toolname()
|
98
|
+
define('foo') { send(toolname).instrumented_dir = path_to('target/coverage/classes') }
|
99
|
+
test_coverage_config.instrumented_dir.should point_to_path('target/coverage/classes')
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should be created during instrumentation' do
|
103
|
+
define('foo')
|
104
|
+
task("foo:#{toolname}:instrument").invoke
|
105
|
+
file(test_coverage_config.instrumented_dir).should exist
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe 'instrumentation' do
|
110
|
+
def instrumented_dir
|
111
|
+
file(test_coverage_config.instrumented_dir)
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should happen after compile' do
|
115
|
+
define('foo')
|
116
|
+
lambda { task("foo:#{toolname}:instrument").invoke }.should run_task('foo:compile')
|
117
|
+
end
|
118
|
+
|
119
|
+
it 'should put classes from compile.target in the instrumented directory' do
|
120
|
+
define('foo')
|
121
|
+
task("foo:#{toolname}:instrument").invoke
|
122
|
+
Dir.entries(instrumented_dir.to_s).should == Dir.entries(project('foo').compile.target.to_s)
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'should touch instrumented directory if anything instrumented' do
|
126
|
+
a_long_time_ago = Time.now - 10
|
127
|
+
define('foo')
|
128
|
+
mkpath instrumented_dir.to_s
|
129
|
+
File.utime(a_long_time_ago, a_long_time_ago, instrumented_dir.to_s)
|
130
|
+
task("foo:#{toolname}:instrument").invoke
|
131
|
+
instrumented_dir.timestamp.should be_close(Time.now, 2)
|
132
|
+
end
|
133
|
+
|
134
|
+
it 'should not touch instrumented directory if nothing instrumented' do
|
135
|
+
a_long_time_ago = Time.now - 10
|
136
|
+
define('foo').compile.invoke
|
137
|
+
mkpath instrumented_dir.to_s
|
138
|
+
[project('foo').compile.target, instrumented_dir].map(&:to_s).each { |dir| File.utime(a_long_time_ago, a_long_time_ago, dir) }
|
139
|
+
task("foo:#{toolname}:instrument").invoke
|
140
|
+
instrumented_dir.timestamp.should be_close(a_long_time_ago, 2)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
describe 'testing classpath' do
|
145
|
+
it 'should give priority to instrumented classes over non-instrumented ones' do
|
146
|
+
define('foo')
|
147
|
+
depends = project('foo').test.dependencies
|
148
|
+
depends.index(test_coverage_config.instrumented_dir).should < depends.index(project('foo').compile.target)
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'should have the test coverage tools artifacts' do
|
152
|
+
define('foo')
|
153
|
+
@tool_module.requires.each { |artifact| project('foo').test.dependencies.should include(artifact) }
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
describe 'html report' do
|
158
|
+
it 'should have html files' do
|
159
|
+
define('foo')
|
160
|
+
task("foo:#{toolname}:html").invoke
|
161
|
+
test_coverage_config.report_to(:html).should have_files_matching('*.html')
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'should contain full source code, including comments' do
|
165
|
+
write 'src/main/java/Foo.java',
|
166
|
+
'public class Foo { /* This comment is a TOKEN to check that test coverage reports include the source code */ }'
|
167
|
+
define('foo')
|
168
|
+
task("foo:#{toolname}:html").invoke
|
169
|
+
htlm_report_contents = Dir[File.join(test_coverage_config.report_dir, '**/*.html')].map{|path|File.open(path).read}.join
|
170
|
+
htlm_report_contents.should =~ /TOKEN/
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
describe 'cross-project' do
|
176
|
+
describe 'reporting' do
|
177
|
+
before do
|
178
|
+
write 'src/main/java/Foo.java', 'public class Foo {}'
|
179
|
+
write 'bar/src/main/java/Bar.java', 'public class Bar {}'
|
180
|
+
write_test :for=>'Bar', :in=>'bar/src/test/java'
|
181
|
+
define('foo') { define('bar')}
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'should have a default target' do
|
185
|
+
@tool_module.report_to.should point_to_path(File.join('reports', toolname))
|
186
|
+
end
|
187
|
+
|
188
|
+
describe 'in html' do
|
189
|
+
it 'should be a defined task' do
|
190
|
+
Rake::Task.task_defined?("#{toolname}:html").should be(true)
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'should happen after project instrumentation and testing' do
|
194
|
+
lambda { task("#{toolname}:html").invoke }.should run_tasks(["foo:#{toolname}:instrument", 'foo:bar:test'])
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'should have html files' do
|
198
|
+
task("#{toolname}:html").invoke
|
199
|
+
@tool_module.report_to(:html).should have_files_matching('*.html')
|
200
|
+
end
|
201
|
+
|
202
|
+
it 'should contain full source code, including comments' do
|
203
|
+
write 'bar/src/main/java/Bar.java',
|
204
|
+
'public class Bar { /* This comment is a TOKEN to check that test coverage reports include the source code */ }'
|
205
|
+
task("#{toolname}:html").invoke
|
206
|
+
htlm_report_contents = Dir[File.join(@tool_module.report_to(:html), '**/*.html')].map{|path|File.open(path).read}.join
|
207
|
+
htlm_report_contents.should =~ /TOKEN/
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
describe 'clean' do
|
213
|
+
it 'should remove the report directory' do
|
214
|
+
define('foo')
|
215
|
+
mkdir_p @tool_module.report_to
|
216
|
+
task("#{toolname}:clean").invoke
|
217
|
+
file(@tool_module.report_to).should_not exist
|
218
|
+
end
|
219
|
+
|
220
|
+
it 'should be called when calling global clean' do
|
221
|
+
define('foo')
|
222
|
+
lambda { task('clean').invoke }.should run_task("#{toolname}:clean")
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
describe 'project with no source' do
|
228
|
+
it 'should not define an html report task' do
|
229
|
+
define 'foo'
|
230
|
+
Rake::Task.task_defined?("foo:#{toolname}:html").should be(false)
|
231
|
+
end
|
232
|
+
|
233
|
+
it 'should not raise an error when instrumenting' do
|
234
|
+
define('foo')
|
235
|
+
lambda { task("foo:#{toolname}:instrument").invoke }.should_not raise_error
|
236
|
+
end
|
237
|
+
|
238
|
+
it 'should not add the instrumented directory to the testing classpath' do
|
239
|
+
define 'foo'
|
240
|
+
depends = project('foo').test.dependencies
|
241
|
+
depends.should_not include(test_coverage_config.instrumented_dir)
|
242
|
+
end
|
243
|
+
|
244
|
+
it 'should not add the test coverage tools artifacts to the testing classpath' do
|
245
|
+
define('foo')
|
246
|
+
@tool_module.requires.each { |artifact| project('foo').test.dependencies.should_not include(artifact) }
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
@@ -14,7 +14,7 @@
|
|
14
14
|
# the License.
|
15
15
|
|
16
16
|
|
17
|
-
require File.join(File.dirname(__FILE__), 'spec_helpers')
|
17
|
+
require File.join(File.dirname(__FILE__), '../spec_helpers')
|
18
18
|
|
19
19
|
|
20
20
|
describe Buildr::Application do
|
@@ -29,6 +29,17 @@ describe Buildr::Application do
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
describe '#run' do
|
33
|
+
it 'should execute *_load methods in order' do
|
34
|
+
last = nil
|
35
|
+
order = [:find_buildfile, :load_gems, :load_artifacts, :load_tasks,
|
36
|
+
:load_requires, :load_buildfile, :load_imports, :top_level]
|
37
|
+
order.each { |method| Buildr.application.should_receive(method).ordered }
|
38
|
+
Buildr.application.stub!(:exit) # With this, shows the correct error instead of SystemExit.
|
39
|
+
Buildr.application.run
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
32
43
|
describe 'environment' do
|
33
44
|
it 'should return value of BUILDR_ENV' do
|
34
45
|
ENV['BUILDR_ENV'] = 'qa'
|
@@ -44,13 +55,24 @@ describe Buildr::Application do
|
|
44
55
|
Buildr::Application.new.environment.should eql('test')
|
45
56
|
ENV['BUILDR_ENV'].should eql('test')
|
46
57
|
end
|
47
|
-
|
58
|
+
|
59
|
+
it 'should be echoed to user' do
|
60
|
+
write 'buildfile'
|
61
|
+
lambda { Buildr.application.send :load_buildfile }.should show_info(%r{(in .*, development)})
|
62
|
+
end
|
63
|
+
|
48
64
|
after do
|
49
65
|
ENV['BUILDR_ENV'] = nil
|
50
66
|
end
|
51
67
|
end
|
52
68
|
|
53
69
|
describe 'gems' do
|
70
|
+
before do
|
71
|
+
Buildr.application.private_methods(true).should include('load_gems')
|
72
|
+
class << Buildr.application
|
73
|
+
public :load_gems
|
74
|
+
end
|
75
|
+
end
|
54
76
|
|
55
77
|
def load_with_yaml
|
56
78
|
write 'build.yaml', <<-YAML
|
@@ -62,7 +84,7 @@ describe Buildr::Application do
|
|
62
84
|
end
|
63
85
|
|
64
86
|
it 'should return empty array if no gems specified' do
|
65
|
-
Buildr.application.load_gems
|
87
|
+
Buildr.application.load_gems
|
66
88
|
Buildr.application.gems.should be_empty
|
67
89
|
end
|
68
90
|
|
@@ -90,10 +112,15 @@ describe Buildr::Application do
|
|
90
112
|
|
91
113
|
describe 'load_gems' do
|
92
114
|
before do
|
115
|
+
Buildr.application.private_methods(true).should include('load_gems')
|
116
|
+
class << Buildr.application
|
117
|
+
public :load_gems
|
118
|
+
end
|
93
119
|
@spec = Gem::Specification.new do |spec|
|
94
120
|
spec.name = 'foo'
|
95
121
|
spec.version = '1.2'
|
96
122
|
end
|
123
|
+
$stdout.stub!(:isatty).and_return(true)
|
97
124
|
end
|
98
125
|
|
99
126
|
it 'should do nothing if no gems specified' do
|
@@ -306,9 +333,59 @@ describe Buildr, 'settings' do
|
|
306
333
|
YAML
|
307
334
|
Buildr.settings.profile.should == { 'foo'=>'bar' }
|
308
335
|
end
|
309
|
-
|
310
336
|
end
|
311
337
|
|
338
|
+
describe 'buildfile task' do
|
339
|
+
before do
|
340
|
+
@buildfile_time = Time.now - 10
|
341
|
+
write 'buildfile'; File.utime(@buildfile_time, @buildfile_time, 'buildfile')
|
342
|
+
end
|
343
|
+
|
344
|
+
it 'should point to the buildfile' do
|
345
|
+
Buildr.application.buildfile.should point_to_path('buildfile')
|
346
|
+
end
|
347
|
+
|
348
|
+
it 'should be a defined task' do
|
349
|
+
Buildr.application.buildfile.should == file(File.expand_path('buildfile'))
|
350
|
+
end
|
351
|
+
|
352
|
+
it 'should ignore any rake namespace' do
|
353
|
+
namespace 'dummy_ns' do
|
354
|
+
Buildr.application.buildfile.should point_to_path('buildfile')
|
355
|
+
end
|
356
|
+
end
|
357
|
+
|
358
|
+
it 'should have the same timestamp as the buildfile' do
|
359
|
+
Buildr.application.buildfile.timestamp.should be_close(@buildfile_time, 1)
|
360
|
+
end
|
361
|
+
|
362
|
+
it 'should have the same timestamp as build.yaml if the latter is newer' do
|
363
|
+
write 'build.yaml'; File.utime(@buildfile_time + 5, @buildfile_time + 5, 'build.yaml')
|
364
|
+
Buildr.application.run
|
365
|
+
Buildr.application.buildfile.timestamp.should be_close(@buildfile_time + 5, 1)
|
366
|
+
end
|
367
|
+
|
368
|
+
it 'should have the same timestamp as the buildfile if build.yaml is older' do
|
369
|
+
write 'build.yaml'; File.utime(@buildfile_time - 5, @buildfile_time - 5, 'build.yaml')
|
370
|
+
Buildr.application.run
|
371
|
+
Buildr.application.buildfile.timestamp.should be_close(@buildfile_time, 1)
|
372
|
+
end
|
373
|
+
|
374
|
+
it 'should have the same timestamp as build.rb in home dir if the latter is newer' do
|
375
|
+
write 'home/buildr.rb'; File.utime(@buildfile_time + 5, @buildfile_time + 5, 'home/buildr.rb')
|
376
|
+
Buildr.application.send :load_tasks
|
377
|
+
Buildr.application.buildfile.timestamp.should be_close(@buildfile_time + 5, 1)
|
378
|
+
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
|
+
end
|
312
389
|
end
|
313
390
|
|
314
391
|
|
@@ -332,3 +409,4 @@ describe Buildr do
|
|
332
409
|
end
|
333
410
|
end
|
334
411
|
end
|
412
|
+
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# License for the specific language governing permissions and limitations under
|
14
14
|
# the License.
|
15
15
|
|
16
|
-
require File.join(File.dirname(__FILE__), 'spec_helpers')
|
16
|
+
require File.join(File.dirname(__FILE__), '../spec_helpers')
|
17
17
|
|
18
18
|
describe Buildr::ArtifactNamespace do
|
19
19
|
|
@@ -247,6 +247,17 @@ describe Buildr::ArtifactNamespace do
|
|
247
247
|
artifact_ns[:copied].should be_nil
|
248
248
|
end
|
249
249
|
end
|
250
|
+
|
251
|
+
it 'should register two artifacts with different version on namespace' do
|
252
|
+
define 'one' do
|
253
|
+
artifact_ns.use :foo => 'a:b:c:1'
|
254
|
+
artifact_ns.use :bar => 'a:b:c:2'
|
255
|
+
artifact_ns[:foo].version.should == '1'
|
256
|
+
artifact_ns[:bar].version.should == '2'
|
257
|
+
# unversioned references the last version set.
|
258
|
+
artifact_ns['a:b:c'].version.should == '2'
|
259
|
+
end
|
260
|
+
end
|
250
261
|
|
251
262
|
it 'should complain if namespace requirement is not satisfied' do
|
252
263
|
define 'one' do
|
@@ -0,0 +1,415 @@
|
|
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
|
+
end
|
173
|
+
|
174
|
+
|
175
|
+
describe Project, '#reports' do
|
176
|
+
before :each do
|
177
|
+
@project = define('foo', :layout=>Layout.new)
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'should default to reports' do
|
181
|
+
@project.reports.should eql('reports')
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'should set layout :reports' do
|
185
|
+
@project.reports = 'bar'
|
186
|
+
@project.layout.expand(:reports).should point_to_path('bar')
|
187
|
+
end
|
188
|
+
|
189
|
+
it 'should come from layout :reports' do
|
190
|
+
@project.layout[:reports] = 'baz'
|
191
|
+
@project.reports.should eql('baz')
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
|
196
|
+
describe Buildr::Release do
|
197
|
+
|
198
|
+
describe '#make' do
|
199
|
+
before do
|
200
|
+
write 'buildfile', "VERSION_NUMBER = '1.0.0-SNAPSHOT'"
|
201
|
+
# Prevent a real call to a spawned buildr process.
|
202
|
+
Release.stub!(:buildr)
|
203
|
+
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
|
204
|
+
Svn.stub!(:uncommitted_files).and_return('')
|
205
|
+
Svn.stub!(:remove)
|
206
|
+
Svn.stub!(:copy)
|
207
|
+
Svn.stub!(:commit)
|
208
|
+
end
|
209
|
+
|
210
|
+
it 'should tag a release with the release version' do
|
211
|
+
Svn.should_receive(:copy).with(Dir.pwd, 'http://my.repo.org/foo/tags/1.0.0', 'Release 1.0.0').and_return {
|
212
|
+
file('buildfile').should contain('VERSION_NUMBER = "1.0.0"')
|
213
|
+
}
|
214
|
+
Release.make
|
215
|
+
end
|
216
|
+
|
217
|
+
it 'should update the buildfile with the next version number' do
|
218
|
+
Release.make
|
219
|
+
file('buildfile').should contain('VERSION_NUMBER = "1.0.1-SNAPSHOT"')
|
220
|
+
end
|
221
|
+
|
222
|
+
it 'should commit the updated buildfile' do
|
223
|
+
Svn.should_receive(:commit).with(File.expand_path('buildfile'), 'Changed version number to 1.0.1-SNAPSHOT').and_return {
|
224
|
+
file('buildfile').should contain('VERSION_NUMBER = "1.0.1-SNAPSHOT"')
|
225
|
+
}
|
226
|
+
Release.make
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
|
231
|
+
describe '#check' do
|
232
|
+
before do
|
233
|
+
Svn.stub!(:uncommitted_files).and_return('')
|
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
|
239
|
+
end
|
240
|
+
|
241
|
+
it 'should accept to release from a branch' do
|
242
|
+
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/branches/1.0')
|
243
|
+
lambda { Release.check }.should_not raise_error
|
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/...'")
|
249
|
+
end
|
250
|
+
|
251
|
+
it 'should reject a non standard repository layout' do
|
252
|
+
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/bar')
|
253
|
+
lambda { Release.check }.should raise_error(RuntimeError, "SVN URL must contain 'trunk' or 'branches/...'")
|
254
|
+
end
|
255
|
+
|
256
|
+
it 'should reject an uncommitted file' do
|
257
|
+
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
|
258
|
+
Svn.stub!(:uncommitted_files).and_return('M foo.rb')
|
259
|
+
lambda { Release.check }.should raise_error(RuntimeError,
|
260
|
+
"Uncommitted SVN files violate the First Principle Of Release!\n" +
|
261
|
+
"M foo.rb")
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
|
266
|
+
describe '#extract_version' do
|
267
|
+
it 'should extract VERSION_NUMBER with single quotes' do
|
268
|
+
write 'buildfile', "VERSION_NUMBER = '1.0.0-SNAPSHOT'"
|
269
|
+
Release.extract_version.should == '1.0.0-SNAPSHOT'
|
270
|
+
end
|
271
|
+
|
272
|
+
it 'should extract VERSION_NUMBER with double quotes' do
|
273
|
+
write 'buildfile', %{VERSION_NUMBER = "1.0.1-SNAPSHOT"}
|
274
|
+
Release.extract_version.should == '1.0.1-SNAPSHOT'
|
275
|
+
end
|
276
|
+
|
277
|
+
it 'should extract VERSION_NUMBER without any spaces' do
|
278
|
+
write 'buildfile', "VERSION_NUMBER='1.0.2-SNAPSHOT'"
|
279
|
+
Release.extract_version.should == '1.0.2-SNAPSHOT'
|
280
|
+
end
|
281
|
+
|
282
|
+
it 'should extract THIS_VERSION as an alternative to VERSION_NUMBER' do
|
283
|
+
write 'buildfile', "THIS_VERSION = '1.0.3-SNAPSHOT'"
|
284
|
+
Release.extract_version.should == '1.0.3-SNAPSHOT'
|
285
|
+
end
|
286
|
+
|
287
|
+
it 'should complain if no current version number' do
|
288
|
+
write 'buildfile', 'define foo'
|
289
|
+
lambda { Release.extract_version }.should raise_error('Looking for THIS_VERSION = "..." in your Buildfile, none found')
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
|
294
|
+
# Reference: http://svnbook.red-bean.com/en/1.4/svn.reposadmin.planning.html#svn.reposadmin.projects.chooselayout
|
295
|
+
describe '#tag url' do
|
296
|
+
it 'should accept to tag foo/trunk' do
|
297
|
+
Release.tag_url('http://my.repo.org/foo/trunk', '1.0.0').should == 'http://my.repo.org/foo/tags/1.0.0'
|
298
|
+
end
|
299
|
+
|
300
|
+
it 'should accept to tag foo/branches/1.0' do
|
301
|
+
Release.tag_url('http://my.repo.org/foo/branches/1.0', '1.0.1').should == 'http://my.repo.org/foo/tags/1.0.1'
|
302
|
+
end
|
303
|
+
|
304
|
+
it 'should accept to tag trunk/foo' do
|
305
|
+
Release.tag_url('http://my.repo.org/trunk/foo', '1.0.0').should == 'http://my.repo.org/tags/foo/1.0.0'
|
306
|
+
end
|
307
|
+
|
308
|
+
it 'should accept to tag branches/foo/1.0' do
|
309
|
+
Release.tag_url('http://my.repo.org/branches/foo/1.0', '1.0.0').should == 'http://my.repo.org/tags/foo/1.0.0'
|
310
|
+
end
|
311
|
+
|
312
|
+
it 'should use tag specified by tag_name' do
|
313
|
+
Release.tag_name = 'first'
|
314
|
+
Release.tag_url('http://my.repo.org/foo/trunk', '1.0.0').should == 'http://my.repo.org/foo/tags/first'
|
315
|
+
end
|
316
|
+
|
317
|
+
it 'should use tag returned by tag_name if tag_name is a proc' do
|
318
|
+
Release.tag_name = lambda { |version| "buildr-#{version}" }
|
319
|
+
Release.tag_url('http://my.repo.org/foo/trunk', '1.0.0').should == 'http://my.repo.org/foo/tags/buildr-1.0.0'
|
320
|
+
end
|
321
|
+
|
322
|
+
after { Release.tag_name = nil }
|
323
|
+
end
|
324
|
+
|
325
|
+
|
326
|
+
describe '#with_release_candidate_version' do
|
327
|
+
before do
|
328
|
+
Buildr.application.stub!(:buildfile).and_return(file('buildfile'))
|
329
|
+
write 'buildfile', "THIS_VERSION = '1.1.0-SNAPSHOT'"
|
330
|
+
end
|
331
|
+
|
332
|
+
it 'should yield the name of the release candidate buildfile' do
|
333
|
+
Release.send :with_release_candidate_version do |new_filename|
|
334
|
+
File.read(new_filename).should == %{THIS_VERSION = "1.1.0"}
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
it 'should yield a name different from the original buildfile' do
|
339
|
+
Release.send :with_release_candidate_version do |new_filename|
|
340
|
+
new_filename.should_not point_to_path('buildfile')
|
341
|
+
end
|
342
|
+
end
|
343
|
+
end
|
344
|
+
|
345
|
+
|
346
|
+
describe '#tag_release' do
|
347
|
+
before do
|
348
|
+
write 'buildfile', "THIS_VERSION = '1.0.1'"
|
349
|
+
Svn.stub!(:repo_url).and_return('http://my.repo.org/foo/trunk')
|
350
|
+
Svn.stub!(:copy)
|
351
|
+
Svn.stub!(:remove)
|
352
|
+
end
|
353
|
+
|
354
|
+
it 'should tag the working copy' do
|
355
|
+
Svn.should_receive(:copy).with(Dir.pwd, 'http://my.repo.org/foo/tags/1.0.1', 'Release 1.0.1')
|
356
|
+
Release.send :tag_release
|
357
|
+
end
|
358
|
+
|
359
|
+
it 'should remove the tag if it already exists' do
|
360
|
+
Svn.should_receive(:remove).with('http://my.repo.org/foo/tags/1.0.1', 'Removing old copy')
|
361
|
+
Release.send :tag_release
|
362
|
+
end
|
363
|
+
|
364
|
+
it 'should accept that the tag does not exist' do
|
365
|
+
Svn.stub!(:remove).and_raise(RuntimeError)
|
366
|
+
Release.send :tag_release
|
367
|
+
end
|
368
|
+
|
369
|
+
it 'should inform the user' do
|
370
|
+
lambda { Release.send :tag_release }.should show_info('Tagging release 1.0.1')
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
|
375
|
+
describe '#commit_new_snapshot' do
|
376
|
+
before do
|
377
|
+
write 'buildfile', 'THIS_VERSION = "1.0.0"'
|
378
|
+
Svn.stub!(:commit)
|
379
|
+
end
|
380
|
+
|
381
|
+
it 'should update the buildfile with a new version number' do
|
382
|
+
Release.send :commit_new_snapshot
|
383
|
+
file('buildfile').should contain('THIS_VERSION = "1.0.1-SNAPSHOT"')
|
384
|
+
end
|
385
|
+
|
386
|
+
it 'should commit the new buildfile on the trunk' do
|
387
|
+
Svn.should_receive(:commit).with(File.expand_path('buildfile'), 'Changed version number to 1.0.1-SNAPSHOT')
|
388
|
+
Release.send :commit_new_snapshot
|
389
|
+
end
|
390
|
+
|
391
|
+
it 'should inform the user of the new version' do
|
392
|
+
lambda { Release.send :commit_new_snapshot }.should show_info('Current version is now 1.0.1-SNAPSHOT')
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
396
|
+
end
|
397
|
+
|
398
|
+
|
399
|
+
describe Buildr::Svn, '#repo_url' do
|
400
|
+
it 'should extract the SVN URL from svn info' do
|
401
|
+
Svn.stub!(:svn, 'info').and_return(<<EOF)
|
402
|
+
Path: .
|
403
|
+
URL: http://my.repo.org/foo/trunk
|
404
|
+
Repository Root: http://my.repo.org
|
405
|
+
Repository UUID: 12345678-9abc-def0-1234-56789abcdef0
|
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'
|
414
|
+
end
|
415
|
+
end
|