buildr 1.3.5-java → 1.4.0-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. data/CHANGELOG +153 -8
  2. data/README.rdoc +1 -1
  3. data/addon/buildr/antlr.rb +5 -5
  4. data/addon/buildr/drb.rb +18 -18
  5. data/addon/buildr/hibernate.rb +18 -14
  6. data/addon/buildr/javacc.rb +4 -4
  7. data/addon/buildr/jetty.rb +5 -5
  8. data/addon/buildr/nailgun.rb +23 -23
  9. data/addon/buildr/openjpa.rb +1 -1
  10. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  11. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  12. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  13. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  14. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  15. data/addon/buildr/protobuf.rb +75 -0
  16. data/addon/buildr/xmlbeans.rb +5 -5
  17. data/buildr.buildfile +2 -2
  18. data/buildr.gemspec +8 -7
  19. data/doc/_layouts/default.html +2 -2
  20. data/doc/artifacts.textile +4 -4
  21. data/doc/building.textile +35 -3
  22. data/doc/contributing.textile +5 -0
  23. data/doc/download.textile +16 -5
  24. data/doc/extending.textile +38 -12
  25. data/doc/installing.textile +6 -5
  26. data/doc/languages.textile +182 -42
  27. data/doc/more_stuff.textile +2 -2
  28. data/doc/packaging.textile +14 -15
  29. data/doc/projects.textile +7 -2
  30. data/doc/quick_start.textile +4 -4
  31. data/doc/scripts/buildr-git.rb +63 -63
  32. data/doc/scripts/gitflow.rb +21 -21
  33. data/doc/settings_profiles.textile +9 -2
  34. data/doc/testing.textile +16 -5
  35. data/etc/KEYS +38 -0
  36. data/lib/buildr.rb +1 -1
  37. data/lib/buildr/core.rb +1 -0
  38. data/lib/buildr/core/application.rb +33 -27
  39. data/lib/buildr/core/build.rb +41 -28
  40. data/lib/buildr/core/cc.rb +172 -0
  41. data/lib/buildr/core/checks.rb +1 -1
  42. data/lib/buildr/core/common.rb +7 -6
  43. data/lib/buildr/core/compile.rb +7 -8
  44. data/lib/buildr/core/doc.rb +263 -0
  45. data/lib/buildr/core/environment.rb +6 -6
  46. data/lib/buildr/core/filter.rb +77 -35
  47. data/lib/buildr/core/generate.rb +7 -7
  48. data/lib/buildr/core/help.rb +1 -1
  49. data/lib/buildr/core/osx.rb +6 -6
  50. data/lib/buildr/core/progressbar.rb +4 -4
  51. data/lib/buildr/core/project.rb +144 -36
  52. data/lib/buildr/core/shell.rb +34 -34
  53. data/lib/buildr/core/test.rb +89 -20
  54. data/lib/buildr/core/transports.rb +8 -7
  55. data/lib/buildr/core/util.rb +77 -23
  56. data/lib/buildr/groovy/bdd.rb +5 -5
  57. data/lib/buildr/groovy/compiler.rb +19 -15
  58. data/lib/buildr/groovy/shell.rb +6 -6
  59. data/lib/buildr/ide/eclipse.rb +148 -75
  60. data/lib/buildr/ide/eclipse/java.rb +3 -3
  61. data/lib/buildr/ide/eclipse/plugin.rb +8 -5
  62. data/lib/buildr/ide/eclipse/scala.rb +4 -2
  63. data/lib/buildr/ide/idea.rb +2 -2
  64. data/lib/buildr/ide/idea7x.rb +23 -4
  65. data/lib/buildr/java.rb +1 -0
  66. data/lib/buildr/java/ant.rb +4 -4
  67. data/lib/buildr/java/bdd.rb +51 -54
  68. data/lib/buildr/java/cobertura.rb +57 -35
  69. data/lib/buildr/java/commands.rb +14 -5
  70. data/lib/buildr/java/compiler.rb +3 -217
  71. data/lib/buildr/java/deprecated.rb +4 -4
  72. data/lib/buildr/java/doc.rb +70 -0
  73. data/lib/buildr/java/emma.rb +22 -22
  74. data/lib/buildr/java/jruby.rb +4 -4
  75. data/lib/buildr/java/jtestr_runner.rb.erb +27 -25
  76. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  77. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +8 -3
  78. data/lib/buildr/java/packaging.rb +30 -29
  79. data/lib/buildr/java/pom.rb +4 -4
  80. data/lib/buildr/java/rjb.rb +6 -6
  81. data/lib/buildr/java/test_result.rb +61 -85
  82. data/lib/buildr/java/tests.rb +44 -27
  83. data/lib/buildr/java/version_requirement.rb +8 -8
  84. data/lib/buildr/packaging/archive.rb +55 -22
  85. data/lib/buildr/packaging/artifact.rb +75 -36
  86. data/lib/buildr/packaging/artifact_namespace.rb +90 -78
  87. data/lib/buildr/packaging/artifact_search.rb +5 -5
  88. data/lib/buildr/packaging/gems.rb +11 -7
  89. data/lib/buildr/packaging/package.rb +10 -7
  90. data/lib/buildr/packaging/tar.rb +14 -14
  91. data/lib/buildr/packaging/version_requirement.rb +30 -10
  92. data/lib/buildr/packaging/ziptask.rb +51 -13
  93. data/lib/buildr/scala.rb +1 -0
  94. data/lib/buildr/scala/bdd.rb +25 -20
  95. data/lib/buildr/scala/compiler.rb +87 -40
  96. data/lib/buildr/scala/doc.rb +106 -0
  97. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  98. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
  99. data/lib/buildr/scala/shell.rb +14 -9
  100. data/lib/buildr/scala/tests.rb +33 -26
  101. data/lib/buildr/shell.rb +33 -33
  102. data/rakelib/all-in-one.rake +113 -0
  103. data/rakelib/checks.rake +1 -1
  104. data/rakelib/doc.rake +7 -0
  105. data/rakelib/package.rake +1 -1
  106. data/rakelib/release.rake +9 -6
  107. data/rakelib/rspec.rake +26 -7
  108. data/rakelib/setup.rake +15 -3
  109. data/rakelib/stage.rake +18 -11
  110. data/spec/addon/drb_spec.rb +25 -25
  111. data/spec/core/application_spec.rb +111 -21
  112. data/spec/core/build_spec.rb +16 -15
  113. data/spec/core/cc_spec.rb +174 -0
  114. data/spec/core/checks_spec.rb +34 -34
  115. data/spec/core/common_spec.rb +51 -5
  116. data/spec/core/compile_spec.rb +89 -14
  117. data/spec/core/extension_spec.rb +127 -19
  118. data/spec/core/generate_spec.rb +2 -2
  119. data/spec/core/project_spec.rb +10 -10
  120. data/spec/core/test_spec.rb +144 -35
  121. data/spec/core/transport_spec.rb +8 -8
  122. data/spec/core/util_spec.rb +63 -5
  123. data/spec/groovy/bdd_spec.rb +5 -5
  124. data/spec/groovy/compiler_spec.rb +29 -18
  125. data/spec/ide/eclipse_spec.rb +185 -9
  126. data/spec/ide/idea7x_spec.rb +22 -10
  127. data/spec/java/ant_spec.rb +9 -5
  128. data/spec/java/bdd_spec.rb +29 -37
  129. data/spec/java/cobertura_spec.rb +12 -12
  130. data/spec/java/commands_spec.rb +34 -0
  131. data/spec/java/compiler_spec.rb +53 -53
  132. data/spec/java/emma_spec.rb +11 -11
  133. data/spec/java/java_spec.rb +10 -10
  134. data/spec/java/packaging_spec.rb +67 -20
  135. data/spec/java/test_coverage_helper.rb +18 -18
  136. data/spec/java/tests_spec.rb +13 -9
  137. data/spec/packaging/archive_spec.rb +187 -20
  138. data/spec/packaging/artifact_namespace_spec.rb +172 -83
  139. data/spec/packaging/artifact_spec.rb +83 -18
  140. data/spec/packaging/packaging_spec.rb +41 -14
  141. data/spec/sandbox.rb +23 -12
  142. data/spec/scala/bdd_spec.rb +13 -8
  143. data/spec/scala/compiler_spec.rb +18 -13
  144. data/spec/scala/scala.rb +3 -3
  145. data/spec/scala/tests_spec.rb +46 -24
  146. data/spec/spec_helpers.rb +28 -10
  147. data/spec/version_requirement_spec.rb +25 -11
  148. metadata +148 -132
  149. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
  150. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +0 -35
  151. data/rakelib/stage.rake~ +0 -213
@@ -18,13 +18,13 @@ require File.join(File.dirname(__FILE__), '../spec_helpers')
18
18
 
19
19
 
20
20
  describe Buildr::Generate do
21
-
21
+
22
22
  describe 'Generated buildfile' do
23
23
  it 'should be a legal buildfile' do
24
24
  File.open('buildfile', 'w') { |file| file.write Generate.from_directory(Dir.pwd).join("\n") }
25
25
  lambda { Buildr.application.run }.should_not raise_error
26
26
  end
27
-
27
+
28
28
  it 'should not contain NEXT_VERSION because it was removed in buildr 1.3.3' do
29
29
  buildfile = Generate.from_directory(Dir.pwd)
30
30
  buildfile.each { |line| line.should_not include('NEXT_VERSION')}
@@ -45,7 +45,7 @@ describe Project do
45
45
  foo.should be(project('foo'))
46
46
  bar.should be(project('bar'))
47
47
  end
48
-
48
+
49
49
  it 'should show up in projects list if defined' do
50
50
  define('foo')
51
51
  projects.map(&:name).should include('foo')
@@ -206,7 +206,7 @@ describe Layout do
206
206
  @layout.expand(:foo, nil, :bar).should eql('none')
207
207
  @layout.expand(nil, :foo).should eql('foo')
208
208
  end
209
-
209
+
210
210
  it 'should return nil if path not mapped' do
211
211
  @layout[:foo].should be_nil
212
212
  end
@@ -368,7 +368,7 @@ describe Project, '#on_define' do
368
368
  define('foo') { define 'bar' }
369
369
  scopes.should eql([['foo'], ['foo', 'bar']])
370
370
  end
371
-
371
+
372
372
  it 'should be removed in version 1.5 since it was deprecated in version 1.3' do
373
373
  Buildr::VERSION.should < '1.5'
374
374
  end
@@ -418,7 +418,7 @@ describe 'Sub-project' do
418
418
  define 'foo' do
419
419
  define 'bar'
420
420
  define 'bar'
421
- end
421
+ end
422
422
  end.should raise_error
423
423
  end
424
424
 
@@ -456,7 +456,7 @@ describe 'Sub-project' do
456
456
  ordered << self.name
457
457
  define('bar') { ordered << self.name }
458
458
  define('baz') { ordered << self.name }
459
- end
459
+ end
460
460
  ordered.should eql(['foo', 'foo:bar', 'foo:baz'])
461
461
  end
462
462
 
@@ -466,7 +466,7 @@ describe 'Sub-project' do
466
466
  ordered << self.name
467
467
  define('bar') { project('foo:baz') ; ordered << self.name }
468
468
  define('baz') { ordered << self.name }
469
- end
469
+ end
470
470
  ordered.should eql(['foo', 'foo:baz', 'foo:bar'])
471
471
  end
472
472
 
@@ -475,7 +475,7 @@ describe 'Sub-project' do
475
475
  define 'foo' do
476
476
  define('bar') { project('foo:baz') }
477
477
  define('baz') { project('foo:bar') }
478
- end
478
+ end
479
479
  end.should raise_error(RuntimeError, /Circular dependency/)
480
480
  end
481
481
  end
@@ -645,7 +645,7 @@ describe Project, '#task' do
645
645
  it 'should create a regular task' do
646
646
  define('foo') { task('bar') }
647
647
  Buildr.application.lookup('foo:bar').should_not be_nil
648
- end
648
+ end
649
649
 
650
650
  it 'should return a task defined in the project' do
651
651
  define('foo') { task('bar') }
@@ -661,7 +661,7 @@ describe Project, '#task' do
661
661
  define('foo') { task('bar') }
662
662
  project('foo').task('bar').name.should eql('foo:bar')
663
663
  end
664
-
664
+
665
665
  it 'should ignore namespace if starting with color' do
666
666
  define 'foo' do
667
667
  task(':bar').name.should == 'bar'
@@ -744,7 +744,7 @@ end
744
744
 
745
745
 
746
746
  =begin
747
- describe Buildr::Generate do
747
+ describe Buildr::Generate do
748
748
  it 'should be able to create buildfile from directory structure' do
749
749
  write 'src/main/java/Foo.java', ''
750
750
  write 'one/two/src/main/java/Foo.java', ''
@@ -110,12 +110,22 @@ describe Buildr::TestTask do
110
110
  test_task.compile.dependencies.should include(artifact('acme:example:jar:1.0'))
111
111
  end
112
112
 
113
+ it 'should respond to deprecated classpath' do
114
+ test_task.classpath = artifact('acme:example:jar:1.0')
115
+ test_task.classpath.should be(artifact('acme:example:jar:1.0'))
116
+ end
117
+
118
+ it 'should respond to dependencies' do
119
+ test_task.dependencies = artifact('acme:example:jar:1.0')
120
+ test_task.dependencies.should be(artifact('acme:example:jar:1.0'))
121
+ end
122
+
113
123
  it 'should respond to :with and add artifacfs to task dependencies' do
114
124
  test_task.with 'test.jar', 'acme:example:jar:1.0'
115
125
  test_task.dependencies.should include(File.expand_path('test.jar'))
116
126
  test_task.dependencies.should include(artifact('acme:example:jar:1.0'))
117
127
  end
118
-
128
+
119
129
  it 'should response to :options and return test framework options' do
120
130
  test_task.using :foo=>'bar'
121
131
  test_task.options[:foo].should eql('bar')
@@ -216,9 +226,9 @@ describe Buildr::TestTask do
216
226
  define('foo').test.dependencies.should include(project('foo').resources.target)
217
227
  end
218
228
 
219
- it 'should not use the test compile dependencies' do
229
+ it 'should use the test compile dependencies' do
220
230
  define('foo') { test.compile.using(:javac).with 'group:id:jar:1.0' }
221
- project('foo').test.dependencies.should_not include(artifact('group:id:jar:1.0'))
231
+ project('foo').test.dependencies.should include(artifact('group:id:jar:1.0'))
222
232
  end
223
233
 
224
234
  it 'should include the test compile target in its dependencies' do
@@ -252,7 +262,7 @@ describe Buildr::TestTask do
252
262
  depends = project('foo').test.dependencies
253
263
  depends.index(project('foo').test.resources.target).should < depends.index(project('foo').resources.target)
254
264
  end
255
-
265
+
256
266
  it 'should not have a last successful run timestamp before the tests are run' do
257
267
  test_task.timestamp.should == Rake::EARLY
258
268
  end
@@ -268,6 +278,14 @@ describe Buildr::TestTask do
268
278
  mkpath project('foo').test.report_to.to_s
269
279
  lambda { task('clean').invoke }.should change { File.exist?(project('foo').test.report_to.to_s) }.to(false)
270
280
  end
281
+
282
+ it 'should only run tests explicitly specified if options.test is :only' do
283
+ Buildr.options.test = :only
284
+ write 'bar/src/main/java/Bar.java', 'public class Bar {}'
285
+ define('bar', :version=>'1.0', :base_dir=>'bar') { package :jar }
286
+ define('foo') { compile.with project('bar') }
287
+ lambda { task('foo:test').invoke rescue nil }.should_not run_tasks('bar:test')
288
+ end
271
289
  end
272
290
 
273
291
 
@@ -279,7 +297,7 @@ describe Buildr::TestTask, 'with no tests' do
279
297
  it 'should report no failed tests' do
280
298
  lambda { verbose(true) { define('foo').test.invoke } }.should_not show_error(/fail/i)
281
299
  end
282
-
300
+
283
301
  it 'should return no failed tests' do
284
302
  define('foo') { test.using(:junit) }
285
303
  project('foo').test.invoke
@@ -319,7 +337,7 @@ describe Buildr::TestTask, 'with passing tests' do
319
337
  it 'should report no failed tests' do
320
338
  lambda { verbose(true) { test_task.invoke } }.should_not show_error(/fail/i)
321
339
  end
322
-
340
+
323
341
  it 'should return passed tests' do
324
342
  test_task.invoke
325
343
  test_task.passed_tests.should == ['PassingTest1', 'PassingTest2']
@@ -343,7 +361,7 @@ end
343
361
 
344
362
  describe Buildr::TestTask, 'with failed test' do
345
363
  include TestHelper
346
-
364
+
347
365
  def test_task
348
366
  @test_task ||= begin
349
367
  define 'foo' do
@@ -365,6 +383,11 @@ describe Buildr::TestTask, 'with failed test' do
365
383
  lambda { verbose(true) { test_task.invoke rescue nil } }.should show_error(/FailingTest/)
366
384
  end
367
385
 
386
+ it 'should record failed tests' do
387
+ test_task.invoke rescue nil
388
+ File.read(project('foo').path_to('target', "#{test_task.framework}-failed")).should == 'FailingTest'
389
+ end
390
+
368
391
  it 'should return failed tests' do
369
392
  test_task.invoke rescue nil
370
393
  test_task.failed_tests.should == ['FailingTest']
@@ -375,6 +398,11 @@ describe Buildr::TestTask, 'with failed test' do
375
398
  test_task.passed_tests.should == ['PassingTest']
376
399
  end
377
400
 
401
+ it 'should know what tests failed last time' do
402
+ test_task.invoke rescue nil
403
+ project('foo').test.last_failures.should == ['FailingTest']
404
+ end
405
+
378
406
  it 'should not fail if fail_on_failure is false' do
379
407
  test_task.using(:fail_on_failure=>false).invoke
380
408
  lambda { test_task.invoke }.should_not raise_error
@@ -393,7 +421,7 @@ describe Buildr::TestTask, 'with failed test' do
393
421
  it 'should execute teardown task' do
394
422
  lambda { test_task.invoke rescue nil }.should run_task('foo:test:teardown')
395
423
  end
396
-
424
+
397
425
  it 'should not update the last successful run timestamp' do
398
426
  a_second_ago = Time.now - 1
399
427
  touch_last_successful_test_run test_task, a_second_ago
@@ -460,7 +488,7 @@ describe Buildr::Project, '#test' do
460
488
  test.options[:environment].should == {}
461
489
  end
462
490
  end
463
-
491
+
464
492
  it 'should clone options from parent project when using #options' do
465
493
  define 'foo' do
466
494
  define 'bar' do
@@ -476,14 +504,14 @@ describe Buildr::Project, '#test' do
476
504
  test.options[:environment].should == {}
477
505
  end
478
506
  end
479
-
507
+
480
508
  it 'should accept to set a test property in the top project' do
481
509
  define 'foo' do
482
510
  test.options[:properties][:foo] = 'bar'
483
511
  end
484
512
  project('foo').test.options[:properties][:foo].should == 'bar'
485
513
  end
486
-
514
+
487
515
  it 'should accept to set a test property in a subproject' do
488
516
  define 'foo' do
489
517
  define 'bar' do
@@ -492,7 +520,7 @@ describe Buildr::Project, '#test' do
492
520
  end
493
521
  project('foo:bar').test.options[:properties][:bar].should == 'baz'
494
522
  end
495
-
523
+
496
524
  it 'should not change options of unrelated projects when using #options' do
497
525
  define 'foo' do
498
526
  test.options[:properties][:foo] = 'bar'
@@ -501,7 +529,7 @@ describe Buildr::Project, '#test' do
501
529
  test.options[:properties].should == {}
502
530
  end
503
531
  end
504
-
532
+
505
533
  it "should run from project's build task" do
506
534
  write 'src/main/java/Foo.java'
507
535
  write 'src/test/java/FooTest.java'
@@ -584,7 +612,9 @@ describe Buildr::Project, '#test.resources' do
584
612
  end
585
613
 
586
614
  it 'should create target directory even if no files to copy' do
587
- define('foo').test.resources.filter.into('resources')
615
+ define('foo') do
616
+ test.resources.filter.into('resources')
617
+ end
588
618
  lambda { file(File.expand_path('resources')).invoke }.should change { File.exist?('resources') }.to(true)
589
619
  end
590
620
 
@@ -598,7 +628,7 @@ end
598
628
 
599
629
  describe Buildr::TestTask, '#invoke' do
600
630
  include TestHelper
601
-
631
+
602
632
  def test_task
603
633
  @test_task ||= define('foo') {
604
634
  test.using(:junit)
@@ -608,7 +638,7 @@ describe Buildr::TestTask, '#invoke' do
608
638
  end
609
639
  }.test
610
640
  end
611
-
641
+
612
642
  it 'should require dependencies to exist' do
613
643
  lambda { test_task.with('no-such.jar').invoke }.should \
614
644
  raise_error(RuntimeError, /Don't know how to build/)
@@ -622,12 +652,12 @@ describe Buildr::TestTask, '#invoke' do
622
652
  it 'should run tests if they have never run' do
623
653
  lambda { test_task.invoke }.should run_task('foo:test')
624
654
  end
625
-
655
+
626
656
  it 'should not run tests if test option is off' do
627
657
  Buildr.options.test = false
628
658
  lambda { test_task.invoke }.should_not run_task('foo:test')
629
659
  end
630
-
660
+
631
661
  describe 'when there was a successful test run already' do
632
662
  before do
633
663
  @a_second_ago = Time.now - 1
@@ -635,57 +665,69 @@ describe Buildr::TestTask, '#invoke' do
635
665
  target = ['classes/Foo.class', 'resources/config.xml', 'test/classes/FooTest.class', 'test/resources/config-test.xml'].map { |f| File.join('target', f) }
636
666
  files = ['buildfile'] + src + target
637
667
  files.each { |file| write file }
638
- (files + files.map { |file| file.pathmap('%d') }).each { |file| File.utime(@a_second_ago, @a_second_ago, file) }
668
+ dirs = (src + target).map { |file| file.pathmap('%d') }
669
+ (files + dirs ).each { |path| File.utime(@a_second_ago, @a_second_ago, path) }
639
670
  touch_last_successful_test_run test_task, @a_second_ago
640
671
  end
641
-
672
+
642
673
  it 'should not run tests if nothing changed' do
643
674
  lambda { test_task.invoke }.should_not run_task('foo:test')
644
675
  end
645
-
676
+
646
677
  it 'should run tests if options.test is :all' do
647
678
  Buildr.options.test = :all
648
679
  lambda { test_task.invoke }.should run_task('foo:test')
649
680
  end
650
-
681
+
651
682
  it 'should run tests if main compile target changed' do
652
683
  touch project('foo').compile.target.to_s
653
684
  lambda { test_task.invoke }.should run_task('foo:test')
654
685
  end
655
-
686
+
656
687
  it 'should run tests if test compile target changed' do
657
688
  touch test_task.compile.target.to_s
658
689
  lambda { test_task.invoke }.should run_task('foo:test')
659
690
  end
660
-
691
+
661
692
  it 'should run tests if main resources changed' do
662
693
  touch project('foo').resources.target.to_s
663
694
  lambda { test_task.invoke }.should run_task('foo:test')
664
695
  end
665
-
696
+
666
697
  it 'should run tests if test resources changed' do
667
698
  touch test_task.resources.target.to_s
668
699
  lambda { test_task.invoke }.should run_task('foo:test')
669
700
  end
670
-
701
+
671
702
  it 'should run tests if compile-dependent project changed' do
672
703
  write 'bar/src/main/java/Bar.java', 'public class Bar {}'
673
704
  define('bar', :version=>'1.0', :base_dir=>'bar') { package :jar }
674
705
  project('foo').compile.with project('bar')
675
706
  lambda { test_task.invoke }.should run_task('foo:test')
676
707
  end
677
-
708
+
678
709
  it 'should run tests if test-dependent project changed' do
679
710
  write 'bar/src/main/java/Bar.java', 'public class Bar {}'
680
711
  define('bar', :version=>'1.0', :base_dir=>'bar') { package :jar }
681
712
  test_task.with project('bar')
682
713
  lambda { test_task.invoke }.should run_task('foo:test')
683
714
  end
684
-
715
+
685
716
  it 'should run tests if buildfile changed' do
686
717
  touch 'buildfile'
718
+ test_task.should_receive(:run_tests)
687
719
  lambda { test_task.invoke }.should run_task('foo:test')
688
720
  end
721
+
722
+ it 'should not run tests if buildfile changed but IGNORE_BUILDFILE is true' do
723
+ begin
724
+ ENV["IGNORE_BUILDFILE"] = "true"
725
+ test_task.should_not_receive(:run_tests)
726
+ test_task.invoke
727
+ ensure
728
+ ENV["IGNORE_BUILDFILE"] = nil
729
+ end
730
+ end
689
731
  end
690
732
  end
691
733
 
@@ -713,9 +755,38 @@ describe Rake::Task, 'test' do
713
755
  it 'should ignore failure if options.test is :all' do
714
756
  define('foo') { test { fail } }
715
757
  define('bar') { test { fail } }
716
- options.test = :all
758
+ options.test = :all
717
759
  lambda { task('test').invoke rescue nil }.should run_tasks('foo:test', 'bar:test')
718
760
  end
761
+
762
+ it 'should ignore failure in subprojects if options.test is :all' do
763
+ define('foo') {
764
+ define('p1') { test { fail } }
765
+ define('p2') { test { } }
766
+ define('p3') { test { fail } }
767
+ }
768
+ define('bar') { test { fail } }
769
+ options.test = :all
770
+ lambda { task('test').invoke rescue nil }.should run_tasks('foo:p1:test', 'foo:p2:test', 'foo:p3:test', 'bar:test')
771
+ end
772
+
773
+ it 'should ignore failure in subprojects if environment variable test is \'all\'' do
774
+ define('foo') {
775
+ define('p1') { test { fail } }
776
+ define('p2') { test { } }
777
+ define('p3') { test { fail } }
778
+ }
779
+ define('bar') { test { fail } }
780
+ ENV['test'] = 'all'
781
+ lambda { task('test').invoke rescue nil }.should run_tasks('foo:p1:test', 'foo:p2:test', 'foo:p3:test', 'bar:test')
782
+ end
783
+
784
+ it 'should ignore failure if options.test is :all and target is build task ' do
785
+ define('foo') { test { fail } }
786
+ define('bar') { test { fail } }
787
+ options.test = :all
788
+ lambda { task('build').invoke rescue nil }.should run_tasks('foo:test', 'bar:test')
789
+ end
719
790
 
720
791
  it 'should ignore failure if environment variable test is \'all\'' do
721
792
  define('foo') { test { fail } }
@@ -751,12 +822,18 @@ describe Rake::Task, 'test' do
751
822
  ENV['TEST'] = 'no'
752
823
  lambda { task('test').invoke rescue nil }.should_not run_tasks('foo:test', 'bar:test')
753
824
  end
754
- end
755
825
 
826
+ it "should not compile tests if environment variable test is 'no'" do
827
+ write "src/test/java/HelloTest.java", "public class HelloTest { public void testTest() {}}"
828
+ define('foo') { test { fail } }
829
+ ENV['test'] = 'no'
830
+ lambda { task('test').invoke rescue nil }.should_not run_tasks('foo:test:compile')
831
+ end
832
+ end
756
833
 
757
834
  describe 'test rule' do
758
835
  include TestHelper
759
-
836
+
760
837
  it 'should execute test task on local project' do
761
838
  define('foo') { define 'bar' }
762
839
  lambda { task('test:something').invoke }.should run_task('foo:test')
@@ -816,7 +893,7 @@ describe 'test rule' do
816
893
  define 'foo'
817
894
  task('test:Something').invoke
818
895
  end
819
-
896
+
820
897
  it 'should execute the named tests even if the test task is not needed' do
821
898
  define 'foo' do
822
899
  test.using(:junit)
@@ -826,7 +903,7 @@ describe 'test rule' do
826
903
  task('test:something').invoke
827
904
  project('foo').test.tests.should include('something')
828
905
  end
829
-
906
+
830
907
  it 'should not update the last successful test run timestamp' do
831
908
  define 'foo' do
832
909
  test.using(:junit)
@@ -839,6 +916,38 @@ describe 'test rule' do
839
916
  end
840
917
  end
841
918
 
919
+ describe 'test failed' do
920
+ include TestHelper
921
+
922
+ def test_task
923
+ @test_task ||= begin
924
+ define 'foo' do
925
+ test.using(:junit)
926
+ test.instance_eval do
927
+ @framework.stub!(:tests).and_return(['FailingTest', 'PassingTest'])
928
+ @framework.stub!(:run).and_return(['PassingTest'])
929
+ end
930
+ end
931
+ project('foo').test
932
+ end
933
+ end
934
+
935
+ it 'should run the tests that failed the last time' do
936
+ define 'foo' do
937
+ test.using(:junit)
938
+ test.instance_eval do
939
+ @framework.stub!(:tests).and_return(['FailingTest', 'PassingTest'])
940
+ @framework.stub!(:run).and_return(['PassingTest'])
941
+ end
942
+ end
943
+ write project('foo').path_to(:target, "junit-failed"), "FailingTest"
944
+ task('test:failed').invoke rescue nil
945
+ project('foo').test.tests.should include('FailingTest')
946
+ project('foo').test.tests.should_not include('PassingTest')
947
+ end
948
+
949
+ end
950
+
842
951
 
843
952
  describe Buildr::Options, 'test' do
844
953
  it 'should be true by default' do
@@ -972,7 +1081,7 @@ describe Rake::Task, 'integration' do
972
1081
  end
973
1082
 
974
1083
  it 'should run test cases marked for integration' do
975
- write 'src/test/java/FailingTest.java',
1084
+ write 'src/test/java/FailingTest.java',
976
1085
  'public class FailingTest extends junit.framework.TestCase { public void testNothing() { assertTrue(false); } }'
977
1086
  define('foo') { test.using :integration }
978
1087
  lambda { task('test').invoke }.should_not raise_error
@@ -996,7 +1105,7 @@ describe Rake::Task, 'integration' do
996
1105
  end
997
1106
 
998
1107
  it 'should not fail if test=all' do
999
- write 'src/test/java/FailingTest.java',
1108
+ write 'src/test/java/FailingTest.java',
1000
1109
  'public class FailingTest extends junit.framework.TestCase { public void testNothing() { assertTrue(false); } }'
1001
1110
  define('foo') { test.using :integration }
1002
1111
  options.test = :all