buildr 1.3.4-java → 1.3.5-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. data/CHANGELOG +35 -0
  2. data/README.rdoc +1 -1
  3. data/Rakefile +3 -3
  4. data/buildr.buildfile +6 -1
  5. data/buildr.gemspec +10 -9
  6. data/doc/_config.yml +1 -0
  7. data/doc/_layouts/default.html +25 -19
  8. data/doc/artifacts.textile +0 -36
  9. data/doc/building.textile +0 -38
  10. data/doc/contributing.textile +51 -15
  11. data/doc/css/default.css +11 -4
  12. data/doc/css/print.css +32 -24
  13. data/doc/download.textile +33 -22
  14. data/doc/extending.textile +10 -20
  15. data/doc/images/1442160941-frontcover.jpg +0 -0
  16. data/doc/images/asf-logo.png +0 -0
  17. data/doc/images/note.png +0 -0
  18. data/doc/images/project-structure.png +0 -0
  19. data/doc/images/tip.png +0 -0
  20. data/doc/images/zbuildr.png +0 -0
  21. data/doc/index.textile +39 -17
  22. data/doc/{getting_started.textile → installing.textile} +3 -80
  23. data/doc/languages.textile +50 -52
  24. data/doc/more_stuff.textile +154 -62
  25. data/doc/packaging.textile +0 -82
  26. data/doc/preface.textile +41 -15
  27. data/doc/projects.textile +0 -18
  28. data/doc/quick_start.textile +210 -0
  29. data/doc/scripts/install-linux.sh +10 -2
  30. data/doc/settings_profiles.textile +1 -33
  31. data/doc/testing.textile +6 -32
  32. data/lib/buildr.rb +2 -1
  33. data/lib/buildr/core.rb +6 -0
  34. data/lib/buildr/core/application.rb +2 -5
  35. data/lib/buildr/core/build.rb +29 -19
  36. data/lib/buildr/core/compile.rb +22 -4
  37. data/lib/buildr/core/filter.rb +2 -4
  38. data/lib/buildr/core/project.rb +5 -4
  39. data/lib/buildr/core/shell.rb +198 -0
  40. data/lib/buildr/core/test.rb +2 -0
  41. data/lib/buildr/core/transports.rb +18 -19
  42. data/lib/buildr/core/util.rb +178 -9
  43. data/lib/buildr/groovy.rb +1 -0
  44. data/lib/buildr/groovy/bdd.rb +5 -5
  45. data/lib/buildr/groovy/shell.rb +48 -0
  46. data/lib/buildr/ide/eclipse.rb +148 -36
  47. data/lib/buildr/ide/eclipse/java.rb +53 -0
  48. data/lib/buildr/ide/eclipse/plugin.rb +68 -0
  49. data/lib/buildr/ide/eclipse/scala.rb +66 -0
  50. data/lib/buildr/java/bdd.rb +16 -8
  51. data/lib/buildr/java/cobertura.rb +44 -13
  52. data/lib/buildr/java/commands.rb +5 -3
  53. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  54. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +18 -0
  55. data/lib/buildr/java/packaging.rb +2 -2
  56. data/lib/buildr/java/rjb.rb +1 -1
  57. data/lib/buildr/java/test_result.rb +48 -1
  58. data/lib/buildr/java/tests.rb +8 -5
  59. data/lib/buildr/packaging/artifact_namespace.rb +1 -1
  60. data/lib/buildr/packaging/package.rb +6 -2
  61. data/lib/buildr/packaging/zip.rb +10 -1
  62. data/lib/buildr/packaging/ziptask.rb +5 -2
  63. data/lib/buildr/scala.rb +1 -0
  64. data/lib/buildr/scala/bdd.rb +17 -8
  65. data/lib/buildr/scala/compiler.rb +66 -21
  66. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
  67. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  68. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +35 -0
  69. data/lib/buildr/scala/shell.rb +55 -0
  70. data/lib/buildr/scala/tests.rb +6 -5
  71. data/lib/buildr/shell.rb +180 -0
  72. data/rakelib/doc.rake +2 -3
  73. data/rakelib/jekylltask.rb +42 -32
  74. data/rakelib/package.rake +4 -2
  75. data/rakelib/release.rake +8 -8
  76. data/rakelib/rspec.rake +3 -3
  77. data/rakelib/setup.rake +7 -1
  78. data/rakelib/stage.rake +9 -2
  79. data/rakelib/stage.rake~ +213 -0
  80. data/spec/core/application_spec.rb +84 -1
  81. data/spec/core/build_spec.rb +54 -2
  82. data/spec/core/common_spec.rb +1 -1
  83. data/spec/core/compile_spec.rb +2 -1
  84. data/spec/core/extension_spec.rb +93 -0
  85. data/spec/core/test_spec.rb +2 -2
  86. data/spec/core/transport_spec.rb +1 -1
  87. data/spec/groovy/bdd_spec.rb +6 -6
  88. data/spec/groovy/compiler_spec.rb +1 -0
  89. data/spec/ide/eclipse_spec.rb +262 -72
  90. data/spec/java/{ant.rb → ant_spec.rb} +0 -0
  91. data/spec/java/bdd_spec.rb +15 -0
  92. data/spec/java/cobertura_spec.rb +9 -1
  93. data/spec/java/emma_spec.rb +1 -1
  94. data/spec/java/java_spec.rb +26 -0
  95. data/spec/java/packaging_spec.rb +9 -7
  96. data/spec/java/{test_coverage_spec.rb → test_coverage_helper.rb} +6 -4
  97. data/spec/java/tests_spec.rb +22 -0
  98. data/spec/packaging/archive_spec.rb +14 -0
  99. data/spec/packaging/artifact_spec.rb +2 -2
  100. data/spec/packaging/packaging_spec.rb +97 -2
  101. data/spec/sandbox.rb +3 -1
  102. data/spec/scala/bdd_spec.rb +17 -48
  103. data/spec/scala/compiler_spec.rb +31 -2
  104. data/spec/scala/tests_spec.rb +1 -0
  105. data/spec/spec_helpers.rb +12 -0
  106. metadata +145 -148
File without changes
@@ -60,6 +60,15 @@ end if RUBY_PLATFORM =~ /java/ || ENV['JRUBY_HOME'] # RSpec
60
60
 
61
61
  describe Buildr::JtestR do
62
62
 
63
+ before do
64
+ # JtestR currently requires JUnit 4.4
65
+ Buildr.settings.build['junit'] = '4.4'
66
+
67
+ # clear cached dependencies
68
+ Buildr::JUnit.instance_eval { @dependencies = nil }
69
+ Buildr::JtestR.instance_eval { @dependencies = nil }
70
+ end
71
+
63
72
  def foo(*args, &prc)
64
73
  define('foo', *args) do
65
74
  test.using :jtestr, :output => false
@@ -261,6 +270,12 @@ describe Buildr::JtestR do
261
270
  end
262
271
  end
263
272
 
273
+ after do
274
+ # reset to default
275
+ Buildr.settings.build['junit'] = nil
276
+ Buildr::JUnit.instance_eval { @dependencies = nil }
277
+ Buildr::JtestR.instance_eval { @dependencies = nil }
278
+ end
264
279
 
265
280
  end if RUBY_PLATFORM =~ /java/ || ENV['JRUBY_HOME'] # JtestR
266
281
 
@@ -14,7 +14,7 @@
14
14
  # the License.
15
15
 
16
16
 
17
- require File.join(File.dirname(__FILE__), 'test_coverage_spec')
17
+ require File.join(File.dirname(__FILE__), 'test_coverage_helper')
18
18
  Sandbox.require_optional_extension 'buildr/java/cobertura'
19
19
  artifacts(Buildr::Cobertura::dependencies).map(&:invoke)
20
20
 
@@ -47,6 +47,12 @@ describe Buildr::Cobertura do
47
47
  task('foo:cobertura:instrument').invoke
48
48
  file(project('foo').cobertura.data_file).should exist
49
49
  end
50
+
51
+ it 'should not instrument projects which have no sources' do
52
+ write 'bar/src/main/java/Baz.java', 'public class Baz {}'
53
+ define('foo') { define('bar') }
54
+ task('foo:bar:cobertura:instrument').invoke
55
+ end
50
56
  end
51
57
 
52
58
  describe 'instrumentation' do
@@ -73,5 +79,7 @@ describe Buildr::Cobertura do
73
79
  Dir.chdir('target/instrumented/classes') { Dir.glob('*').sort.should == ['Baz.class'] }
74
80
  end
75
81
  end
82
+
83
+ # TODO add specs for cobertura:check...somehow
76
84
  end
77
85
  end
@@ -14,7 +14,7 @@
14
14
  # the License.
15
15
 
16
16
 
17
- require File.join(File.dirname(__FILE__), 'test_coverage_spec')
17
+ require File.join(File.dirname(__FILE__), 'test_coverage_helper')
18
18
  Sandbox.require_optional_extension 'buildr/java/emma'
19
19
  artifacts(Buildr::Emma::dependencies).map(&:invoke)
20
20
 
@@ -89,6 +89,32 @@ describe Java, '#tools_jar' do
89
89
  end
90
90
  end
91
91
 
92
+ describe Java, '#java' do
93
+ before do
94
+ @old_home = ENV['JAVA_HOME']
95
+ end
96
+
97
+ describe 'when JAVA_HOME points to an invalid JRE/JDK installation' do
98
+ before do
99
+ write 'jdk'
100
+ ENV['JAVA_HOME'] = File.expand_path('jdk')
101
+ end
102
+
103
+ it 'should fail with an error message mentioning JAVA_HOME' do
104
+ begin
105
+ Java.java ['-version']
106
+ fail 'Java.java did not fail with JAVA_HOME pointing to invalid JRE/JDK installation'
107
+ rescue => error
108
+ error.message.to_s.should match(/JAVA_HOME/)
109
+ end
110
+ end
111
+ end
112
+
113
+ after do
114
+ ENV['JAVA_HOME'] = @old_home
115
+ end
116
+ end
117
+
92
118
 
93
119
  describe Java::JavaWrapper do
94
120
  it 'should be removed in version 1.5 since it was deprecated in version 1.3' do
@@ -97,7 +97,9 @@ shared_examples_for 'package with manifest' do
97
97
  end
98
98
 
99
99
  it 'should generate a new manifest for a file that does not have one' do
100
- Zip::ZipFile.open("tmp.zip", Zip::ZipFile::CREATE).close
100
+ Zip::ZipOutputStream.open 'tmp.zip' do |zip|
101
+ zip.put_next_entry 'empty.txt'
102
+ end
101
103
  begin
102
104
  manifest = Buildr::Packaging::Java::Manifest.from_zip('tmp.zip')
103
105
  manifest.each do |key, val|
@@ -339,7 +341,7 @@ describe 'package with meta_inf', :shared=>true do
339
341
  package.invoke
340
342
  assumed = Array(@meta_inf_ignore)
341
343
  Zip::ZipFile.open(package.to_s) do |zip|
342
- entries = zip.entries.map(&:to_s).select { |f| File.dirname(f) == 'META-INF' }.map { |f| File.basename(f) }
344
+ entries = zip.entries.map(&:name).select { |f| File.dirname(f) == 'META-INF' }.map { |f| File.basename(f) }
343
345
  assumed.each { |f| entries.should include(f) }
344
346
  yield entries - assumed if block_given?
345
347
  end
@@ -657,7 +659,7 @@ describe Packaging, 'ear' do
657
659
  tmp.write ear.file.read(package)
658
660
  end
659
661
  manifest = Buildr::Packaging::Java::Manifest.from_zip('tmp.zip')
660
- yield manifest.main['Class-Path'].to_s.split(' ')
662
+ yield manifest.main['Class-Path'].split(' ')
661
663
  end
662
664
  end
663
665
 
@@ -909,7 +911,7 @@ describe Packaging, 'ear' do
909
911
  package(:ear) << { :jar=>package(:jar) } << { :jar=>package(:jar, :id=>'bar') }
910
912
  end
911
913
  inspect_application_xml do |xml|
912
- jars = xml.get_elements('/application/jar').map(&:texts).map(&:to_s)
914
+ jars = xml.get_elements('/application/jar').map(&:texts).map(&:join)
913
915
  jars.should include('jar/foo-1.0.jar', 'jar/bar-1.0.jar')
914
916
  end
915
917
  end
@@ -939,7 +941,7 @@ describe Packaging, 'ear' do
939
941
  it 'should update EJB component classpath to include libraries' do
940
942
  define 'foo', :version=>'1.0' do
941
943
  package(:ear) << package(:jar, :id=>'lib1') << package(:jar, :id=>'lib2')
942
- package(:ear).add :ejb=>package(:jar)
944
+ package(:ear).add :ejb=>package(:jar, :id=>'foo')
943
945
  end
944
946
  inspect_classpath 'ejb/foo-1.0.jar' do |classpath|
945
947
  classpath.should include('../lib/lib1-1.0.jar', '../lib/lib2-1.0.jar')
@@ -949,7 +951,7 @@ describe Packaging, 'ear' do
949
951
  it 'should update JAR component classpath to include libraries' do
950
952
  define 'foo', :version=>'1.0' do
951
953
  package(:ear) << package(:jar, :id=>'lib1') << package(:jar, :id=>'lib2')
952
- package(:ear).add :jar=>package(:jar)
954
+ package(:ear).add :jar=>package(:jar, :id=>'foo')
953
955
  end
954
956
  inspect_classpath 'jar/foo-1.0.jar' do |classpath|
955
957
  classpath.should include('../lib/lib1-1.0.jar', '../lib/lib2-1.0.jar')
@@ -959,7 +961,7 @@ describe Packaging, 'ear' do
959
961
  it 'should deal with very long classpaths' do
960
962
  define 'foo', :version=>'1.0' do
961
963
  20.times { |i| package(:ear) << package(:jar, :id=>"lib#{i}") }
962
- package(:ear).add :jar=>package(:jar)
964
+ package(:ear).add :jar=>package(:jar, :id=>'foo')
963
965
  end
964
966
  inspect_classpath 'jar/foo-1.0.jar' do |classpath|
965
967
  classpath.should include('../lib/lib1-1.0.jar', '../lib/lib2-1.0.jar')
@@ -166,8 +166,9 @@ describe 'test coverage tool', :shared=>true do
166
166
  'public class Foo { /* This comment is a TOKEN to check that test coverage reports include the source code */ }'
167
167
  define('foo')
168
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/
169
+ html_report_contents = Dir[File.join(test_coverage_config.report_dir, '**/*.html')].map{|path|File.open(path).read}.join
170
+ html_report_contents.force_encoding('ascii-8bit') if RUBY_VERSION >= '1.9'
171
+ html_report_contents.should =~ /TOKEN/
171
172
  end
172
173
  end
173
174
  end
@@ -203,8 +204,9 @@ describe 'test coverage tool', :shared=>true do
203
204
  write 'bar/src/main/java/Bar.java',
204
205
  'public class Bar { /* This comment is a TOKEN to check that test coverage reports include the source code */ }'
205
206
  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/
207
+ html_report_contents = Dir[File.join(@tool_module.report_to(:html), '**/*.html')].map{|path|File.read(path)}.join
208
+ html_report_contents.force_encoding('ascii-8bit') if RUBY_VERSION >= '1.9'
209
+ html_report_contents.should =~ /TOKEN/
208
210
  end
209
211
 
210
212
  it 'should handle gracefully a project with no source' do
@@ -216,6 +216,7 @@ describe Buildr::JUnit do
216
216
  JAVA
217
217
  define('foo').test.using :properties=>{ 'name'=>'value' }
218
218
  project('foo').test.invoke
219
+ project('foo').test.options[:properties]["baseDir"].should eql(project("foo").test.compile.target.to_s)
219
220
  end
220
221
 
221
222
  it 'should pass environment to JVM' do
@@ -439,6 +440,27 @@ describe Buildr::TestNG do
439
440
  lambda { project('foo').test.invoke }.should raise_error(RuntimeError, /Tests failed/)
440
441
  end
441
442
 
443
+ it 'should fail when multiple TestNG test case fail' do
444
+ write 'src/test/java/FailingTest1.java', <<-JAVA
445
+ public class FailingTest1 {
446
+ @org.testng.annotations.Test
447
+ public void testNothing() {
448
+ org.testng.AssertJUnit.assertTrue(false);
449
+ }
450
+ }
451
+ JAVA
452
+ write 'src/test/java/FailingTest2.java', <<-JAVA
453
+ public class FailingTest2 {
454
+ @org.testng.annotations.Test
455
+ public void testNothing() {
456
+ org.testng.AssertJUnit.assertTrue(false);
457
+ }
458
+ }
459
+ JAVA
460
+ define('foo') { test.using(:testng) }
461
+ lambda { project('foo').test.invoke }.should raise_error(RuntimeError, /Tests failed/)
462
+ end
463
+
442
464
  it 'should report failed test names' do
443
465
  write 'src/test/java/FailingTest.java', <<-JAVA
444
466
  public class FailingTest {
@@ -375,6 +375,20 @@ describe ZipTask do
375
375
  archive(@archive).invoke
376
376
  inspect_archive { |archive| archive.keys.should include('code/') }
377
377
  end
378
+
379
+ it 'should preserve file permissions' do
380
+ # with JRuby it's important to use absolute paths with File.chmod()
381
+ # http://jira.codehaus.org/browse/JRUBY-3300
382
+ hello = File.expand_path('src/main/bin/hello')
383
+ write hello, 'echo hi'
384
+ File.chmod(0777, hello) ||
385
+ fail("Failed to set permission on #{hello}") unless (File.stat(hello).mode & 0777) == 0777
386
+
387
+ zip('foo.zip').include('src/main/bin/*').invoke
388
+ unzip('target' => 'foo.zip').extract
389
+ (File.stat('target/hello').mode & 0777).should == 0777
390
+ end
391
+
378
392
  end
379
393
 
380
394
 
@@ -231,7 +231,7 @@ describe Repositories, 'remote' do
231
231
  it 'should deal well with repositories URL that lack the last slash' do
232
232
  repositories.remote = 'http://example.com/base'
233
233
  uri = nil
234
- URI.should_receive(:download).twice.and_return { |uri, target, options| }
234
+ URI.should_receive(:download).twice.and_return { |_uri, args| uri = _uri }
235
235
  artifact('group:id:jar:1.0').invoke
236
236
  uri.to_s.should eql('http://example.com/base/group/id/1.0/id-1.0.pom')
237
237
  end
@@ -239,7 +239,7 @@ describe Repositories, 'remote' do
239
239
  it 'should deal well with repositories URL that have the last slash' do
240
240
  repositories.remote = 'http://example.com/base/'
241
241
  uri = nil
242
- URI.should_receive(:download).twice.and_return { |uri, target, options| }
242
+ URI.should_receive(:download).twice.and_return { |_uri, args| p args ; uri = _uri }
243
243
  artifact('group:id:jar:1.0').invoke
244
244
  uri.to_s.should eql('http://example.com/base/group/id/1.0/id-1.0.pom')
245
245
  end
@@ -168,6 +168,62 @@ describe Project, '#package' do
168
168
  lambda { define('foo') { package(:weirdo) } }.should raise_error(RuntimeError, /Don't know how to create a package/)
169
169
  end
170
170
 
171
+ it 'should call package_as_foo when using package(:foo)' do
172
+ class Buildr::Project
173
+ def package_as_foo(file_name)
174
+ file(file_name) do |t|
175
+ mkdir_p File.dirname(t.to_s)
176
+ File.open(t.to_s, 'w') {|f| f.write('foo') }
177
+ end
178
+ end
179
+ end
180
+ define('foo', :version => '1.0') do |project|
181
+ package(:foo).invoke
182
+ package(:foo).should exist
183
+ package(:foo).should contain('foo')
184
+ end
185
+ end
186
+
187
+ it 'should allow to respec package(:sources) using package_as_sources_spec()' do
188
+ class Buildr::Project
189
+ def package_as_sources_spec(spec)
190
+ spec.merge({ :type=>:jar, :classifier=>'sources' })
191
+ end
192
+ end
193
+ define('foo', :version => '1.0') do
194
+ package(:sources).type.should eql(:jar)
195
+ package(:sources).classifier.should eql('sources')
196
+ end
197
+ end
198
+
199
+ it 'should produce different packages for different specs' do
200
+ class Buildr::Project
201
+ def package_as_foo(file_name)
202
+ file(file_name)
203
+ end
204
+
205
+ def package_as_foo_spec(spec)
206
+ spec.merge(:type => :zip)
207
+ end
208
+
209
+ def package_as_bar(file_name)
210
+ file(file_name)
211
+ end
212
+
213
+ def package_as_bar_spec(spec)
214
+ spec.merge(:type => :zip, :classifier => "foobar")
215
+ end
216
+
217
+ end
218
+ define('foo', :version => '1.0') do
219
+ package(:foo).type.should eql(:zip)
220
+ package(:foo).classifier.should be_nil
221
+ package(:bar).type.should eql(:zip)
222
+ package(:bar).classifier.should eql('foobar')
223
+ package(:foo).equal?(package(:bar)).should be_false
224
+ end
225
+ end
226
+
171
227
  it 'should default to no classifier' do
172
228
  define 'foo', :version=>'1.0' do
173
229
  package.classifier.should be_nil
@@ -203,8 +259,17 @@ describe Project, '#package' do
203
259
  package(:war)
204
260
  package(:jar, :id=>'bar')
205
261
  package(:jar, :classifier=>'srcs')
262
+ package(:jar, :classifier=>'doc')
206
263
  end
207
- project('foo').packages.uniq.size.should be(4)
264
+ project('foo').packages.uniq.size.should be(5)
265
+ end
266
+
267
+ it 'should create different tasks for package with classifier' do
268
+ define 'foo', :version=>'1.0' do
269
+ package(:jar)
270
+ package(:jar, :classifier=>'foo')
271
+ end
272
+ project('foo').packages.uniq.size.should be(2)
208
273
  end
209
274
 
210
275
  it 'should not create multiple packages for the same spec' do
@@ -213,8 +278,9 @@ describe Project, '#package' do
213
278
  package(:war)
214
279
  package(:jar, :id=>'bar')
215
280
  package(:jar, :id=>'bar')
281
+ package(:jar, :id=>'baz')
216
282
  end
217
- project('foo').packages.uniq.size.should be(2)
283
+ project('foo').packages.uniq.size.should be(3)
218
284
  end
219
285
 
220
286
  it 'should return the same task for subsequent calls' do
@@ -299,6 +365,35 @@ POM
299
365
  lambda { task('artifacts').invoke }.should_not raise_error
300
366
  end
301
367
 
368
+ describe "existing package access" do
369
+ it "should return the same instance for identical optionless invocations" do
370
+ define 'foo', :version => '1.0' do
371
+ package(:zip).should equal(package(:zip))
372
+ end
373
+ project('foo').packages.size.should == 1
374
+ end
375
+
376
+ it "should return the exactly matching package identical invocations with options" do
377
+ define 'foo', :version => '1.0' do
378
+ package(:zip, :id => 'src')
379
+ package(:zip, :id => 'bin')
380
+ end
381
+ project('foo').package(:zip, :id => 'src').should equal(project('foo').packages.first)
382
+ project('foo').package(:zip, :id => 'bin').should equal(project('foo').packages.last)
383
+ project('foo').packages.size.should == 2
384
+ end
385
+
386
+ it "should return the first of the same type for subsequent optionless invocations" do
387
+ define 'foo', :version => '1.0' do
388
+ package(:zip, :file => 'override.zip')
389
+ package(:jar, :file => 'another.jar')
390
+ end
391
+ project('foo').package(:zip).name.should == 'override.zip'
392
+ project('foo').package(:jar).name.should == 'another.jar'
393
+ project('foo').packages.size.should == 2
394
+ end
395
+ end
396
+
302
397
  end
303
398
 
304
399
 
@@ -29,8 +29,10 @@ Java.load # Anything added to the classpath.
29
29
  artifacts(TestFramework.frameworks.map(&:dependencies).flatten, JUnit.ant_taskdef).each do |path|
30
30
  file(path).invoke
31
31
  end
32
+ # JtestR currently requires JUnit 4.4
33
+ file(artifact("junit:junit:jar:4.4")).invoke
32
34
 
33
- ENV['HOME'] = File.expand_path('tmp/home')
35
+ ENV['HOME'] = File.expand_path(File.join(File.dirname(__FILE__), '..', 'tmp', 'home'))
34
36
 
35
37
  # We need to run all tests inside a _sandbox, tacking a snapshot of Buildr before the test,
36
38
  # and restoring everything to its previous state after the test. Damn state changes.
@@ -15,6 +15,7 @@
15
15
 
16
16
 
17
17
  require File.join(File.dirname(__FILE__), '../spec_helpers')
18
+ require 'buildr/scala'
18
19
 
19
20
  describe Buildr::Scala::Specs do
20
21
  it 'should be the default when tests in src/spec/scala' do
@@ -51,7 +52,7 @@ describe Buildr::Scala::Specs do
51
52
  project('foo').test.dependencies.should include(*artifacts(JMock.dependencies))
52
53
  end
53
54
 
54
- it 'should include public classes extending org.specs.Specification' do
55
+ it 'should include public objects extending org.specs.Specification' do
55
56
  write 'src/spec/scala/com/example/MySpecs.scala', <<-SCALA
56
57
  package com.example
57
58
  object MySpecs extends org.specs.Specification {
@@ -64,12 +65,13 @@ describe Buildr::Scala::Specs do
64
65
  }
65
66
  SCALA
66
67
  define('foo').test.invoke
67
- project('foo').test.tests.should include('com.example.MySpecs')
68
+ project('foo').test.tests.should include('com.example.MySpecs$')
68
69
  end
69
70
 
70
- it 'should pass when spec passes' do
71
- write 'src/spec/scala/PassingSpecs.scala', <<-SCALA
72
- object PassingSpecs extends org.specs.Specification {
71
+ it 'should include public objects extending org.specs.Specification even with companion classes' do
72
+ write 'src/spec/scala/com/example/MySpecs.scala', <<-SCALA
73
+ package com.example
74
+ object MySpecs extends org.specs.Specification {
73
75
  "it" should {
74
76
  "add" in {
75
77
  val sum = 1 + 1
@@ -77,59 +79,27 @@ describe Buildr::Scala::Specs do
77
79
  }
78
80
  }
79
81
  }
82
+ class MySpecs extends org.specs.runner.JUnit4(MySpecs)
80
83
  SCALA
81
- lambda { define('foo').test.invoke }.should_not raise_error
82
- end
83
-
84
- it 'should fail when ScalaTest test case fails' do
85
- write 'src/spec/scala/FailingSpecs.scala', <<-SCALA
86
- object FailingSpecs extends org.specs.Specification {
87
- "it" should {
88
- "add" in {
89
- val sum = 1 + 1
90
- sum mustEqual 42
91
- }
92
- }
93
- }
94
- SCALA
95
- lambda { define('foo').test.invoke }.should raise_error(RuntimeError, /Tests failed/) rescue nil
84
+ define('foo').test.invoke
85
+ project('foo').test.tests.should include('com.example.MySpecs$')
96
86
  end
97
87
 
98
- it 'should report failed test names' do
99
- write 'src/spec/scala/FailingSpecs.scala', <<-SCALA
100
- object FailingSpecs extends org.specs.Specification {
88
+ it 'should pass when spec passes' do
89
+ write 'src/spec/scala/PassingSpecs.scala', <<-SCALA
90
+ object PassingSpecs extends org.specs.Specification {
101
91
  "it" should {
102
92
  "add" in {
103
93
  val sum = 1 + 1
104
- sum mustEqual 42
94
+ sum mustEqual 2
105
95
  }
106
96
  }
107
97
  }
108
98
  SCALA
109
- define('foo').test.invoke rescue
110
- project('foo').test.failed_tests.should include('FailingSpecs')
99
+ lambda { define('foo').test.invoke }.should_not raise_error
111
100
  end
112
101
 
113
- it 'should compile and run specifications with "Specs" suffix' do
114
- write 'src/spec/scala/HelloWorldSpecs.scala', <<-SCALA
115
- import org.specs._
116
-
117
- object HelloWorldSpecs extends Specification {
118
- "'hello world' has 11 characters" in {
119
- "hello world".size must beEqualTo(11)
120
- }
121
- "'hello world' matches 'h.* w.*'" in {
122
- "hello world" must beMatching("h.* w.*")
123
- }
124
- }
125
- SCALA
126
- define('foo')
127
- project('foo').test.invoke
128
- project('foo').test.passed_tests.should include('HelloWorldSpecs')
129
- end
130
-
131
-
132
- it 'should fail if specifications fail' do
102
+ it 'should fail when spec fails' do
133
103
  write 'src/spec/scala/StringSpecs.scala', <<-SCALA
134
104
  import org.specs._
135
105
  import org.specs.runner._
@@ -144,7 +114,6 @@ describe Buildr::Scala::Specs do
144
114
  SCALA
145
115
  define('foo')
146
116
  project('foo').test.invoke rescue
147
- project('foo').test.failed_tests.should include('StringSpecs')
117
+ project('foo').test.failed_tests.should include('StringSpecs$')
148
118
  end
149
-
150
119
  end