buildr 1.3.5-x86-mswin32 → 1.4.0-x86-mswin32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +153 -8
- data/README.rdoc +1 -1
- data/addon/buildr/antlr.rb +5 -5
- data/addon/buildr/drb.rb +18 -18
- data/addon/buildr/hibernate.rb +18 -14
- data/addon/buildr/javacc.rb +4 -4
- data/addon/buildr/jetty.rb +5 -5
- data/addon/buildr/nailgun.rb +23 -23
- data/addon/buildr/openjpa.rb +1 -1
- 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/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/protobuf.rb +75 -0
- data/addon/buildr/xmlbeans.rb +5 -5
- data/buildr.buildfile +2 -2
- data/buildr.gemspec +8 -7
- data/doc/_layouts/default.html +2 -2
- data/doc/artifacts.textile +4 -4
- data/doc/building.textile +35 -3
- data/doc/contributing.textile +5 -0
- data/doc/download.textile +16 -5
- data/doc/extending.textile +38 -12
- data/doc/installing.textile +6 -5
- data/doc/languages.textile +182 -42
- data/doc/more_stuff.textile +2 -2
- data/doc/packaging.textile +14 -15
- data/doc/projects.textile +7 -2
- data/doc/quick_start.textile +4 -4
- data/doc/scripts/buildr-git.rb +63 -63
- data/doc/scripts/gitflow.rb +21 -21
- data/doc/settings_profiles.textile +9 -2
- data/doc/testing.textile +16 -5
- data/etc/KEYS +38 -0
- data/lib/buildr.rb +1 -1
- data/lib/buildr/core.rb +1 -0
- data/lib/buildr/core/application.rb +33 -27
- data/lib/buildr/core/build.rb +41 -28
- data/lib/buildr/core/cc.rb +172 -0
- data/lib/buildr/core/checks.rb +1 -1
- data/lib/buildr/core/common.rb +7 -6
- data/lib/buildr/core/compile.rb +7 -8
- data/lib/buildr/core/doc.rb +263 -0
- data/lib/buildr/core/environment.rb +6 -6
- data/lib/buildr/core/filter.rb +77 -35
- data/lib/buildr/core/generate.rb +7 -7
- data/lib/buildr/core/help.rb +1 -1
- data/lib/buildr/core/osx.rb +6 -6
- data/lib/buildr/core/progressbar.rb +4 -4
- data/lib/buildr/core/project.rb +144 -36
- data/lib/buildr/core/shell.rb +34 -34
- data/lib/buildr/core/test.rb +89 -20
- data/lib/buildr/core/transports.rb +8 -7
- data/lib/buildr/core/util.rb +77 -23
- data/lib/buildr/groovy/bdd.rb +5 -5
- data/lib/buildr/groovy/compiler.rb +19 -15
- data/lib/buildr/groovy/shell.rb +6 -6
- data/lib/buildr/ide/eclipse.rb +148 -75
- data/lib/buildr/ide/eclipse/java.rb +3 -3
- data/lib/buildr/ide/eclipse/plugin.rb +8 -5
- data/lib/buildr/ide/eclipse/scala.rb +4 -2
- data/lib/buildr/ide/idea.rb +2 -2
- data/lib/buildr/ide/idea7x.rb +23 -4
- data/lib/buildr/java.rb +1 -0
- data/lib/buildr/java/ant.rb +4 -4
- data/lib/buildr/java/bdd.rb +51 -54
- data/lib/buildr/java/cobertura.rb +57 -35
- data/lib/buildr/java/commands.rb +14 -5
- data/lib/buildr/java/compiler.rb +3 -217
- data/lib/buildr/java/deprecated.rb +4 -4
- data/lib/buildr/java/doc.rb +70 -0
- data/lib/buildr/java/emma.rb +22 -22
- data/lib/buildr/java/jruby.rb +4 -4
- data/lib/buildr/java/jtestr_runner.rb.erb +27 -25
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +8 -3
- data/lib/buildr/java/packaging.rb +30 -29
- data/lib/buildr/java/pom.rb +4 -4
- data/lib/buildr/java/rjb.rb +6 -6
- data/lib/buildr/java/test_result.rb +61 -85
- data/lib/buildr/java/tests.rb +44 -27
- data/lib/buildr/java/version_requirement.rb +8 -8
- data/lib/buildr/packaging/archive.rb +55 -22
- data/lib/buildr/packaging/artifact.rb +75 -36
- data/lib/buildr/packaging/artifact_namespace.rb +90 -78
- data/lib/buildr/packaging/artifact_search.rb +5 -5
- data/lib/buildr/packaging/gems.rb +11 -7
- data/lib/buildr/packaging/package.rb +10 -7
- data/lib/buildr/packaging/tar.rb +14 -14
- data/lib/buildr/packaging/version_requirement.rb +30 -10
- data/lib/buildr/packaging/ziptask.rb +51 -13
- data/lib/buildr/scala.rb +1 -0
- data/lib/buildr/scala/bdd.rb +25 -20
- data/lib/buildr/scala/compiler.rb +87 -40
- data/lib/buildr/scala/doc.rb +106 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
- data/lib/buildr/scala/shell.rb +14 -9
- data/lib/buildr/scala/tests.rb +33 -26
- data/lib/buildr/shell.rb +33 -33
- data/rakelib/all-in-one.rake +113 -0
- data/rakelib/checks.rake +1 -1
- data/rakelib/doc.rake +7 -0
- data/rakelib/package.rake +1 -1
- data/rakelib/release.rake +9 -6
- data/rakelib/rspec.rake +26 -7
- data/rakelib/setup.rake +15 -3
- data/rakelib/stage.rake +18 -11
- data/spec/addon/drb_spec.rb +25 -25
- data/spec/core/application_spec.rb +111 -21
- data/spec/core/build_spec.rb +16 -15
- data/spec/core/cc_spec.rb +174 -0
- data/spec/core/checks_spec.rb +34 -34
- data/spec/core/common_spec.rb +51 -5
- data/spec/core/compile_spec.rb +89 -14
- data/spec/core/extension_spec.rb +127 -19
- data/spec/core/generate_spec.rb +2 -2
- data/spec/core/project_spec.rb +10 -10
- data/spec/core/test_spec.rb +144 -35
- data/spec/core/transport_spec.rb +8 -8
- data/spec/core/util_spec.rb +63 -5
- data/spec/groovy/bdd_spec.rb +5 -5
- data/spec/groovy/compiler_spec.rb +29 -18
- data/spec/ide/eclipse_spec.rb +185 -9
- data/spec/ide/idea7x_spec.rb +22 -10
- data/spec/java/ant_spec.rb +9 -5
- data/spec/java/bdd_spec.rb +29 -37
- data/spec/java/cobertura_spec.rb +12 -12
- data/spec/java/commands_spec.rb +34 -0
- data/spec/java/compiler_spec.rb +53 -53
- data/spec/java/emma_spec.rb +11 -11
- data/spec/java/java_spec.rb +10 -10
- data/spec/java/packaging_spec.rb +67 -20
- data/spec/java/test_coverage_helper.rb +18 -18
- data/spec/java/tests_spec.rb +13 -9
- data/spec/packaging/archive_spec.rb +187 -20
- data/spec/packaging/artifact_namespace_spec.rb +172 -83
- data/spec/packaging/artifact_spec.rb +83 -18
- data/spec/packaging/packaging_spec.rb +41 -14
- data/spec/sandbox.rb +23 -12
- data/spec/scala/bdd_spec.rb +13 -8
- data/spec/scala/compiler_spec.rb +18 -13
- data/spec/scala/scala.rb +3 -3
- data/spec/scala/tests_spec.rb +46 -24
- data/spec/spec_helpers.rb +28 -10
- data/spec/version_requirement_spec.rb +25 -11
- metadata +149 -133
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +0 -35
- data/rakelib/stage.rake~ +0 -213
data/rakelib/setup.rake
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
require 'jruby' if RUBY_PLATFORM[/java/]
|
18
18
|
require 'rubygems/source_info_cache'
|
19
19
|
|
20
|
-
RAKE_SUDO = case (ENV['RAKE_SUDO'] or '
|
20
|
+
RAKE_SUDO = case (ENV['RAKE_SUDO'] or 'false').strip.downcase
|
21
21
|
when 'yes', 'true'
|
22
22
|
true
|
23
23
|
else
|
@@ -35,7 +35,14 @@ def install_gem(name, options = {})
|
|
35
35
|
args = []
|
36
36
|
args << 'sudo' << 'env' << "JAVA_HOME=#{ENV['JAVA_HOME']}" if sudo_needed? and RAKE_SUDO
|
37
37
|
args << rb_bin << '-S' << 'gem' << 'install' << name
|
38
|
-
|
38
|
+
|
39
|
+
if (spec.respond_to? :requirement)
|
40
|
+
args << '--version' << dep.requirement.to_s
|
41
|
+
else
|
42
|
+
# Dependency.version_requirements deprecated in rubygems 1.3.6
|
43
|
+
args << '--version' << dep.version_requirements.to_s
|
44
|
+
end
|
45
|
+
|
39
46
|
args << '--source' << options[:source] if options[:source]
|
40
47
|
args << '--source' << 'http://gems.rubyforge.org'
|
41
48
|
args << '--install-dir' << ENV['GEM_HOME'] if ENV['GEM_HOME']
|
@@ -49,6 +56,11 @@ desc "If you're building from sources, run this task first to setup the necessar
|
|
49
56
|
task :setup do
|
50
57
|
missing = spec.dependencies.select { |dep| Gem::SourceIndex.from_installed_gems.search(dep).empty? }
|
51
58
|
missing.each do |dep|
|
52
|
-
|
59
|
+
if (spec.respond_to? :requirement)
|
60
|
+
install_gem dep.name, :version=>dep.requirement
|
61
|
+
else
|
62
|
+
# Dependency.version_requirements deprecated in rubygems 1.3.6
|
63
|
+
install_gem dep.name, :version=>dep.version_requirements
|
64
|
+
end
|
53
65
|
end
|
54
66
|
end
|
data/rakelib/stage.rake
CHANGED
@@ -23,13 +23,14 @@ rescue LoadError
|
|
23
23
|
task(:setup) { install_gem 'rubyforge' }
|
24
24
|
end
|
25
25
|
|
26
|
+
gpg_cmd = 'gpg2'
|
26
27
|
|
27
28
|
task :prepare do |task, args|
|
28
29
|
# Make sure we're doing a release from checked code.
|
29
30
|
lambda do
|
30
31
|
puts "Checking there are no local changes ... "
|
31
32
|
svn = `svn status`
|
32
|
-
|
33
|
+
fail "Cannot release unless all local changes are in SVN:\n#{svn}" unless svn.empty?
|
33
34
|
git = `git status`
|
34
35
|
fail "Cannot release unless all local changes are in Git:\n#{git}" if git[/^#\t/]
|
35
36
|
puts "[X] There are no local changes, everything is in source control"
|
@@ -40,14 +41,19 @@ task :prepare do |task, args|
|
|
40
41
|
puts "Checking that CHANGELOG indicates most recent version and today's date ... "
|
41
42
|
expecting = "#{spec.version} (#{Time.now.strftime('%Y-%m-%d')})"
|
42
43
|
header = File.readlines('CHANGELOG').first.chomp
|
43
|
-
|
44
|
+
fail "Expecting CHANGELOG to start with #{expecting}, but found #{header} instead" unless expecting == header
|
44
45
|
puts "[x] CHANGELOG indicates most recent version and today's date"
|
45
46
|
end.call
|
46
47
|
|
47
48
|
# Need GPG to sign the packages.
|
48
49
|
lambda do
|
49
50
|
args.gpg or fail "Please run with gpg=<argument for gpg --local-user>"
|
50
|
-
|
51
|
+
gpg_ok = `gpg2 --list-keys #{args.gpg}`
|
52
|
+
if !$?.success?
|
53
|
+
gpg_ok = `gpg --list-keys #{args.gpg}`
|
54
|
+
gpg_cmd = 'gpg'
|
55
|
+
end
|
56
|
+
fail "No GPG user #{args.gpg}" if gpg_ok.empty?
|
51
57
|
end.call
|
52
58
|
|
53
59
|
task(:license).invoke
|
@@ -73,7 +79,7 @@ task :prepare do |task, args|
|
|
73
79
|
lambda do
|
74
80
|
puts "[!] Make sure you have admin privileges to make a release on RubyForge"
|
75
81
|
rubyforge = RubyForge.new.configure
|
76
|
-
rubyforge.login
|
82
|
+
rubyforge.login
|
77
83
|
rubyforge.scrape_project(spec.name)
|
78
84
|
end.call
|
79
85
|
|
@@ -106,14 +112,14 @@ task :stage=>['setup', 'doc:setup', :clobber, :prepare] do |task, args|
|
|
106
112
|
task(:package).invoke
|
107
113
|
mkpath '_staged/dist'
|
108
114
|
FileList['pkg/*.{gem,zip,tgz}'].each do |source|
|
109
|
-
pkg = source.pathmap('_staged/dist/%n%x')
|
115
|
+
pkg = source.pathmap('_staged/dist/%n%x')
|
110
116
|
cp source, pkg
|
111
117
|
bytes = File.open(pkg, 'rb') { |file| file.read }
|
112
118
|
File.open(pkg + '.md5', 'w') { |file| file.write Digest::MD5.hexdigest(bytes) << ' ' << File.basename(pkg) }
|
113
119
|
File.open(pkg + '.sha1', 'w') { |file| file.write Digest::SHA1.hexdigest(bytes) << ' ' << File.basename(pkg) }
|
114
|
-
sh
|
120
|
+
sh gpg_cmd, '--local-user', args.gpg, '--armor', '--output', pkg + '.asc', '--detach-sig', pkg, :verbose=>true
|
115
121
|
end
|
116
|
-
cp 'etc/KEYS', '_staged'
|
122
|
+
cp 'etc/KEYS', '_staged/dist'
|
117
123
|
puts "[X] Created and signed release packages in _staged/dist"
|
118
124
|
end.call
|
119
125
|
|
@@ -121,10 +127,11 @@ task :stage=>['setup', 'doc:setup', :clobber, :prepare] do |task, args|
|
|
121
127
|
# want to do that before generating the site/documentation.
|
122
128
|
lambda do
|
123
129
|
puts "Updating download page with links to release packages ... "
|
124
|
-
|
130
|
+
mirror = "http://www.apache.org/dyn/closer.cgi/#{spec.name}/#{spec.version}"
|
131
|
+
official = "http://www.apache.org/dist/#{spec.name}/#{spec.version}"
|
125
132
|
rows = FileList['_staged/dist/*.{gem,tgz,zip}'].map { |pkg|
|
126
133
|
name, md5 = File.basename(pkg), Digest::MD5.file(pkg).to_s
|
127
|
-
%{| "#{name}":#{
|
134
|
+
%{| "#{name}":#{mirror}/#{name} | "#{md5}":#{official}/#{name}.md5 | "Sig":#{official}/#{name}.asc |}
|
128
135
|
}
|
129
136
|
textile = <<-TEXTILE
|
130
137
|
h3. #{spec.name} #{spec.version} (#{Time.now.strftime('%Y-%m-%d')})
|
@@ -132,7 +139,7 @@ h3. #{spec.name} #{spec.version} (#{Time.now.strftime('%Y-%m-%d')})
|
|
132
139
|
|_. Package |_. MD5 Checksum |_. PGP |
|
133
140
|
#{rows.join("\n")}
|
134
141
|
|
135
|
-
p>. ("Release signing keys":#{
|
142
|
+
p>. ("Release signing keys":#{official}/KEYS)
|
136
143
|
TEXTILE
|
137
144
|
file_name = 'doc/download.textile'
|
138
145
|
print "Adding download links to #{file_name} ... "
|
@@ -161,7 +168,7 @@ p>. ("Release signing keys":#{url}/KEYS)
|
|
161
168
|
sh 'rsync', '--progress', '--recursive', '_staged/', url
|
162
169
|
puts "[X] Uploaded _staged directory to #{url}"
|
163
170
|
end.call
|
164
|
-
|
171
|
+
|
165
172
|
|
166
173
|
# Prepare a release vote email. In the distant future this will also send the
|
167
174
|
# email for you and vote on it.
|
data/spec/addon/drb_spec.rb
CHANGED
@@ -12,16 +12,16 @@
|
|
12
12
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
13
|
# License for the specific language governing permissions and limitations under
|
14
14
|
# the License.
|
15
|
-
|
16
|
-
|
15
|
+
|
16
|
+
|
17
17
|
require File.expand_path('../spec_helpers', File.dirname(__FILE__))
|
18
18
|
require 'stringio'
|
19
19
|
Sandbox.require_optional_extension 'buildr/drb'
|
20
20
|
|
21
21
|
|
22
|
-
describe Buildr::DRbApplication do
|
22
|
+
describe Buildr::DRbApplication do
|
23
23
|
|
24
|
-
module DRbHelper
|
24
|
+
module DRbHelper
|
25
25
|
attr_accessor :app, :drb, :cfg
|
26
26
|
|
27
27
|
def use_stdio(stdin = nil, stdout = nil, stderr = nil)
|
@@ -30,7 +30,7 @@ describe Buildr::DRbApplication do
|
|
30
30
|
stderr ||= StringIO.new
|
31
31
|
cfg.update :in => stdin, :out => stdout, :err => stderr
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
def remote_run(*argv)
|
35
35
|
cfg.update :argv => argv
|
36
36
|
drb.remote_run(cfg)
|
@@ -48,7 +48,7 @@ describe Buildr::DRbApplication do
|
|
48
48
|
$stdout.puts "#{t.name} from #{t.source}"
|
49
49
|
end
|
50
50
|
|
51
|
-
task('hello') do
|
51
|
+
task('hello') do
|
52
52
|
$stdout.puts 'hi'
|
53
53
|
end
|
54
54
|
|
@@ -81,7 +81,7 @@ describe Buildr::DRbApplication do
|
|
81
81
|
end
|
82
82
|
|
83
83
|
include DRbHelper
|
84
|
-
|
84
|
+
|
85
85
|
before(:each) do
|
86
86
|
@in, @out, @err = $stdin, $stdout, $stderr
|
87
87
|
@cfg = {
|
@@ -96,7 +96,7 @@ describe Buildr::DRbApplication do
|
|
96
96
|
after(:each) do
|
97
97
|
$stdin, $stdout, $stderr = @in, @out, @err
|
98
98
|
end
|
99
|
-
|
99
|
+
|
100
100
|
describe '.run' do
|
101
101
|
it 'starts server if no server is running' do
|
102
102
|
drb.should_receive(:connect).and_raise DRb::DRbConnError
|
@@ -114,11 +114,11 @@ describe Buildr::DRbApplication do
|
|
114
114
|
end
|
115
115
|
|
116
116
|
describe '.remote_run' do
|
117
|
-
|
117
|
+
|
118
118
|
describe 'stdout' do
|
119
|
-
it 'is redirected to client' do
|
119
|
+
it 'is redirected to client' do
|
120
120
|
use_stdio
|
121
|
-
Buildr.application.should_receive(:remote_run) do
|
121
|
+
Buildr.application.should_receive(:remote_run) do
|
122
122
|
$stdout.puts "HELLO"
|
123
123
|
end
|
124
124
|
remote_run
|
@@ -126,10 +126,10 @@ describe Buildr::DRbApplication do
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
|
-
describe 'stderr' do
|
129
|
+
describe 'stderr' do
|
130
130
|
it 'is redirected to client' do
|
131
131
|
use_stdio
|
132
|
-
Buildr.application.should_receive(:remote_run) do
|
132
|
+
Buildr.application.should_receive(:remote_run) do
|
133
133
|
$stderr.puts "HELLO"
|
134
134
|
end
|
135
135
|
remote_run
|
@@ -142,7 +142,7 @@ describe Buildr::DRbApplication do
|
|
142
142
|
use_stdio
|
143
143
|
cfg[:in].should_receive(:gets).and_return("HELLO\n")
|
144
144
|
result = nil
|
145
|
-
Buildr.application.should_receive(:remote_run) do
|
145
|
+
Buildr.application.should_receive(:remote_run) do
|
146
146
|
result = $stdin.gets
|
147
147
|
end
|
148
148
|
remote_run
|
@@ -152,7 +152,7 @@ describe Buildr::DRbApplication do
|
|
152
152
|
|
153
153
|
describe 'server ARGV' do
|
154
154
|
it 'is replaced with client argv' do
|
155
|
-
Buildr.application.should_receive(:remote_run) do
|
155
|
+
Buildr.application.should_receive(:remote_run) do
|
156
156
|
ARGV.should eql(['hello'])
|
157
157
|
end
|
158
158
|
remote_run 'hello'
|
@@ -164,7 +164,7 @@ describe Buildr::DRbApplication do
|
|
164
164
|
app.instance_eval { @rakefile = nil }
|
165
165
|
write_buildfile
|
166
166
|
end
|
167
|
-
|
167
|
+
|
168
168
|
it 'should load the buildfile' do
|
169
169
|
app.should_receive(:top_level)
|
170
170
|
lambda { remote_run }.should run_task('foo')
|
@@ -172,14 +172,14 @@ describe Buildr::DRbApplication do
|
|
172
172
|
end
|
173
173
|
|
174
174
|
describe 'with unmodified buildfile' do
|
175
|
-
|
176
|
-
before(:each) do
|
175
|
+
|
176
|
+
before(:each) do
|
177
177
|
write_buildfile
|
178
178
|
app.options.rakelib = []
|
179
179
|
app.send :load_buildfile
|
180
180
|
drb.save_snapshot(app)
|
181
181
|
end
|
182
|
-
|
182
|
+
|
183
183
|
it 'should not reload the buildfile' do
|
184
184
|
app.should_not_receive(:reload_buildfile)
|
185
185
|
app.should_receive(:top_level)
|
@@ -235,12 +235,12 @@ describe Buildr::DRbApplication do
|
|
235
235
|
remote_run 'foo:empty'
|
236
236
|
app.instance_eval { @rules.size }.should eql(orig)
|
237
237
|
end
|
238
|
-
|
238
|
+
|
239
239
|
end
|
240
240
|
|
241
241
|
describe 'with modified buildfile' do
|
242
|
-
|
243
|
-
before(:each) do
|
242
|
+
|
243
|
+
before(:each) do
|
244
244
|
write_buildfile
|
245
245
|
app.options.rakelib = []
|
246
246
|
app.send :load_buildfile
|
@@ -251,12 +251,12 @@ describe Buildr::DRbApplication do
|
|
251
251
|
$stdout.puts "#{t.name} from #{t.source}"
|
252
252
|
end
|
253
253
|
define('foo') do
|
254
|
-
task('hello') do
|
254
|
+
task('hello') do
|
255
255
|
$stdout.puts 'bye'
|
256
256
|
end
|
257
257
|
task('empty')
|
258
258
|
define('bar') do
|
259
|
-
|
259
|
+
|
260
260
|
end
|
261
261
|
end
|
262
262
|
}
|
@@ -277,7 +277,7 @@ describe Buildr::DRbApplication do
|
|
277
277
|
remote_run
|
278
278
|
app.lookup('foo:delete_me').should be_nil
|
279
279
|
end
|
280
|
-
|
280
|
+
|
281
281
|
it 'should redefine tasks actions' do
|
282
282
|
actions = app.lookup('foo:empty').instance_eval { @actions }
|
283
283
|
actions.should be_empty # no action
|
@@ -72,7 +72,7 @@ describe Buildr::Application do
|
|
72
72
|
Buildr.application.environment.should eql('test')
|
73
73
|
ENV['BUILDR_ENV'].should eql('test')
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
it 'should be echoed to user' do
|
77
77
|
write 'buildfile'
|
78
78
|
ENV['BUILDR_ENV'] = 'spec'
|
@@ -80,12 +80,22 @@ describe Buildr::Application do
|
|
80
80
|
lambda { Buildr.application.send :load_buildfile }.should show(%r{(in .*, spec)})
|
81
81
|
end
|
82
82
|
end
|
83
|
-
|
83
|
+
|
84
84
|
describe 'options' do
|
85
85
|
it "should have 'tasks' as the sole default rakelib" do
|
86
86
|
Buildr.application.send(:handle_options)
|
87
87
|
Buildr.application.options.rakelib.should == ['tasks']
|
88
88
|
end
|
89
|
+
|
90
|
+
it 'should show the version when prompted with -V' do
|
91
|
+
ARGV.push('-V')
|
92
|
+
test_exit(0) { Buildr.application.send(:handle_options) }.should show(/Buildr #{Buildr::VERSION}.*/)
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'should show the version when prompted with --version' do
|
96
|
+
ARGV.push('--version')
|
97
|
+
test_exit(0) { Buildr.application.send(:handle_options) }.should show(/Buildr #{Buildr::VERSION}.*/)
|
98
|
+
end
|
89
99
|
end
|
90
100
|
|
91
101
|
describe 'gems' do
|
@@ -248,45 +258,45 @@ describe Buildr::Application do
|
|
248
258
|
@original_loaded_features = $LOADED_FEATURES.dup
|
249
259
|
Buildr.application.options.rakelib = ["tasks"]
|
250
260
|
end
|
251
|
-
|
261
|
+
|
252
262
|
after do
|
253
263
|
$taskfiles = nil
|
254
264
|
($LOADED_FEATURES - @original_loaded_features).each do |new_load|
|
255
265
|
$LOADED_FEATURES.delete(new_load)
|
256
266
|
end
|
257
267
|
end
|
258
|
-
|
268
|
+
|
259
269
|
def write_task(filename)
|
260
270
|
write filename, <<-RUBY
|
261
271
|
$taskfiles ||= []
|
262
272
|
$taskfiles << __FILE__
|
263
273
|
RUBY
|
264
274
|
end
|
265
|
-
|
275
|
+
|
266
276
|
def loaded_tasks
|
267
277
|
@loaded ||= Buildr.application.load_tasks
|
268
278
|
$taskfiles
|
269
279
|
end
|
270
|
-
|
280
|
+
|
271
281
|
it "should load {options.rakelib}/foo.rake" do
|
272
282
|
write_task 'tasks/foo.rake'
|
273
283
|
loaded_tasks.should have(1).task
|
274
284
|
loaded_tasks.first.should =~ %r{tasks/foo\.rake$}
|
275
285
|
end
|
276
|
-
|
286
|
+
|
277
287
|
it 'should load all *.rake files from the rakelib' do
|
278
288
|
write_task 'tasks/bar.rake'
|
279
289
|
write_task 'tasks/quux.rake'
|
280
290
|
loaded_tasks.should have(2).tasks
|
281
291
|
end
|
282
|
-
|
292
|
+
|
283
293
|
it 'should not load files which do not have the .rake extension' do
|
284
294
|
write_task 'tasks/foo.rb'
|
285
295
|
write_task 'tasks/bar.rake'
|
286
296
|
loaded_tasks.should have(1).task
|
287
297
|
loaded_tasks.first.should =~ %r{tasks/bar\.rake$}
|
288
298
|
end
|
289
|
-
|
299
|
+
|
290
300
|
it 'should load files only from the directory specified in the rakelib option' do
|
291
301
|
Buildr.application.options.rakelib = ['extensions']
|
292
302
|
write_task 'extensions/amp.rake'
|
@@ -297,7 +307,7 @@ describe Buildr::Application do
|
|
297
307
|
loaded_tasks.select{|x| x =~ %r{extensions/#{filename}\.rake}}.should have(1).entry
|
298
308
|
end
|
299
309
|
end
|
300
|
-
|
310
|
+
|
301
311
|
it 'should load files from all the directories specified in the rakelib option' do
|
302
312
|
Buildr.application.options.rakelib = ['ext', 'more', 'tasks']
|
303
313
|
write_task 'ext/foo.rake'
|
@@ -306,17 +316,71 @@ describe Buildr::Application do
|
|
306
316
|
write_task 'more/baz.rake'
|
307
317
|
loaded_tasks.should have(4).tasks
|
308
318
|
end
|
309
|
-
|
319
|
+
|
310
320
|
it 'should not load files from the rakelib more than once' do
|
311
321
|
write_task 'tasks/new_one.rake'
|
312
322
|
write_task 'tasks/already.rake'
|
313
323
|
$LOADED_FEATURES << 'tasks/already.rake'
|
314
|
-
|
324
|
+
|
315
325
|
loaded_tasks.should have(1).task
|
316
326
|
loaded_tasks.first.should =~ %r{tasks/new_one\.rake$}
|
317
327
|
end
|
318
328
|
end
|
319
329
|
|
330
|
+
describe 'exception handling' do
|
331
|
+
|
332
|
+
it 'should exit when given a SystemExit exception' do
|
333
|
+
test_exit(3) { Buildr.application.standard_exception_handling { raise SystemExit.new(3) } }
|
334
|
+
end
|
335
|
+
|
336
|
+
it 'should exit with status 1 when given an OptionParser::ParseError exception' do
|
337
|
+
test_exit(1) { Buildr.application.standard_exception_handling { raise OptionParser::ParseError.new() } }
|
338
|
+
end
|
339
|
+
|
340
|
+
it 'should exit with status 1 when given any other type of exception exception' do
|
341
|
+
test_exit(1) { Buildr.application.standard_exception_handling { raise Exception.new() } }
|
342
|
+
end
|
343
|
+
|
344
|
+
it 'should print the class name and the message when receiving an exception (except when the exception is named Exception)' do
|
345
|
+
|
346
|
+
# Our fake $stderr for the exercise. We could start it with a matcher instead
|
347
|
+
class FakeStdErr
|
348
|
+
|
349
|
+
attr_accessor :messages
|
350
|
+
|
351
|
+
def puts(*args)
|
352
|
+
@messages ||= []
|
353
|
+
@messages += args
|
354
|
+
end
|
355
|
+
|
356
|
+
alias :write :puts
|
357
|
+
end
|
358
|
+
|
359
|
+
# Save the old $stderr and make sure to restore it in the end.
|
360
|
+
old_stderr = $stderr
|
361
|
+
begin
|
362
|
+
|
363
|
+
$stderr = FakeStdErr.new
|
364
|
+
test_exit(1) {
|
365
|
+
Buildr.application.send :standard_exception_handling do
|
366
|
+
class MyOwnNicelyNamedException < Exception
|
367
|
+
end
|
368
|
+
raise MyOwnNicelyNamedException.new('My message')
|
369
|
+
end
|
370
|
+
}.call
|
371
|
+
$stderr.messages.select {|msg| msg =~ /.*MyOwnNicelyNamedException : My message.*/}.size.should == 1
|
372
|
+
$stderr.messages.clear
|
373
|
+
test_exit(1) {
|
374
|
+
Buildr.application.send :standard_exception_handling do
|
375
|
+
raise Exception.new('My message')
|
376
|
+
end
|
377
|
+
}.call
|
378
|
+
$stderr.messages.select {|msg| msg =~ /.*My message.*/ && !(msg =~ /Exception/)}.size.should == 1
|
379
|
+
end
|
380
|
+
$stderr = old_stderr
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
320
384
|
end
|
321
385
|
|
322
386
|
|
@@ -439,48 +503,55 @@ describe Buildr, 'settings' do
|
|
439
503
|
@buildfile_time = Time.now - 10
|
440
504
|
write 'buildfile'; File.utime(@buildfile_time, @buildfile_time, 'buildfile')
|
441
505
|
end
|
442
|
-
|
506
|
+
|
443
507
|
it 'should point to the buildfile' do
|
444
508
|
Buildr.application.buildfile.should point_to_path('buildfile')
|
445
509
|
end
|
446
|
-
|
510
|
+
|
447
511
|
it 'should be a defined task' do
|
448
512
|
Buildr.application.buildfile.should == file(File.expand_path('buildfile'))
|
449
513
|
end
|
450
|
-
|
514
|
+
|
451
515
|
it 'should ignore any rake namespace' do
|
452
516
|
namespace 'dummy_ns' do
|
453
517
|
Buildr.application.buildfile.should point_to_path('buildfile')
|
454
518
|
end
|
455
519
|
end
|
456
|
-
|
520
|
+
|
457
521
|
it 'should have the same timestamp as the buildfile' do
|
458
522
|
Buildr.application.buildfile.timestamp.should be_close(@buildfile_time, 1)
|
459
523
|
end
|
460
|
-
|
524
|
+
|
461
525
|
it 'should have the same timestamp as build.yaml if the latter is newer' do
|
462
526
|
write 'build.yaml'; File.utime(@buildfile_time + 5, @buildfile_time + 5, 'build.yaml')
|
463
527
|
Buildr.application.run
|
464
528
|
Buildr.application.buildfile.timestamp.should be_close(@buildfile_time + 5, 1)
|
465
529
|
end
|
466
|
-
|
530
|
+
|
467
531
|
it 'should have the same timestamp as the buildfile if build.yaml is older' do
|
468
532
|
write 'build.yaml'; File.utime(@buildfile_time - 5, @buildfile_time - 5, 'build.yaml')
|
469
533
|
Buildr.application.run
|
470
534
|
Buildr.application.buildfile.timestamp.should be_close(@buildfile_time, 1)
|
471
535
|
end
|
472
|
-
|
473
|
-
it 'should have the same timestamp as build.rb in home dir if the latter is newer' do
|
536
|
+
|
537
|
+
it 'should have the same timestamp as build.rb in home dir if the latter is newer (until version 1.6)' do
|
538
|
+
Buildr::VERSION.should < '1.6'
|
474
539
|
write 'home/buildr.rb'; File.utime(@buildfile_time + 5, @buildfile_time + 5, 'home/buildr.rb')
|
475
540
|
Buildr.application.send :load_tasks
|
476
541
|
Buildr.application.buildfile.timestamp.should be_close(@buildfile_time + 5, 1)
|
477
542
|
end
|
543
|
+
|
544
|
+
it 'should have the same timestamp as build.rb in home dir if the latter is newer' do
|
545
|
+
write 'home/.buildr/buildr.rb'; File.utime(@buildfile_time + 5, @buildfile_time + 5, 'home/.buildr/buildr.rb')
|
546
|
+
Buildr.application.send :load_tasks
|
547
|
+
Buildr.application.buildfile.timestamp.should be_close(@buildfile_time + 5, 1)
|
548
|
+
end
|
478
549
|
end
|
479
550
|
end
|
480
551
|
|
481
552
|
|
482
553
|
describe Buildr do
|
483
|
-
|
554
|
+
|
484
555
|
describe 'environment' do
|
485
556
|
it 'should be same as Buildr.application.environment' do
|
486
557
|
Buildr.environment.should eql(Buildr.application.environment)
|
@@ -498,5 +569,24 @@ describe Buildr do
|
|
498
569
|
Buildr.settings.should == Buildr.application.settings
|
499
570
|
end
|
500
571
|
end
|
572
|
+
|
573
|
+
end
|
574
|
+
|
575
|
+
describe Rake do
|
576
|
+
describe 'define_task' do
|
577
|
+
it 'should restore call chain when invoke is called' do
|
578
|
+
task1 = Rake::Task.define_task('task1') do
|
579
|
+
end
|
580
|
+
|
581
|
+
task2 = Rake::Task.define_task('task2') do
|
582
|
+
chain1 = Thread.current[:rake_chain]
|
583
|
+
task1.invoke
|
584
|
+
chain2 = Thread.current[:rake_chain]
|
585
|
+
chain2.should == chain1
|
586
|
+
end
|
587
|
+
|
588
|
+
task2.invoke
|
589
|
+
end
|
590
|
+
end
|
501
591
|
end
|
502
592
|
|