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.
Files changed (127) hide show
  1. data/CHANGELOG +90 -8
  2. data/{README → README.rdoc} +29 -16
  3. data/Rakefile +17 -19
  4. data/_buildr +50 -0
  5. data/addon/buildr/cobertura.rb +47 -44
  6. data/addon/buildr/emma.rb +237 -0
  7. data/addon/buildr/jetty.rb +1 -1
  8. data/addon/buildr/nailgun.rb +581 -661
  9. data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail$Main.class +0 -0
  10. data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.class +0 -0
  11. data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.java +0 -0
  12. data/addon/buildr/xmlbeans.rb +1 -1
  13. data/bin/buildr +9 -2
  14. data/buildr.buildfile +53 -0
  15. data/buildr.gemspec +23 -15
  16. data/doc/css/default.css +51 -48
  17. data/doc/css/print.css +60 -55
  18. data/doc/css/syntax.css +40 -31
  19. data/doc/images/growl-icon.tiff +0 -0
  20. data/doc/images/project-structure.png +0 -0
  21. data/doc/pages/artifacts.textile +46 -156
  22. data/doc/pages/building.textile +63 -324
  23. data/doc/pages/contributing.textile +116 -88
  24. data/doc/pages/download.textile +20 -15
  25. data/doc/pages/extending.textile +27 -81
  26. data/doc/pages/getting_started.textile +47 -111
  27. data/doc/pages/index.textile +19 -37
  28. data/doc/pages/languages.textile +407 -0
  29. data/doc/pages/more_stuff.textile +92 -173
  30. data/doc/pages/packaging.textile +72 -237
  31. data/doc/pages/projects.textile +58 -233
  32. data/doc/pages/recipes.textile +19 -43
  33. data/doc/pages/settings_profiles.textile +39 -104
  34. data/doc/pages/testing.textile +41 -304
  35. data/doc/pages/troubleshooting.textile +29 -47
  36. data/doc/pages/whats_new.textile +66 -157
  37. data/doc/print.haml +0 -1
  38. data/doc/print.toc.yaml +1 -0
  39. data/doc/scripts/buildr-git.rb +1 -1
  40. data/doc/scripts/install-jruby.sh +1 -1
  41. data/doc/scripts/install-linux.sh +4 -4
  42. data/doc/site.toc.yaml +8 -5
  43. data/{KEYS → etc/KEYS} +0 -0
  44. data/etc/git-svn-authors +16 -0
  45. data/lib/buildr.rb +2 -13
  46. data/lib/buildr/core/application.rb +200 -95
  47. data/lib/buildr/core/application_cli.rb +6 -1
  48. data/lib/buildr/core/build.rb +140 -91
  49. data/lib/buildr/core/checks.rb +5 -5
  50. data/lib/buildr/core/common.rb +1 -1
  51. data/lib/buildr/core/compile.rb +14 -12
  52. data/lib/buildr/core/filter.rb +151 -46
  53. data/lib/buildr/core/generate.rb +9 -7
  54. data/lib/buildr/core/progressbar.rb +1 -1
  55. data/lib/buildr/core/project.rb +8 -7
  56. data/lib/buildr/core/test.rb +54 -29
  57. data/lib/buildr/core/transports.rb +25 -20
  58. data/lib/buildr/core/util.rb +80 -26
  59. data/lib/buildr/groovy.rb +18 -0
  60. data/lib/buildr/groovy/bdd.rb +105 -0
  61. data/lib/buildr/groovy/compiler.rb +138 -0
  62. data/lib/buildr/ide/eclipse.rb +102 -71
  63. data/lib/buildr/ide/idea.rb +7 -12
  64. data/lib/buildr/ide/idea7x.rb +20 -20
  65. data/lib/buildr/java.rb +4 -7
  66. data/lib/buildr/java/ant.rb +26 -5
  67. data/lib/buildr/java/bdd.rb +447 -0
  68. data/lib/buildr/java/commands.rb +8 -9
  69. data/lib/buildr/java/{compilers.rb → compiler.rb} +8 -90
  70. data/lib/buildr/java/jruby.rb +29 -11
  71. data/lib/buildr/java/jtestr_runner.rb.erb +114 -0
  72. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  73. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +4 -1
  74. data/lib/buildr/java/packaging.rb +23 -16
  75. data/lib/buildr/java/pom.rb +1 -1
  76. data/lib/buildr/java/rjb.rb +21 -8
  77. data/lib/buildr/java/test_result.rb +277 -0
  78. data/lib/buildr/java/{test_frameworks.rb → tests.rb} +121 -88
  79. data/lib/buildr/packaging/artifact.rb +12 -11
  80. data/lib/buildr/packaging/artifact_namespace.rb +7 -4
  81. data/lib/buildr/packaging/gems.rb +3 -3
  82. data/lib/buildr/packaging/zip.rb +13 -10
  83. data/lib/buildr/resources/buildr.icns +0 -0
  84. data/lib/buildr/scala.rb +19 -0
  85. data/lib/buildr/scala/compiler.rb +109 -0
  86. data/lib/buildr/scala/tests.rb +203 -0
  87. data/rakelib/apache.rake +31 -41
  88. data/rakelib/doc.rake +2 -2
  89. data/rakelib/package.rake +31 -2
  90. data/rakelib/rspec.rake +22 -20
  91. data/rakelib/rubyforge.rake +1 -0
  92. data/rakelib/setup.rake +34 -9
  93. data/spec/addon/cobertura_spec.rb +77 -0
  94. data/spec/addon/emma_spec.rb +120 -0
  95. data/spec/addon/test_coverage_spec.rb +249 -0
  96. data/spec/{application_spec.rb → core/application_spec.rb} +82 -4
  97. data/spec/{artifact_namespace_spec.rb → core/artifact_namespace_spec.rb} +12 -1
  98. data/spec/core/build_spec.rb +415 -0
  99. data/spec/{checks_spec.rb → core/checks_spec.rb} +1 -1
  100. data/spec/{common_spec.rb → core/common_spec.rb} +119 -30
  101. data/spec/{compile_spec.rb → core/compile_spec.rb} +17 -13
  102. data/spec/{project_spec.rb → core/project_spec.rb} +9 -6
  103. data/spec/{test_spec.rb → core/test_spec.rb} +226 -32
  104. data/spec/{transport_spec.rb → core/transport_spec.rb} +35 -23
  105. data/spec/groovy/bdd_spec.rb +80 -0
  106. data/spec/{groovy_compilers_spec.rb → groovy/compiler_spec.rb} +1 -1
  107. data/spec/ide/eclipse_spec.rb +243 -0
  108. data/spec/{java_spec.rb → java/ant.rb} +7 -17
  109. data/spec/java/bdd_spec.rb +358 -0
  110. data/spec/{java_compilers_spec.rb → java/compiler_spec.rb} +1 -1
  111. data/spec/java/java_spec.rb +88 -0
  112. data/spec/{java_packaging_spec.rb → java/packaging_spec.rb} +65 -4
  113. data/spec/{java_test_frameworks_spec.rb → java/tests_spec.rb} +50 -10
  114. data/spec/{archive_spec.rb → packaging/archive_spec.rb} +12 -2
  115. data/spec/{artifact_spec.rb → packaging/artifact_spec.rb} +10 -3
  116. data/spec/{packaging_helper.rb → packaging/packaging_helper.rb} +0 -0
  117. data/spec/{packaging_spec.rb → packaging/packaging_spec.rb} +1 -1
  118. data/spec/sandbox.rb +25 -4
  119. data/spec/{scala_compilers_spec.rb → scala/compiler_spec.rb} +1 -1
  120. data/spec/scala/tests_spec.rb +215 -0
  121. data/spec/spec_helpers.rb +38 -17
  122. metadata +119 -69
  123. data/lib/buildr/java/bdd_frameworks.rb +0 -265
  124. data/lib/buildr/java/groovyc.rb +0 -137
  125. data/spec/build_spec.rb +0 -193
  126. data/spec/java_bdd_frameworks_spec.rb +0 -238
  127. data/spec/spec.opts +0 -6
@@ -13,26 +13,16 @@
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')
17
16
 
18
- describe ENV, 'JAVA_HOME on OS X' do
19
- before do
20
- @old_home, ENV['JAVA_HOME'] = ENV['JAVA_HOME'], nil
21
- Config::CONFIG.should_receive(:[]).with('host_os').and_return('darwin0.9')
22
- end
17
+ require File.join(File.dirname(__FILE__), '../spec_helpers')
23
18
 
24
- it 'should point to default JVM' do
25
- load File.expand_path('../lib/buildr/java.rb')
26
- ENV['JAVA_HOME'].should == '/System/Library/Frameworks/JavaVM.framework/Home'
27
- end
28
19
 
29
- it 'should use value of environment variable if specified' do
30
- ENV['JAVA_HOME'] = '/System/Library/Frameworks/JavaVM.specified'
31
- load File.expand_path('../lib/buildr/java.rb')
32
- ENV['JAVA_HOME'].should == '/System/Library/Frameworks/JavaVM.specified'
20
+ describe Buildr::Ant do
21
+
22
+ it 'should pick Ant version from ant build settings' do
23
+ Buildr::Ant.instance_eval { @dependencies = nil }
24
+ write 'build.yaml', 'ant: 1.2.3'
25
+ Buildr::Ant.dependencies.should include("org.apache.ant:ant:jar:1.2.3")
33
26
  end
34
27
 
35
- after do
36
- ENV['JAVA_HOME'] = @old_home
37
- end
38
28
  end
@@ -0,0 +1,358 @@
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
+ require File.join(File.dirname(__FILE__), '../spec_helpers')
17
+
18
+ describe Buildr::RSpec do
19
+
20
+ def foo(*args, &prc)
21
+ define('foo', *args) do
22
+ test.using :rspec, :output => false
23
+ if prc
24
+ instance_eval(&prc)
25
+ else
26
+ self
27
+ end
28
+ end
29
+ end
30
+
31
+ it 'should be selected by :rspec name' do
32
+ foo { test.framework.should eql(:rspec) }
33
+ end
34
+
35
+ it 'should run rspecs' do
36
+ success = File.expand_path('src/spec/ruby/success_spec.rb')
37
+ write(success, 'describe("success") { it("is true") { nil.should be_nil } }')
38
+ failure = File.expand_path('src/spec/ruby/failure_spec.rb')
39
+ write(failure, 'describe("failure") { it("is false") { true.should == false } }')
40
+ error = File.expand_path('src/spec/ruby/error_spec.rb')
41
+ write(error, 'describe("error") { it("raises") { eval("lambda") } }')
42
+ foo do
43
+ lambda { test.invoke }.should raise_error(/Tests failed/)
44
+ test.tests.should include(success, failure, error)
45
+ test.failed_tests.should include(failure, error)
46
+ test.passed_tests.should include(success)
47
+ end
48
+ end
49
+
50
+ end if RUBY_PLATFORM =~ /java/ || ENV['JRUBY_HOME'] # RSpec
51
+
52
+ describe Buildr::JtestR do
53
+
54
+ def foo(*args, &prc)
55
+ define('foo', *args) do
56
+ test.using :jtestr, :output => false
57
+ if prc
58
+ instance_eval(&prc)
59
+ else
60
+ self
61
+ end
62
+ end
63
+ end
64
+
65
+ it 'should be selected by :jtestr name' do
66
+ foo { test.framework.should eql(:jtestr) }
67
+ end
68
+
69
+ it 'should apply to projects having test_unit sources' do
70
+ define('one', :base_dir => 'one') do
71
+ write _('src/spec/ruby/one_test.rb')
72
+ JtestR.applies_to?(self).should be_true
73
+ end
74
+ define('two', :base_dir => 'two') do
75
+ write _('src/spec/ruby/twoTest.rb')
76
+ JtestR.applies_to?(self).should be_true
77
+ end
78
+ define('three', :base_dir => 'three') do
79
+ write _('src/spec/ruby/tc_three.rb')
80
+ JtestR.applies_to?(self).should be_true
81
+ end
82
+ define('four', :base_dir => 'four') do
83
+ write _('src/spec/ruby/ts_four.rb')
84
+ JtestR.applies_to?(self).should be_true
85
+ end
86
+ end
87
+
88
+ it 'should apply to projects having rspec sources' do
89
+ define('one', :base_dir => 'one') do
90
+ write _('src/spec/ruby/one_spec.rb')
91
+ JtestR.applies_to?(self).should be_true
92
+ end
93
+ end
94
+
95
+ it 'should apply to projects having expectations sources' do
96
+ define('one', :base_dir => 'one') do
97
+ write _('src/spec/ruby/one_expect.rb')
98
+ JtestR.applies_to?(self).should be_true
99
+ end
100
+ end
101
+
102
+ it 'should apply to projects having junit sources' do
103
+ define('one', :base_dir => 'one') do
104
+ write _('src/test/java/example/OneTest.java', <<-JAVA)
105
+ package example;
106
+ public class OneTest extends junit.framework.TestCase { }
107
+ JAVA
108
+ JtestR.applies_to?(self).should be_true
109
+ end
110
+ end
111
+
112
+ it 'should apply to projects having testng sources' do
113
+ define('one', :base_dir => 'one') do
114
+ write _('src/test/java/example/OneTest.java', <<-JAVA)
115
+ package example;
116
+ public class OneTest {
117
+ @org.testng.annotations.Test
118
+ public void testNothing() {}
119
+ }
120
+ JAVA
121
+ JtestR.applies_to?(self).should be_true
122
+ end
123
+ end
124
+
125
+ it 'should use a java compiler if java sources found' do
126
+ foo do
127
+ write _('src/spec/java/Something.java'), 'public class Something {}'
128
+ test.compile.language.should eql(:java)
129
+ end
130
+ end
131
+
132
+ it 'should load user jtestr_config.rb' do
133
+ foo do
134
+ hello = _('hello')
135
+ write('src/spec/ruby/jtestr_config.rb', "File.open('#{hello}', 'w') { |f| f.write 'HELLO' }")
136
+ write('src/spec/ruby/some_spec.rb')
137
+ test.invoke
138
+ File.should be_exist(hello)
139
+ File.read(hello).should == 'HELLO'
140
+ end
141
+ end
142
+
143
+ it 'should run junit tests' do
144
+ write('src/test/java/example/SuccessTest.java', <<-JAVA)
145
+ package example;
146
+ public class SuccessTest extends junit.framework.TestCase {
147
+ public void testSuccess() { assertTrue(true); }
148
+ }
149
+ JAVA
150
+ write('src/test/java/example/FailureTest.java', <<-JAVA)
151
+ package example;
152
+ public class FailureTest extends junit.framework.TestCase {
153
+ public void testFailure() { assertTrue(false); }
154
+ }
155
+ JAVA
156
+ foo do
157
+ lambda { test.invoke }.should raise_error(/Tests failed/)
158
+ test.tests.should include('example.SuccessTest', 'example.FailureTest')
159
+ test.failed_tests.should include('example.FailureTest')
160
+ test.passed_tests.should include('example.SuccessTest')
161
+ end
162
+ end
163
+
164
+ it 'should run testng tests' do
165
+ write('src/test/java/example/Success.java', <<-JAVA)
166
+ package example;
167
+ public class Success {
168
+ @org.testng.annotations.Test
169
+ public void annotatedSuccess() { org.testng.Assert.assertTrue(true); }
170
+ }
171
+ JAVA
172
+ write('src/test/java/example/Failure.java', <<-JAVA)
173
+ package example;
174
+ public class Failure {
175
+ @org.testng.annotations.Test
176
+ public void annotatedFail() { org.testng.Assert.fail("FAIL"); }
177
+ }
178
+ JAVA
179
+ foo do
180
+ lambda { test.invoke }.should raise_error(/Tests failed/)
181
+ test.tests.should include('example.Success', 'example.Failure')
182
+ test.failed_tests.should include('example.Failure')
183
+ test.passed_tests.should include('example.Success')
184
+ end
185
+ end
186
+
187
+ it 'should run test_unit' do
188
+ success = File.expand_path('src/spec/ruby/success_test.rb')
189
+ write(success, <<-TESTUNIT)
190
+ require 'test/unit'
191
+ class TC_Success < Test::Unit::TestCase
192
+ def test_success
193
+ assert true
194
+ end
195
+ end
196
+ TESTUNIT
197
+ failure = File.expand_path('src/spec/ruby/failure_test.rb')
198
+ write(failure, <<-TESTUNIT)
199
+ require 'test/unit'
200
+ class TC_Failure < Test::Unit::TestCase
201
+ def test_failure
202
+ assert false
203
+ end
204
+ end
205
+ TESTUNIT
206
+ error = File.expand_path('src/spec/ruby/error_test.rb')
207
+ write(error, <<-TESTUNIT)
208
+ require 'test/unit'
209
+ class TC_Error < Test::Unit::TestCase
210
+ def test_error
211
+ eval('lambda')
212
+ end
213
+ end
214
+ TESTUNIT
215
+ foo do
216
+ lambda { test.invoke }.should raise_error(/Tests failed/)
217
+ test.tests.should include(success, failure, error)
218
+ test.failed_tests.should include(failure, error)
219
+ test.passed_tests.should include(success)
220
+ end
221
+ end
222
+
223
+ it 'should run expectations' do
224
+ success = File.expand_path('src/spec/ruby/success_expect.rb')
225
+ write(success, 'Expectations { expect(true) { true } }')
226
+ failure = File.expand_path('src/spec/ruby/failure_expect.rb')
227
+ write(failure, 'Expectations { expect(true) { false } }')
228
+ error = File.expand_path('src/spec/ruby/error_expect.rb')
229
+ write(error, 'Expectations { expect(nil) { eval("lambda") } }')
230
+ foo do
231
+ lambda { test.invoke }.should raise_error(/Tests failed/)
232
+ test.tests.should include(success, failure, error)
233
+ test.failed_tests.should include(failure, error)
234
+ test.passed_tests.should include(success)
235
+ end
236
+ end
237
+
238
+ it 'should run rspecs' do
239
+ success = File.expand_path('src/spec/ruby/success_spec.rb')
240
+ write(success, 'describe("success") { it("is true") { nil.should be_nil } }')
241
+ failure = File.expand_path('src/spec/ruby/failure_spec.rb')
242
+ write(failure, 'describe("failure") { it("is false") { true.should == false } }')
243
+ error = File.expand_path('src/spec/ruby/error_spec.rb')
244
+ write(error, 'describe("error") { it("raises") { eval("lambda") } }')
245
+ pending = File.expand_path('src/spec/ruby/pending_spec.rb')
246
+ write(pending, 'describe("peding") { it "is not implemented" }')
247
+ foo do
248
+ lambda { test.invoke }.should raise_error(/Tests failed/)
249
+ test.tests.should include(success, failure, error)
250
+ test.failed_tests.should include(failure, error)
251
+ test.passed_tests.should include(success)
252
+ end
253
+ end
254
+
255
+
256
+ end if RUBY_PLATFORM =~ /java/ || ENV['JRUBY_HOME'] # JtestR
257
+
258
+ describe Buildr::JBehave do
259
+ def foo(*args, &prc)
260
+ define('foo', *args) do
261
+ test.using :jbehave
262
+ if prc
263
+ instance_eval(&prc)
264
+ else
265
+ self
266
+ end
267
+ end
268
+ end
269
+
270
+ it 'should apply to projects having JBehave sources' do
271
+ define('one', :base_dir => 'one') do
272
+ write _('src/spec/java/SomeBehaviour.java'), 'public class SomeBehaviour {}'
273
+ JBehave.applies_to?(self).should be_true
274
+ end
275
+ define('two', :base_dir => 'two') do
276
+ write _('src/test/java/SomeBehaviour.java'), 'public class SomeBehaviour {}'
277
+ JBehave.applies_to?(self).should be_false
278
+ end
279
+ define('three', :base_dir => 'three') do
280
+ write _('src/spec/java/SomeBehavior.java'), 'public class SomeBehavior {}'
281
+ JBehave.applies_to?(self).should be_true
282
+ end
283
+ define('four', :base_dir => 'four') do
284
+ write _('src/test/java/SomeBehavior.java'), 'public class SomeBehavior {}'
285
+ JBehave.applies_to?(self).should be_false
286
+ end
287
+ end
288
+
289
+ it 'should be selected by :jbehave name' do
290
+ foo { test.framework.should eql(:jbehave) }
291
+ end
292
+
293
+ it 'should select a java compiler for its sources' do
294
+ write 'src/test/java/SomeBehavior.java', 'public class SomeBehavior {}'
295
+ foo do
296
+ test.compile.language.should eql(:java)
297
+ end
298
+ end
299
+
300
+ it 'should include JBehave dependencies' do
301
+ foo do
302
+ test.compile.dependencies.should include(artifact("org.jbehave:jbehave:jar::#{JBehave.version}"))
303
+ test.dependencies.should include(artifact("org.jbehave:jbehave:jar::#{JBehave.version}"))
304
+ end
305
+ end
306
+
307
+ it 'should include JMock dependencies' do
308
+ foo do
309
+ test.compile.dependencies.should include(artifact("jmock:jmock:jar:#{JMock.version}"))
310
+ test.dependencies.should include(artifact("jmock:jmock:jar:#{JMock.version}"))
311
+ end
312
+ end
313
+
314
+ it 'should include classes whose name ends with Behavior' do
315
+ write 'src/spec/java/some/FooBehavior.java', <<-JAVA
316
+ package some;
317
+ public class FooBehavior {
318
+ public void shouldFoo() { assert true; }
319
+ }
320
+ JAVA
321
+ write 'src/spec/java/some/NotATest.java', <<-JAVA
322
+ package some;
323
+ public class NotATest { }
324
+ JAVA
325
+ foo.tap do |project|
326
+ project.test.invoke
327
+ project.test.tests.should include('some.FooBehavior')
328
+ end
329
+ end
330
+
331
+
332
+ it 'should include classes implementing Behaviours' do
333
+ write 'src/spec/java/some/MyBehaviours.java', <<-JAVA
334
+ package some;
335
+ public class MyBehaviours implements
336
+ org.jbehave.core.behaviour.Behaviours {
337
+ public Class[] getBehaviours() {
338
+ return new Class[] { some.FooBehave.class };
339
+ }
340
+ }
341
+ JAVA
342
+ write 'src/spec/java/some/FooBehave.java', <<-JAVA
343
+ package some;
344
+ public class FooBehave {
345
+ public void shouldFoo() { assert true; }
346
+ }
347
+ JAVA
348
+ write 'src/spec/java/some/NotATest.java', <<-JAVA
349
+ package some;
350
+ public class NotATest { }
351
+ JAVA
352
+ foo.tap do |project|
353
+ project.test.invoke
354
+ project.test.tests.should include('some.MyBehaviours')
355
+ end
356
+ end
357
+
358
+ end # JBehave
@@ -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 'javac compiler' do
@@ -0,0 +1,88 @@
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
+ require File.join(File.dirname(__FILE__), '../spec_helpers')
17
+
18
+ unless RUBY_PLATFORM =~ /java/
19
+ describe ENV, 'JAVA_HOME on OS X' do
20
+ before do
21
+ @old_home, ENV['JAVA_HOME'] = ENV['JAVA_HOME'], nil
22
+ @old_env_java = ENV_JAVA
23
+ Config::CONFIG.should_receive(:[]).with('host_os').and_return('darwin0.9')
24
+ end
25
+
26
+ it 'should point to default JVM' do
27
+ load File.expand_path('../lib/buildr/java/rjb.rb')
28
+ ENV['JAVA_HOME'].should == '/System/Library/Frameworks/JavaVM.framework/Home'
29
+ end
30
+
31
+ it 'should use value of environment variable if specified' do
32
+ ENV['JAVA_HOME'] = '/System/Library/Frameworks/JavaVM.specified'
33
+ load File.expand_path('../lib/buildr/java/rjb.rb')
34
+ ENV['JAVA_HOME'].should == '/System/Library/Frameworks/JavaVM.specified'
35
+ end
36
+
37
+ after do
38
+ ENV['JAVA_HOME'] = @old_home
39
+ ENV_JAVA.replace @old_env_java
40
+ end
41
+ end
42
+ end
43
+
44
+
45
+ describe Java, '#tools_jar' do
46
+ before do
47
+ @old_home = ENV['JAVA_HOME']
48
+ end
49
+
50
+ describe 'when JAVA_HOME points to a JDK' do
51
+ before do
52
+ Java.instance_eval { @tools_jar = nil }
53
+ write 'jdk/lib/tools.jar'
54
+ ENV['JAVA_HOME'] = File.expand_path('jdk')
55
+ end
56
+
57
+ it 'should return the path to tools.jar' do
58
+ Java.tools_jar.should point_to_path('jdk/lib/tools.jar')
59
+ end
60
+ end
61
+
62
+ describe 'when JAVA_HOME points to a JRE inside a JDK' do
63
+ before do
64
+ Java.instance_eval { @tools_jar = nil }
65
+ write 'jdk/lib/tools.jar'
66
+ ENV['JAVA_HOME'] = File.expand_path('jdk/jre')
67
+ end
68
+
69
+ it 'should return the path to tools.jar' do
70
+ Java.tools_jar.should point_to_path('jdk/lib/tools.jar')
71
+ end
72
+ end
73
+
74
+ describe 'when there is no tools.jar' do
75
+ before do
76
+ Java.instance_eval { @tools_jar = nil }
77
+ ENV['JAVA_HOME'] = File.expand_path('jdk')
78
+ end
79
+
80
+ it 'should return nil' do
81
+ Java.tools_jar.should be_nil
82
+ end
83
+ end
84
+
85
+ after do
86
+ ENV['JAVA_HOME'] = @old_home
87
+ end
88
+ end