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,502 @@
|
|
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 Buildr::Application do
|
21
|
+
|
22
|
+
describe 'home_dir' do
|
23
|
+
it 'should point to ~/.buildr' do
|
24
|
+
Buildr.application.home_dir.should eql(File.expand_path('.buildr', ENV['HOME']))
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should point to existing directory' do
|
28
|
+
File.directory?(Buildr.application.home_dir).should be_true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#run' do
|
33
|
+
it 'should execute *_load methods in order' do
|
34
|
+
order = [:load_gems, :load_artifact_ns, :load_tasks, :raw_load_buildfile]
|
35
|
+
order.each { |method| Buildr.application.should_receive(method).ordered }
|
36
|
+
Buildr.application.stub!(:exit) # With this, shows the correct error instead of SystemExit.
|
37
|
+
Buildr.application.run
|
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
|
57
|
+
end
|
58
|
+
|
59
|
+
describe 'environment' do
|
60
|
+
it 'should return value of BUILDR_ENV' do
|
61
|
+
ENV['BUILDR_ENV'] = 'qa'
|
62
|
+
Buildr.application.environment.should eql('qa')
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should default to development' do
|
66
|
+
Buildr.application.environment.should eql('development')
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should set environment name from -e argument' do
|
70
|
+
ARGV.push('-e', 'test')
|
71
|
+
Buildr.application.send(:handle_options)
|
72
|
+
Buildr.application.environment.should eql('test')
|
73
|
+
ENV['BUILDR_ENV'].should eql('test')
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should be echoed to user' do
|
77
|
+
write 'buildfile'
|
78
|
+
ENV['BUILDR_ENV'] = 'spec'
|
79
|
+
Buildr.application.send(:handle_options)
|
80
|
+
lambda { Buildr.application.send :load_buildfile }.should show(%r{(in .*, spec)})
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe 'options' do
|
85
|
+
it "should have 'tasks' as the sole default rakelib" do
|
86
|
+
Buildr.application.send(:handle_options)
|
87
|
+
Buildr.application.options.rakelib.should == ['tasks']
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe 'gems' do
|
92
|
+
before do
|
93
|
+
class << Buildr.application
|
94
|
+
public :load_gems
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def load_with_yaml
|
99
|
+
write 'build.yaml', <<-YAML
|
100
|
+
gems:
|
101
|
+
- rake
|
102
|
+
- rspec >= 1.2
|
103
|
+
YAML
|
104
|
+
Buildr.application.load_gems
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should return empty array if no gems specified' do
|
108
|
+
Buildr.application.load_gems
|
109
|
+
Buildr.application.gems.should be_empty
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'should return one entry for each gem specified in buildr.yaml' do
|
113
|
+
load_with_yaml
|
114
|
+
Buildr.application.gems.size.should be(2)
|
115
|
+
end
|
116
|
+
|
117
|
+
it 'should return a Gem::Specification for each installed gem' do
|
118
|
+
load_with_yaml
|
119
|
+
Buildr.application.gems.each { |gem| gem.should be_kind_of(Gem::Specification) }
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'should parse Gem name correctly' do
|
123
|
+
load_with_yaml
|
124
|
+
Buildr.application.gems.map(&:name).should include('rspec', 'rake')
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'should find installed version of Gem' do
|
128
|
+
load_with_yaml
|
129
|
+
Buildr.application.gems.each { |gem| gem.version.should eql(Gem.loaded_specs[gem.name].version) }
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe 'load_gems' do
|
134
|
+
before do
|
135
|
+
class << Buildr.application
|
136
|
+
public :load_gems
|
137
|
+
end
|
138
|
+
@spec = Gem::Specification.new do |spec|
|
139
|
+
spec.name = 'foo'
|
140
|
+
spec.version = '1.2'
|
141
|
+
end
|
142
|
+
$stdout.stub!(:isatty).and_return(true)
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'should do nothing if no gems specified' do
|
146
|
+
lambda { Buildr.application.load_gems }.should_not raise_error
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'should install nothing if specified gems already installed' do
|
150
|
+
Buildr.application.should_receive(:listed_gems).and_return([Gem.loaded_specs['rspec']])
|
151
|
+
Util.should_not_receive(:ruby)
|
152
|
+
lambda { Buildr.application.load_gems }.should_not raise_error
|
153
|
+
end
|
154
|
+
|
155
|
+
it 'should fail if required gem not found in remote repository' do
|
156
|
+
Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo', '>=1.1')])
|
157
|
+
Gem::SourceInfoCache.should_receive(:search).and_return([])
|
158
|
+
lambda { Buildr.application.load_gems }.should raise_error(LoadError, /cannot be found/i)
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'should fail if need to install gem and not running in interactive mode' do
|
162
|
+
Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo', '>=1.1')])
|
163
|
+
Gem::SourceInfoCache.should_receive(:search).and_return([@spec])
|
164
|
+
$stdout.should_receive(:isatty).and_return(false)
|
165
|
+
lambda { Buildr.application.load_gems }.should raise_error(LoadError, /this build requires the gems/i)
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'should ask permission before installing required gems' do
|
169
|
+
Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo', '>=1.1')])
|
170
|
+
Gem::SourceInfoCache.should_receive(:search).and_return([@spec])
|
171
|
+
$terminal.should_receive(:agree).with(/install/, true)
|
172
|
+
lambda { Buildr.application.load_gems }.should raise_error
|
173
|
+
end
|
174
|
+
|
175
|
+
it 'should fail if permission not granted to install gem' do
|
176
|
+
Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo', '>=1.1')])
|
177
|
+
Gem::SourceInfoCache.should_receive(:search).and_return([@spec])
|
178
|
+
$terminal.should_receive(:agree).and_return(false)
|
179
|
+
lambda { Buildr.application.load_gems }.should raise_error(LoadError, /cannot build without/i)
|
180
|
+
end
|
181
|
+
|
182
|
+
it 'should install gem if permission granted' do
|
183
|
+
Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo', '>=1.1')])
|
184
|
+
Gem::SourceInfoCache.should_receive(:search).and_return([@spec])
|
185
|
+
$terminal.should_receive(:agree).and_return(true)
|
186
|
+
Util.should_receive(:ruby) do |*args|
|
187
|
+
args.should include('install', 'foo', '-v', '1.2')
|
188
|
+
end
|
189
|
+
Buildr.application.should_receive(:gem).and_return(false)
|
190
|
+
Buildr.application.load_gems
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'should reload gem cache after installing required gems' do
|
194
|
+
Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo', '>=1.1')])
|
195
|
+
Gem::SourceInfoCache.should_receive(:search).and_return([@spec])
|
196
|
+
$terminal.should_receive(:agree).and_return(true)
|
197
|
+
Util.should_receive(:ruby)
|
198
|
+
Gem.source_index.should_receive(:load_gems_in).with(Gem::SourceIndex.installed_spec_directories)
|
199
|
+
Buildr.application.should_receive(:gem).and_return(false)
|
200
|
+
Buildr.application.load_gems
|
201
|
+
end
|
202
|
+
|
203
|
+
it 'should load previously installed gems' do
|
204
|
+
Buildr.application.should_receive(:listed_gems).and_return([Gem.loaded_specs['rspec']])
|
205
|
+
Buildr.application.should_receive(:gem).with('rspec', Gem.loaded_specs['rspec'].version.to_s)
|
206
|
+
Buildr.application.load_gems
|
207
|
+
end
|
208
|
+
|
209
|
+
it 'should load newly installed gems' do
|
210
|
+
Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('foo', '>=1.1')])
|
211
|
+
Gem::SourceInfoCache.should_receive(:search).and_return([@spec])
|
212
|
+
$terminal.should_receive(:agree).and_return(true)
|
213
|
+
Util.should_receive(:ruby)
|
214
|
+
Buildr.application.should_receive(:gem).with('foo', @spec.version.to_s)
|
215
|
+
Buildr.application.load_gems
|
216
|
+
end
|
217
|
+
|
218
|
+
it 'should default to >=0 version requirement if not specified' do
|
219
|
+
write 'build.yaml', 'gems: foo'
|
220
|
+
Gem::SourceInfoCache.should_receive(:search).with(Gem::Dependency.new('foo', '>=0')).and_return([])
|
221
|
+
lambda { Buildr.application.load_gems }.should raise_error
|
222
|
+
end
|
223
|
+
|
224
|
+
it 'should parse exact version requirement' do
|
225
|
+
write 'build.yaml', 'gems: foo 2.5'
|
226
|
+
Gem::SourceInfoCache.should_receive(:search).with(Gem::Dependency.new('foo', '=2.5')).and_return([])
|
227
|
+
lambda { Buildr.application.load_gems }.should raise_error
|
228
|
+
end
|
229
|
+
|
230
|
+
it 'should parse range version requirement' do
|
231
|
+
write 'build.yaml', 'gems: foo ~>2.3'
|
232
|
+
Gem::SourceInfoCache.should_receive(:search).with(Gem::Dependency.new('foo', '~>2.3')).and_return([])
|
233
|
+
lambda { Buildr.application.load_gems }.should raise_error
|
234
|
+
end
|
235
|
+
|
236
|
+
it 'should parse multiple version requirements' do
|
237
|
+
write 'build.yaml', 'gems: foo >=2.0 !=2.1'
|
238
|
+
Gem::SourceInfoCache.should_receive(:search).with(Gem::Dependency.new('foo', ['>=2.0', '!=2.1'])).and_return([])
|
239
|
+
lambda { Buildr.application.load_gems }.should raise_error
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
describe 'load_tasks' do
|
244
|
+
before do
|
245
|
+
class << Buildr.application
|
246
|
+
public :load_tasks
|
247
|
+
end
|
248
|
+
@original_loaded_features = $LOADED_FEATURES.dup
|
249
|
+
Buildr.application.options.rakelib = ["tasks"]
|
250
|
+
end
|
251
|
+
|
252
|
+
after do
|
253
|
+
$taskfiles = nil
|
254
|
+
($LOADED_FEATURES - @original_loaded_features).each do |new_load|
|
255
|
+
$LOADED_FEATURES.delete(new_load)
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
def write_task(filename)
|
260
|
+
write filename, <<-RUBY
|
261
|
+
$taskfiles ||= []
|
262
|
+
$taskfiles << __FILE__
|
263
|
+
RUBY
|
264
|
+
end
|
265
|
+
|
266
|
+
def loaded_tasks
|
267
|
+
@loaded ||= Buildr.application.load_tasks
|
268
|
+
$taskfiles
|
269
|
+
end
|
270
|
+
|
271
|
+
it "should load {options.rakelib}/foo.rake" do
|
272
|
+
write_task 'tasks/foo.rake'
|
273
|
+
loaded_tasks.should have(1).task
|
274
|
+
loaded_tasks.first.should =~ %r{tasks/foo\.rake$}
|
275
|
+
end
|
276
|
+
|
277
|
+
it 'should load all *.rake files from the rakelib' do
|
278
|
+
write_task 'tasks/bar.rake'
|
279
|
+
write_task 'tasks/quux.rake'
|
280
|
+
loaded_tasks.should have(2).tasks
|
281
|
+
end
|
282
|
+
|
283
|
+
it 'should not load files which do not have the .rake extension' do
|
284
|
+
write_task 'tasks/foo.rb'
|
285
|
+
write_task 'tasks/bar.rake'
|
286
|
+
loaded_tasks.should have(1).task
|
287
|
+
loaded_tasks.first.should =~ %r{tasks/bar\.rake$}
|
288
|
+
end
|
289
|
+
|
290
|
+
it 'should load files only from the directory specified in the rakelib option' do
|
291
|
+
Buildr.application.options.rakelib = ['extensions']
|
292
|
+
write_task 'extensions/amp.rake'
|
293
|
+
write_task 'tasks/bar.rake'
|
294
|
+
write_task 'extensions/foo.rake'
|
295
|
+
loaded_tasks.should have(2).tasks
|
296
|
+
%w[amp foo].each do |filename|
|
297
|
+
loaded_tasks.select{|x| x =~ %r{extensions/#{filename}\.rake}}.should have(1).entry
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
it 'should load files from all the directories specified in the rakelib option' do
|
302
|
+
Buildr.application.options.rakelib = ['ext', 'more', 'tasks']
|
303
|
+
write_task 'ext/foo.rake'
|
304
|
+
write_task 'tasks/bar.rake'
|
305
|
+
write_task 'tasks/zeb.rake'
|
306
|
+
write_task 'more/baz.rake'
|
307
|
+
loaded_tasks.should have(4).tasks
|
308
|
+
end
|
309
|
+
|
310
|
+
it 'should not load files from the rakelib more than once' do
|
311
|
+
write_task 'tasks/new_one.rake'
|
312
|
+
write_task 'tasks/already.rake'
|
313
|
+
$LOADED_FEATURES << 'tasks/already.rake'
|
314
|
+
|
315
|
+
loaded_tasks.should have(1).task
|
316
|
+
loaded_tasks.first.should =~ %r{tasks/new_one\.rake$}
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
end
|
321
|
+
|
322
|
+
|
323
|
+
describe Buildr, 'settings' do
|
324
|
+
|
325
|
+
describe 'user' do
|
326
|
+
|
327
|
+
it 'should be empty hash if no settings.yaml file' do
|
328
|
+
Buildr.settings.user.should == {}
|
329
|
+
end
|
330
|
+
|
331
|
+
it 'should return loaded settings.yaml file' do
|
332
|
+
write 'home/.buildr/settings.yaml', 'foo: bar'
|
333
|
+
Buildr.settings.user.should == { 'foo'=>'bar' }
|
334
|
+
end
|
335
|
+
|
336
|
+
it 'should return loaded settings.yml file' do
|
337
|
+
write 'home/.buildr/settings.yml', 'foo: bar'
|
338
|
+
Buildr.settings.user.should == { 'foo'=>'bar' }
|
339
|
+
end
|
340
|
+
|
341
|
+
it 'should fail if settings.yaml file is not a hash' do
|
342
|
+
write 'home/.buildr/settings.yaml', 'foo bar'
|
343
|
+
lambda { Buildr.settings.user }.should raise_error(RuntimeError, /expecting.*settings.yaml/i)
|
344
|
+
end
|
345
|
+
|
346
|
+
it 'should be empty hash if settings.yaml file is empty' do
|
347
|
+
write 'home/.buildr/settings.yaml'
|
348
|
+
Buildr.settings.user.should == {}
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
describe 'configuration' do
|
353
|
+
it 'should be empty hash if no build.yaml file' do
|
354
|
+
Buildr.settings.build.should == {}
|
355
|
+
end
|
356
|
+
|
357
|
+
it 'should return loaded build.yaml file' do
|
358
|
+
write 'build.yaml', 'foo: bar'
|
359
|
+
Buildr.settings.build.should == { 'foo'=>'bar' }
|
360
|
+
end
|
361
|
+
|
362
|
+
it 'should return loaded build.yml file' do
|
363
|
+
write 'build.yml', 'foo: bar'
|
364
|
+
Buildr.settings.build.should == { 'foo'=>'bar' }
|
365
|
+
end
|
366
|
+
|
367
|
+
it 'should fail if build.yaml file is not a hash' do
|
368
|
+
write 'build.yaml', 'foo bar'
|
369
|
+
lambda { Buildr.settings.build }.should raise_error(RuntimeError, /expecting.*build.yaml/i)
|
370
|
+
end
|
371
|
+
|
372
|
+
it 'should be empty hash if build.yaml file is empty' do
|
373
|
+
write 'build.yaml'
|
374
|
+
Buildr.settings.build.should == {}
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|
378
|
+
describe 'profiles' do
|
379
|
+
it 'should be empty hash if no profiles.yaml file' do
|
380
|
+
Buildr.settings.profiles.should == {}
|
381
|
+
end
|
382
|
+
|
383
|
+
it 'should return loaded profiles.yaml file' do
|
384
|
+
write 'profiles.yaml', <<-YAML
|
385
|
+
development:
|
386
|
+
foo: bar
|
387
|
+
YAML
|
388
|
+
Buildr.settings.profiles.should == { 'development'=> { 'foo'=>'bar' } }
|
389
|
+
end
|
390
|
+
|
391
|
+
it 'should return loaded profiles.yml file' do
|
392
|
+
write 'profiles.yml', <<-YAML
|
393
|
+
development:
|
394
|
+
foo: bar
|
395
|
+
YAML
|
396
|
+
Buildr.settings.profiles.should == { 'development'=> { 'foo'=>'bar' } }
|
397
|
+
end
|
398
|
+
|
399
|
+
it 'should fail if profiles.yaml file is not a hash' do
|
400
|
+
write 'profiles.yaml', 'foo bar'
|
401
|
+
lambda { Buildr.settings.profiles }.should raise_error(RuntimeError, /expecting.*profiles.yaml/i)
|
402
|
+
end
|
403
|
+
|
404
|
+
it 'should be empty hash if profiles.yaml file is empty' do
|
405
|
+
write 'profiles.yaml'
|
406
|
+
Buildr.settings.profiles.should == {}
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
describe 'profile' do
|
411
|
+
before do
|
412
|
+
end
|
413
|
+
|
414
|
+
it 'should be empty hash if no profiles.yaml' do
|
415
|
+
Buildr.settings.profile.should == {}
|
416
|
+
end
|
417
|
+
|
418
|
+
it 'should be empty hash if no matching profile' do
|
419
|
+
write 'profiles.yaml', <<-YAML
|
420
|
+
test:
|
421
|
+
foo: bar
|
422
|
+
YAML
|
423
|
+
Buildr.settings.profile.should == {}
|
424
|
+
end
|
425
|
+
|
426
|
+
it 'should return profile matching environment name' do
|
427
|
+
write 'profiles.yaml', <<-YAML
|
428
|
+
development:
|
429
|
+
foo: bar
|
430
|
+
test:
|
431
|
+
foo: baz
|
432
|
+
YAML
|
433
|
+
Buildr.settings.profile.should == { 'foo'=>'bar' }
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
437
|
+
describe 'buildfile task' do
|
438
|
+
before do
|
439
|
+
@buildfile_time = Time.now - 10
|
440
|
+
write 'buildfile'; File.utime(@buildfile_time, @buildfile_time, 'buildfile')
|
441
|
+
end
|
442
|
+
|
443
|
+
it 'should point to the buildfile' do
|
444
|
+
Buildr.application.buildfile.should point_to_path('buildfile')
|
445
|
+
end
|
446
|
+
|
447
|
+
it 'should be a defined task' do
|
448
|
+
Buildr.application.buildfile.should == file(File.expand_path('buildfile'))
|
449
|
+
end
|
450
|
+
|
451
|
+
it 'should ignore any rake namespace' do
|
452
|
+
namespace 'dummy_ns' do
|
453
|
+
Buildr.application.buildfile.should point_to_path('buildfile')
|
454
|
+
end
|
455
|
+
end
|
456
|
+
|
457
|
+
it 'should have the same timestamp as the buildfile' do
|
458
|
+
Buildr.application.buildfile.timestamp.should be_close(@buildfile_time, 1)
|
459
|
+
end
|
460
|
+
|
461
|
+
it 'should have the same timestamp as build.yaml if the latter is newer' do
|
462
|
+
write 'build.yaml'; File.utime(@buildfile_time + 5, @buildfile_time + 5, 'build.yaml')
|
463
|
+
Buildr.application.run
|
464
|
+
Buildr.application.buildfile.timestamp.should be_close(@buildfile_time + 5, 1)
|
465
|
+
end
|
466
|
+
|
467
|
+
it 'should have the same timestamp as the buildfile if build.yaml is older' do
|
468
|
+
write 'build.yaml'; File.utime(@buildfile_time - 5, @buildfile_time - 5, 'build.yaml')
|
469
|
+
Buildr.application.run
|
470
|
+
Buildr.application.buildfile.timestamp.should be_close(@buildfile_time, 1)
|
471
|
+
end
|
472
|
+
|
473
|
+
it 'should have the same timestamp as build.rb in home dir if the latter is newer' do
|
474
|
+
write 'home/buildr.rb'; File.utime(@buildfile_time + 5, @buildfile_time + 5, 'home/buildr.rb')
|
475
|
+
Buildr.application.send :load_tasks
|
476
|
+
Buildr.application.buildfile.timestamp.should be_close(@buildfile_time + 5, 1)
|
477
|
+
end
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
|
482
|
+
describe Buildr do
|
483
|
+
|
484
|
+
describe 'environment' do
|
485
|
+
it 'should be same as Buildr.application.environment' do
|
486
|
+
Buildr.environment.should eql(Buildr.application.environment)
|
487
|
+
end
|
488
|
+
end
|
489
|
+
|
490
|
+
describe 'application' do
|
491
|
+
it 'should be same as Rake.application' do
|
492
|
+
Buildr.application.should == Rake.application
|
493
|
+
end
|
494
|
+
end
|
495
|
+
|
496
|
+
describe 'settings' do
|
497
|
+
it 'should be same as Buildr.application.settings' do
|
498
|
+
Buildr.settings.should == Buildr.application.settings
|
499
|
+
end
|
500
|
+
end
|
501
|
+
end
|
502
|
+
|