buildr 1.4.6-java → 1.4.7-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. data/CHANGELOG +81 -0
  2. data/Rakefile +5 -2
  3. data/addon/buildr/antlr.rb +0 -4
  4. data/addon/buildr/bnd.rb +3 -1
  5. data/addon/buildr/checkstyle.rb +201 -0
  6. data/addon/buildr/cobertura.rb +0 -1
  7. data/addon/buildr/drb.rb +0 -2
  8. data/addon/buildr/emma.rb +0 -1
  9. data/addon/buildr/findbugs.rb +227 -0
  10. data/addon/buildr/gwt.rake +82 -0
  11. data/addon/buildr/hibernate.rb +0 -4
  12. data/addon/buildr/javacc.rb +0 -4
  13. data/addon/buildr/javancss.rb +155 -0
  14. data/addon/buildr/jdepend.rb +138 -24
  15. data/addon/buildr/jdepend.rb.orig +178 -0
  16. data/addon/buildr/jetty.rb +0 -5
  17. data/addon/buildr/jibx.rb +85 -86
  18. data/addon/buildr/nailgun.rb +2 -2
  19. data/addon/buildr/openjpa.rb +0 -4
  20. data/addon/buildr/pmd.rb +166 -0
  21. data/addon/buildr/protobuf.rb +0 -1
  22. data/addon/buildr/sonar.rb +142 -0
  23. data/addon/buildr/xmlbeans.rb +0 -5
  24. data/buildr.gemspec +36 -21
  25. data/doc/_layouts/default.html +1 -0
  26. data/doc/contributing.textile +11 -2
  27. data/doc/download.textile +17 -5
  28. data/doc/index.textile +21 -46
  29. data/doc/installing.textile +18 -8
  30. data/doc/installing.textile.orig +282 -0
  31. data/doc/languages.textile +0 -38
  32. data/doc/more_stuff.textile +199 -12
  33. data/doc/more_stuff.textile.orig +1004 -0
  34. data/doc/packaging.textile +10 -0
  35. data/doc/settings_profiles.textile +2 -2
  36. data/etc/KEYS +44 -0
  37. data/lib/buildr.rb +67 -4
  38. data/lib/buildr/clojure.rb +0 -2
  39. data/lib/buildr/core/application.rb +23 -32
  40. data/lib/buildr/core/build.rb +0 -7
  41. data/lib/buildr/core/cc.rb +0 -5
  42. data/lib/buildr/core/checks.rb +0 -4
  43. data/lib/buildr/core/common.rb +0 -5
  44. data/lib/buildr/core/compile.rb +5 -10
  45. data/lib/buildr/core/doc.rb +9 -3
  46. data/lib/buildr/core/environment.rb +0 -1
  47. data/lib/buildr/core/filter.rb +0 -5
  48. data/lib/buildr/core/generate.rb +2 -6
  49. data/lib/buildr/core/help.rb +1 -6
  50. data/lib/buildr/core/linux.rb +0 -1
  51. data/lib/buildr/core/osx.rb +0 -1
  52. data/lib/buildr/core/project.rb +0 -4
  53. data/lib/buildr/core/run.rb +1 -5
  54. data/lib/buildr/core/shell.rb +1 -6
  55. data/lib/buildr/core/test.rb +1 -7
  56. data/lib/buildr/core/transports.rb +4 -6
  57. data/lib/buildr/core/util.rb +2 -65
  58. data/lib/buildr/groovy/doc.rb +0 -3
  59. data/lib/buildr/groovy/shell.rb +0 -2
  60. data/lib/buildr/ide/eclipse.rb +4 -13
  61. data/lib/buildr/ide/eclipse/java.rb +0 -4
  62. data/lib/buildr/ide/eclipse/plugin.rb +0 -4
  63. data/lib/buildr/ide/eclipse/scala.rb +0 -4
  64. data/lib/buildr/ide/idea.rb +284 -52
  65. data/lib/buildr/java/ant.rb +2 -6
  66. data/lib/buildr/java/bdd.rb +5 -123
  67. data/lib/buildr/java/cobertura.rb +16 -10
  68. data/lib/buildr/java/commands.rb +33 -7
  69. data/lib/buildr/java/compiler.rb +0 -7
  70. data/lib/buildr/java/deprecated.rb +0 -4
  71. data/lib/buildr/java/doc.rb +0 -2
  72. data/lib/buildr/java/emma.rb +0 -4
  73. data/lib/buildr/java/jruby.rb +0 -2
  74. data/lib/buildr/java/packaging.rb +0 -4
  75. data/lib/buildr/java/pom.rb +24 -16
  76. data/lib/buildr/java/rjb.rb +1 -1
  77. data/lib/buildr/java/test_result.rb +1 -2
  78. data/lib/buildr/java/tests.rb +68 -6
  79. data/lib/buildr/packaging/archive.rb +0 -1
  80. data/lib/buildr/packaging/artifact.rb +19 -16
  81. data/lib/buildr/packaging/artifact_namespace.rb +51 -24
  82. data/lib/buildr/packaging/artifact_search.rb +1 -2
  83. data/lib/buildr/packaging/gems.rb +1 -13
  84. data/lib/buildr/packaging/package.rb +0 -6
  85. data/lib/buildr/packaging/tar.rb +2 -4
  86. data/lib/buildr/packaging/version_requirement.rb +1 -1
  87. data/lib/buildr/packaging/zip.rb +1 -2
  88. data/lib/buildr/packaging/ziptask.rb +0 -4
  89. data/lib/buildr/run.rb +3 -3
  90. data/lib/buildr/scala/bdd.rb +129 -11
  91. data/lib/buildr/scala/compiler.rb +53 -6
  92. data/lib/buildr/scala/doc.rb +6 -4
  93. data/lib/buildr/scala/org/apache/buildr/Specs2Runner.class +0 -0
  94. data/lib/buildr/scala/org/apache/buildr/Specs2Runner.java +38 -0
  95. data/lib/buildr/scala/shell.rb +0 -4
  96. data/lib/buildr/scala/tests.rb +15 -6
  97. data/lib/buildr/shell.rb +0 -1
  98. data/lib/buildr/version.rb +1 -1
  99. data/rakelib/all-in-one.rake +20 -11
  100. data/rakelib/checks.rake +0 -31
  101. data/rakelib/doc.rake +86 -100
  102. data/rakelib/package.rake +3 -3
  103. data/rakelib/release.rake +1 -1
  104. data/rakelib/rspec.rake +23 -7
  105. data/rakelib/stage.rake +18 -21
  106. data/spec/addon/bnd_spec.rb +2 -2
  107. data/spec/addon/jaxb_xjc_spec.rb +5 -0
  108. data/spec/core/application_spec.rb +11 -64
  109. data/spec/core/cc_spec.rb +12 -5
  110. data/spec/core/compile_spec.rb +11 -0
  111. data/spec/core/doc_spec.rb +1 -1
  112. data/spec/core/run_spec.rb +17 -4
  113. data/spec/core/test_spec.rb +5 -3
  114. data/spec/ide/idea_spec.rb +60 -0
  115. data/spec/java/bdd_spec.rb +8 -218
  116. data/spec/java/cobertura_spec.rb +4 -0
  117. data/spec/java/compiler_spec.rb +11 -8
  118. data/spec/java/emma_spec.rb +4 -1
  119. data/spec/java/java_spec.rb +1 -1
  120. data/spec/java/pom_spec.rb +125 -0
  121. data/spec/java/tests_spec.rb +185 -0
  122. data/spec/packaging/archive_spec.rb +1 -1
  123. data/spec/packaging/artifact_namespace_spec.rb +15 -0
  124. data/spec/packaging/artifact_spec.rb +26 -1
  125. data/spec/sandbox.rb +7 -1
  126. data/spec/scala/bdd_spec.rb +111 -8
  127. data/spec/scala/tests_spec.rb +5 -1
  128. data/spec/spec_helpers.rb +9 -4
  129. data/spec/version_requirement_spec.rb +2 -0
  130. metadata +499 -467
  131. data/lib/buildr/core.rb +0 -34
  132. data/lib/buildr/ide.rb +0 -19
  133. data/lib/buildr/java.rb +0 -25
  134. data/lib/buildr/java/jtestr_result.rb +0 -331
  135. data/lib/buildr/java/jtestr_runner.rb.erb +0 -116
  136. data/lib/buildr/packaging.rb +0 -25
  137. data/rakelib/setup.rake +0 -68
@@ -133,8 +133,9 @@ describe Buildr::Application do
133
133
  write 'build.yaml', <<-YAML
134
134
  gems:
135
135
  - rake
136
- - rspec ~> 2.1.0
136
+ - rspec ~> 2.9.0
137
137
  YAML
138
+ Buildr.application.should_receive(:listed_gems).and_return([[Gem.loaded_specs['rspec'],Gem.loaded_specs['rake']],[]])
138
139
  Buildr.application.load_gems
139
140
  end
140
141
 
@@ -181,71 +182,20 @@ describe Buildr::Application do
181
182
  end
182
183
 
183
184
  it 'should install nothing if specified gems already installed' do
184
- Buildr.application.should_receive(:listed_gems).and_return([Gem.loaded_specs['rspec']])
185
+ Buildr.application.should_receive(:listed_gems).and_return([[Gem.loaded_specs['rspec']],[]])
185
186
  Util.should_not_receive(:ruby)
186
187
  lambda { Buildr.application.load_gems }.should_not raise_error
187
188
  end
188
189
 
189
- it 'should fail if required gem not found in remote repository' do
190
- Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('buildr-foo', '>=1.1')])
191
- Gem.source_index.should_receive(:search).at_least(:once).and_return([])
190
+ it 'should fail if required gem not installed' do
191
+ Buildr.application.should_receive(:listed_gems).and_return([[],[Gem::Dependency.new('buildr-foo', '>=1.1')]])
192
192
  lambda { Buildr.application.load_gems }.should raise_error(LoadError, /cannot be found/i)
193
193
  end
194
194
 
195
- it 'should fail if need to install gem and not running in interactive mode' do
196
- Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('buildr-foo', '>=1.1')])
197
- Gem.source_index.should_receive(:search).and_return([@spec])
198
- $stdout.should_receive(:isatty).and_return(false)
199
- lambda { Buildr.application.load_gems }.should raise_error(LoadError, /this build requires the gems/i)
200
- end
201
-
202
- it 'should ask permission before installing required gems' do
203
- Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('buildr-foo', '>=1.1')])
204
- Gem.source_index.should_receive(:search).and_return([@spec])
205
- $terminal.should_receive(:agree).with(/install/, true)
206
- lambda { Buildr.application.load_gems }.should raise_error
207
- end
208
-
209
- it 'should fail if permission not granted to install gem' do
210
- Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('buildr-foo', '>=1.1')])
211
- Gem.source_index.should_receive(:search).and_return([@spec])
212
- $terminal.should_receive(:agree).and_return(false)
213
- lambda { Buildr.application.load_gems }.should raise_error(LoadError, /cannot build without/i)
214
- end
215
-
216
- it 'should install gem if permission granted' do
217
- Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('buildr-foo', '>=1.1')])
218
- Gem.source_index.should_receive(:search).and_return([@spec])
219
- $terminal.should_receive(:agree).and_return(true)
220
- Util.should_receive(:ruby) do |*args|
221
- args.should include('install', 'buildr-foo', '-v', '1.2')
222
- end
223
- Buildr.application.should_receive(:gem).and_return(false)
224
- Buildr.application.load_gems
225
- end
226
-
227
- it 'should reload gem cache after installing required gems' do
228
- Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('buildr-foo', '>=1.1')])
229
- Gem.source_index.should_receive(:search).and_return([@spec])
230
- $terminal.should_receive(:agree).and_return(true)
231
- Util.should_receive(:ruby)
232
- Gem.source_index.should_receive(:load_gems_in).with(Gem::SourceIndex.installed_spec_directories)
233
- Buildr.application.should_receive(:gem).and_return(false)
234
- Buildr.application.load_gems
235
- end
236
-
237
195
  it 'should load previously installed gems' do
238
- Buildr.application.should_receive(:listed_gems).and_return([Gem.loaded_specs['rspec']])
239
- Buildr.application.should_receive(:gem).with('rspec', Gem.loaded_specs['rspec'].version.to_s)
240
- Buildr.application.load_gems
241
- end
242
-
243
- it 'should load newly installed gems' do
244
- Buildr.application.should_receive(:listed_gems).and_return([Gem::Dependency.new('buildr-foo', '>=1.1')])
245
- Gem.source_index.should_receive(:search).and_return([@spec])
246
- $terminal.should_receive(:agree).and_return(true)
247
- Util.should_receive(:ruby)
248
- Buildr.application.should_receive(:gem).with('buildr-foo', @spec.version.to_s)
196
+ Gem.loaded_specs['rspec'].should_receive(:activate)
197
+ Buildr.application.should_receive(:listed_gems).and_return([[Gem.loaded_specs['rspec']],[]])
198
+ #Buildr.application.should_receive(:gem).with('rspec', Gem.loaded_specs['rspec'].version.to_s)
249
199
  Buildr.application.load_gems
250
200
  end
251
201
 
@@ -270,12 +220,9 @@ describe Buildr::Application do
270
220
  end
271
221
 
272
222
  def should_attempt_to_load_dependency(dep)
273
- Gem.source_index.should_receive(:search).with(dep).and_return([])
274
- lambda { Buildr.application.load_gems }.should raise_missing_gem_error(dep)
275
- end
276
-
277
- def raise_missing_gem_error(dep)
278
- raise_error(Gem::LoadError, /Build requires the gems #{dep.name} #{dep.requirement}, which cannot be found in local or remote repository./)
223
+ missing_gems = Buildr.application.send(:listed_gems)[1]
224
+ missing_gems.size.should eql(1)
225
+ missing_gems[0].eql?(dep)
279
226
  end
280
227
  end
281
228
 
@@ -92,21 +92,29 @@ describe Buildr::CCTask do
92
92
  foo.cc.invoke
93
93
  rescue => e
94
94
  p "unexpected exception #{e.inspect}"
95
- p e.backtrace.join("\n").inspect
95
+ p e.backtrace.join("\n")
96
96
  end
97
97
  end
98
98
 
99
- sleep 1
99
+ #Ick! Try to get the sleeping enough on each platform that the tests reliably pass
100
+ sleep 1 if RUBY_VERSION >= '1.9' && !RUBY_PLATFORM[/java/]
101
+ sleep 5 if RUBY_VERSION >= '1.8.7' && !RUBY_PLATFORM[/java/]
102
+ sleep 1 if RUBY_PLATFORM[/java/]
100
103
 
101
104
  foo.compile.run_count.should == 1
102
105
  foo.test.compile.run_count.should == 1
103
106
  foo.resources.run_count.should == 1
104
107
 
105
- sleep 1 # Wait one sec as the timestamp needs to be different.
108
+ # Wait some time as the timestamp needs to be different on files.
109
+ sleep 3 if Buildr::Util.win_os?
110
+ sleep 1 unless Buildr::Util.win_os?
106
111
 
107
112
  touch File.join(Dir.pwd, 'src/main/java/Example.java')
108
113
 
109
- sleep 1
114
+ #Ick! Try to get the sleeping enough on each platform that the tests reliably pass
115
+ sleep 1 if RUBY_VERSION >= '1.9' && !RUBY_PLATFORM[/java/]
116
+ sleep 5 if RUBY_VERSION >= '1.8.7' && !RUBY_PLATFORM[/java/]
117
+ sleep 1 if RUBY_PLATFORM[/java/]
110
118
 
111
119
  foo.compile.run_count.should == 2
112
120
  foo.test.compile.run_count.should == 2
@@ -195,7 +203,6 @@ describe Buildr::CCTask do
195
203
  tstamp = File.mtime("foo/target/classes/Example.class")
196
204
 
197
205
  touch 'foo/src/main/java/Example.java'
198
- p "after touch"
199
206
  sleep 2
200
207
 
201
208
  project("container:foo").tap do |p|
@@ -413,6 +413,17 @@ describe Buildr::CompileTask, '#invoke' do
413
413
  lambda { compile.from('sources').invoke }.should raise_error(RuntimeError, /no compiler selected/i)
414
414
  end
415
415
  end
416
+
417
+ it 'should not unnecessarily recompile files explicitly added to compile list (BUILDR-611)' do
418
+ mkpath 'src/other'
419
+ write 'src/other/Foo.java', 'package foo; public class Foo {}'
420
+ compile_task.from FileList['src/other/**.java']
421
+ mkpath 'target/classes/foo'
422
+ touch 'target/classes/foo/Foo.class'
423
+ File.utime(Time.now - 10, Time.now - 10, compile_task.target.to_s)
424
+ compile_task.invoke
425
+ File.stat(compile_task.target.to_s).mtime.should be_close(Time.now - 10, 2)
426
+ end
416
427
  end
417
428
 
418
429
 
@@ -124,7 +124,7 @@ describe Project, '#doc' do
124
124
  compile.using(:javac)
125
125
  doc.include included
126
126
  end
127
- project('foo').doc.source_files.should include(included)
127
+ project('foo').doc.source_files.should include(File.expand_path(included))
128
128
  end
129
129
 
130
130
  it 'should respond to exclude() and return self' do
@@ -27,13 +27,20 @@ describe Project, :run do
27
27
  project('foo').run.should be_kind_of(Run::RunTask)
28
28
  end
29
29
 
30
- it 'should include compile and test.compile dependencies' do
30
+ it 'should include compile dependencies' do
31
31
  define('foo') do
32
32
  compile.using(:javac).with 'group:compile:jar:1.0'
33
33
  test.compile.using(:javac).with 'group:test:jar:1.0'
34
34
  end
35
35
  project('foo').run.classpath.should include(artifact('group:compile:jar:1.0'))
36
- project('foo').run.classpath.should include(artifact('group:test:jar:1.0'))
36
+ end
37
+
38
+ it 'should not include test dependencies' do
39
+ define('foo') do
40
+ compile.using(:javac).with 'group:compile:jar:1.0'
41
+ test.compile.using(:javac).with 'group:test:jar:1.0'
42
+ end
43
+ project('foo').run.classpath.should_not include(artifact('group:test:jar:1.0'))
37
44
  end
38
45
 
39
46
  it 'should respond to using() and return self' do
@@ -63,11 +70,17 @@ describe Project, :run do
63
70
  end
64
71
  project('foo').run.runner.should be_a(Run::JavaRunner)
65
72
  end
73
+
74
+ it "should run with the project resources" do
75
+ write 'src/main/java/Test.java', 'class Test {}'
76
+ write 'src/main/resources/test.properties', ''
77
+ define 'foo'
78
+ project('foo').run.classpath.should include project('foo').resources.target
79
+ end
66
80
 
67
- it 'should depend on project''s compile and test.compile task' do
81
+ it 'should depend on project''s compile task' do
68
82
  define 'foo'
69
83
  project('foo').run.prerequisites.should include(project('foo').compile)
70
- project('foo').run.prerequisites.should include(project('foo').test)
71
84
  end
72
85
 
73
86
  it 'should be local task' do
@@ -747,9 +747,11 @@ describe Rake::Task, 'test' do
747
747
  end
748
748
 
749
749
  it 'should stop at first failure' do
750
- define('foo') { test { fail } }
751
- define('bar') { test { fail } }
752
- lambda { task('test').invoke rescue nil }.should run_tasks('foo:test').but_not('bar:test')
750
+ define('myproject') do
751
+ define('foo') { test { fail } }
752
+ define('bar') { test { fail } }
753
+ end
754
+ lambda { task('test').invoke rescue nil }.should run_tasks('myproject:bar:test').but_not('myproject:foo:test')
753
755
  end
754
756
 
755
757
  it 'should ignore failure if options.test is :all' do
@@ -296,6 +296,66 @@ describe Buildr::IntellijIdea do
296
296
  end
297
297
  end
298
298
 
299
+ describe "with artifacts added to root project" do
300
+ before do
301
+ @foo = define "foo" do
302
+ ipr.add_artifact("MyFancy.jar", "jar") do |xml|
303
+ xml.tag!('output-path', project._(:artifacts, "MyFancy.jar"))
304
+ xml.element :id => "module-output", :name => "foo"
305
+ end
306
+ ipr.add_artifact("MyOtherFancy.jar", "jar") do |xml|
307
+ xml.tag!('output-path', project._(:artifacts, "MyOtherFancy.jar"))
308
+ xml.element :id => "module-output", :name => "foo"
309
+ end
310
+ end
311
+ invoke_generate_task
312
+ end
313
+
314
+ it "generates an IPR with multiple jar artifacts" do
315
+ doc = xml_document(@foo._("foo.ipr"))
316
+ facet_xpath = "/project/component[@name='ArtifactManager']/artifact"
317
+ doc.should have_nodes(facet_xpath, 2)
318
+ doc.should have_xpath("#{facet_xpath}[@type='jar', @name='MyFancy.jar']")
319
+ doc.should have_xpath("#{facet_xpath}[@type='jar', @name='MyOtherFancy.jar']")
320
+ end
321
+ end
322
+
323
+ describe "with configurations added to root project" do
324
+ before do
325
+ @foo = define "foo" do
326
+ ipr.add_configuration("Run Contacts.html", "GWT.ConfigurationType", "GWT Configuration") do |xml|
327
+ xml.module(:name => project.iml.id)
328
+ xml.option(:name => "RUN_PAGE", :value => "Contacts.html")
329
+ xml.option(:name => "compilerParameters", :value => "-draftCompile -localWorkers 2")
330
+ xml.option(:name => "compilerMaxHeapSize", :value => "512")
331
+
332
+ xml.RunnerSettings(:RunnerId => "Run")
333
+ xml.ConfigurationWrapper(:RunnerId => "Run")
334
+ xml.tag! :method
335
+ end
336
+ ipr.add_configuration("Run Planner.html", "GWT.ConfigurationType", "GWT Configuration") do |xml|
337
+ xml.module(:name => project.iml.id)
338
+ xml.option(:name => "RUN_PAGE", :value => "Planner.html")
339
+ xml.option(:name => "compilerParameters", :value => "-draftCompile -localWorkers 2")
340
+ xml.option(:name => "compilerMaxHeapSize", :value => "512")
341
+
342
+ xml.RunnerSettings(:RunnerId => "Run")
343
+ xml.ConfigurationWrapper(:RunnerId => "Run")
344
+ xml.tag! :method
345
+ end
346
+ end
347
+ invoke_generate_task
348
+ end
349
+
350
+ it "generates an IPR with multiple configurations" do
351
+ doc = xml_document(@foo._("foo.ipr"))
352
+ facet_xpath = "/project/component[@name='ProjectRunConfigurationManager']/configuration"
353
+ doc.should have_nodes(facet_xpath, 2)
354
+ doc.should have_xpath("#{facet_xpath}[@type='GWT.ConfigurationType', @name='Run Contacts.html']")
355
+ doc.should have_xpath("#{facet_xpath}[@type='GWT.ConfigurationType', @name='Run Planner.html']")
356
+ end
357
+ end
358
+
299
359
  describe "with iml.group specified" do
300
360
  before do
301
361
  @foo = define "foo" do
@@ -28,6 +28,10 @@ describe Buildr::RSpec do
28
28
  end
29
29
 
30
30
  it 'should read passed specs from result yaml' do
31
+ # This test fails on the CI machine if the spec is run as part of a suite but not if run individually
32
+ # This seems to indicate that there is interaction with some other test but until that other test is
33
+ # identified the test has been marked as pending on the ci box
34
+ pending "Unable to determine why it fails on the CI machine so disabling" if `hostname` == "vesta.apache.org\n"
31
35
  write('src/spec/ruby/success_spec.rb', 'describe("success") { it("is true") { nil.should be_nil } }')
32
36
 
33
37
  project('foo').test.invoke
@@ -35,6 +39,10 @@ describe Buildr::RSpec do
35
39
  end
36
40
 
37
41
  it 'should read result yaml to obtain the list of failed specs' do
42
+ # This test fails on the CI machine if the spec is run as part of a suite but not if run individually
43
+ # This seems to indicate that there is interaction with some other test but until that other test is
44
+ # identified the test has been marked as pending on the ci box
45
+ pending "Unable to determine why it fails on the CI machine so disabling" if `hostname` == "vesta.apache.org\n"
38
46
  success = File.expand_path('src/spec/ruby/success_spec.rb')
39
47
  write(success, 'describe("success") { it("is true") { nil.should be_nil } }')
40
48
  failure = File.expand_path('src/spec/ruby/failure_spec.rb')
@@ -51,224 +59,6 @@ describe Buildr::RSpec do
51
59
 
52
60
  end if RUBY_PLATFORM =~ /java/ || ENV['JRUBY_HOME'] # RSpec
53
61
 
54
- describe Buildr::JtestR do
55
-
56
- before do
57
- # clear cached dependencies
58
- Buildr::JUnit.instance_eval { @dependencies = nil }
59
- Buildr::JtestR.instance_eval { @dependencies = nil }
60
- end
61
-
62
- def foo(*args, &prc)
63
- define('foo', *args) do
64
- test.using :jtestr, :output => false
65
- if prc
66
- instance_eval(&prc)
67
- else
68
- self
69
- end
70
- end
71
- end
72
-
73
- it 'should be selected by :jtestr name' do
74
- foo { test.framework.should eql(:jtestr) }
75
- end
76
-
77
- it 'should apply to projects having test_unit sources' do
78
- define('one', :base_dir => 'one') do
79
- write _('src/spec/ruby/one_test.rb')
80
- JtestR.applies_to?(self).should be_true
81
- end
82
- define('two', :base_dir => 'two') do
83
- write _('src/spec/ruby/twoTest.rb')
84
- JtestR.applies_to?(self).should be_true
85
- end
86
- define('three', :base_dir => 'three') do
87
- write _('src/spec/ruby/tc_three.rb')
88
- JtestR.applies_to?(self).should be_true
89
- end
90
- define('four', :base_dir => 'four') do
91
- write _('src/spec/ruby/ts_four.rb')
92
- JtestR.applies_to?(self).should be_true
93
- end
94
- end
95
-
96
- it 'should apply to projects having rspec sources' do
97
- define('one', :base_dir => 'one') do
98
- write _('src/spec/ruby/one_spec.rb')
99
- JtestR.applies_to?(self).should be_true
100
- end
101
- end
102
-
103
- it 'should apply to projects having expectations sources' do
104
- define('one', :base_dir => 'one') do
105
- write _('src/spec/ruby/one_expect.rb')
106
- JtestR.applies_to?(self).should be_true
107
- end
108
- end
109
-
110
- it 'should apply to projects having junit sources' do
111
- define('one', :base_dir => 'one') do
112
- write _('src/test/java/example/OneTest.java'), <<-JAVA
113
- package example;
114
- public class OneTest extends junit.framework.TestCase { }
115
- JAVA
116
- JtestR.applies_to?(self).should be_true
117
- end
118
- end
119
-
120
- it 'should apply to projects having testng sources' do
121
- define('one', :base_dir => 'one') do
122
- write _('src/test/java/example/OneTest.java'), <<-JAVA
123
- package example;
124
- public class OneTest {
125
- @org.testng.annotations.Test
126
- public void testNothing() {}
127
- }
128
- JAVA
129
- JtestR.applies_to?(self).should be_true
130
- end
131
- end
132
-
133
- it 'should use a java compiler if java sources found' do
134
- foo do
135
- write _('src/spec/java/Something.java'), 'public class Something {}'
136
- test.compile.language.should eql(:java)
137
- end
138
- end
139
-
140
- it 'should load user jtestr_config.rb' do
141
- foo do
142
- hello = _('hello')
143
- write('src/spec/ruby/jtestr_config.rb', "File.open('#{hello}', 'w') { |f| f.write 'HELLO' }")
144
- write('src/spec/ruby/some_spec.rb')
145
- test.invoke
146
- File.should be_exist(hello)
147
- File.read(hello).should == 'HELLO'
148
- end
149
- end
150
-
151
- it 'should run junit tests' do
152
- write('src/test/java/example/SuccessTest.java', <<-JAVA)
153
- package example;
154
- public class SuccessTest extends junit.framework.TestCase {
155
- public void testSuccess() { assertTrue(true); }
156
- }
157
- JAVA
158
- write('src/test/java/example/FailureTest.java', <<-JAVA)
159
- package example;
160
- public class FailureTest extends junit.framework.TestCase {
161
- public void testFailure() { assertTrue(false); }
162
- }
163
- JAVA
164
- foo do
165
- lambda { test.invoke }.should raise_error(/Tests failed/)
166
- test.tests.should include('example.SuccessTest', 'example.FailureTest')
167
- test.failed_tests.should include('example.FailureTest')
168
- test.passed_tests.should include('example.SuccessTest')
169
- end
170
- end
171
-
172
- it 'should run testng tests' do
173
- write('src/test/java/example/Success.java', <<-JAVA)
174
- package example;
175
- public class Success {
176
- @org.testng.annotations.Test
177
- public void annotatedSuccess() { org.testng.Assert.assertTrue(true); }
178
- }
179
- JAVA
180
- write('src/test/java/example/Failure.java', <<-JAVA)
181
- package example;
182
- public class Failure {
183
- @org.testng.annotations.Test
184
- public void annotatedFail() { org.testng.Assert.fail("FAIL"); }
185
- }
186
- JAVA
187
- foo do
188
- lambda { test.invoke }.should raise_error(/Tests failed/)
189
- test.tests.should include('example.Success', 'example.Failure')
190
- test.failed_tests.should include('example.Failure')
191
- test.passed_tests.should include('example.Success')
192
- end
193
- end
194
-
195
- it 'should run test_unit' do
196
- success = File.expand_path('src/spec/ruby/success_test.rb')
197
- write(success, <<-TESTUNIT)
198
- require 'test/unit'
199
- class TC_Success < Test::Unit::TestCase
200
- def test_success
201
- assert true
202
- end
203
- end
204
- TESTUNIT
205
- failure = File.expand_path('src/spec/ruby/failure_test.rb')
206
- write(failure, <<-TESTUNIT)
207
- require 'test/unit'
208
- class TC_Failure < Test::Unit::TestCase
209
- def test_failure
210
- assert false
211
- end
212
- end
213
- TESTUNIT
214
- error = File.expand_path('src/spec/ruby/error_test.rb')
215
- write(error, <<-TESTUNIT)
216
- require 'test/unit'
217
- class TC_Error < Test::Unit::TestCase
218
- def test_error
219
- lambda;
220
- end
221
- end
222
- TESTUNIT
223
- foo do
224
- lambda { test.invoke }.should raise_error(/Tests failed/)
225
- test.tests.should include(success, failure, error)
226
- test.failed_tests.should include(failure, error)
227
- test.passed_tests.should include(success)
228
- end
229
- end
230
-
231
- it 'should run expectations' do
232
- success = File.expand_path('src/spec/ruby/success_expect.rb')
233
- write(success, 'Expectations { expect(true) { true } }')
234
- failure = File.expand_path('src/spec/ruby/failure_expect.rb')
235
- write(failure, 'Expectations { expect(true) { false } }')
236
- error = File.expand_path('src/spec/ruby/error_expect.rb')
237
- write(error, 'Expectations { expect(nil) { lambda {}; } }')
238
- foo do
239
- lambda { test.invoke }.should raise_error(/Tests failed/)
240
- test.tests.should include(success, failure, error)
241
- test.failed_tests.should include(failure, error)
242
- test.passed_tests.should include(success)
243
- end
244
- end
245
-
246
- it 'should run rspecs' do
247
- success = File.expand_path('src/spec/ruby/success_spec.rb')
248
- write(success, 'describe("success") { it("is true") { nil.should be_nil } }')
249
- failure = File.expand_path('src/spec/ruby/failure_spec.rb')
250
- write(failure, 'describe("failure") { it("is false") { true.should == false } }')
251
- error = File.expand_path('src/spec/ruby/error_spec.rb')
252
- write(error, 'describe("error") { it("raises") { lambda; } }')
253
- pending = File.expand_path('src/spec/ruby/pending_spec.rb')
254
- write(pending, 'describe("pending") { it "is not implemented" }')
255
- foo do
256
- lambda { test.invoke }.should raise_error(/Tests failed/)
257
- test.tests.should include(success, failure, error)
258
- test.failed_tests.should include(failure, error)
259
- test.passed_tests.should include(success)
260
- end
261
- end
262
-
263
- after do
264
- # reset to default
265
- Buildr.settings.build['junit'] = nil
266
- Buildr::JUnit.instance_eval { @dependencies = nil }
267
- Buildr::JtestR.instance_eval { @dependencies = nil }
268
- end
269
-
270
- end if ENV["JTESTR"] && (RUBY_PLATFORM =~ /java/ || ENV['JRUBY_HOME']) # JtestR
271
-
272
62
  describe Buildr::JBehave do
273
63
  def foo(*args, &prc)
274
64
  define('foo', *args) do