realityforge-buildr 1.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +5 -0
  3. data/LICENSE +176 -0
  4. data/NOTICE +26 -0
  5. data/README.md +3 -0
  6. data/Rakefile +50 -0
  7. data/addon/buildr/checkstyle-report.xsl +104 -0
  8. data/addon/buildr/checkstyle.rb +254 -0
  9. data/addon/buildr/git_auto_version.rb +36 -0
  10. data/addon/buildr/gpg.rb +90 -0
  11. data/addon/buildr/gwt.rb +413 -0
  12. data/addon/buildr/jacoco.rb +161 -0
  13. data/addon/buildr/pmd.rb +185 -0
  14. data/addon/buildr/single_intermediate_layout.rb +71 -0
  15. data/addon/buildr/spotbugs.rb +265 -0
  16. data/addon/buildr/top_level_generate_dir.rb +37 -0
  17. data/addon/buildr/wsgen.rb +192 -0
  18. data/bin/buildr +20 -0
  19. data/buildr.gemspec +61 -0
  20. data/lib/buildr.rb +86 -0
  21. data/lib/buildr/core/application.rb +705 -0
  22. data/lib/buildr/core/assets.rb +96 -0
  23. data/lib/buildr/core/build.rb +587 -0
  24. data/lib/buildr/core/common.rb +167 -0
  25. data/lib/buildr/core/compile.rb +599 -0
  26. data/lib/buildr/core/console.rb +124 -0
  27. data/lib/buildr/core/doc.rb +275 -0
  28. data/lib/buildr/core/environment.rb +128 -0
  29. data/lib/buildr/core/filter.rb +405 -0
  30. data/lib/buildr/core/help.rb +114 -0
  31. data/lib/buildr/core/progressbar.rb +161 -0
  32. data/lib/buildr/core/project.rb +994 -0
  33. data/lib/buildr/core/test.rb +776 -0
  34. data/lib/buildr/core/transports.rb +456 -0
  35. data/lib/buildr/core/util.rb +77 -0
  36. data/lib/buildr/ide/idea.rb +1664 -0
  37. data/lib/buildr/java/commands.rb +230 -0
  38. data/lib/buildr/java/compiler.rb +85 -0
  39. data/lib/buildr/java/custom_pom.rb +300 -0
  40. data/lib/buildr/java/doc.rb +62 -0
  41. data/lib/buildr/java/packaging.rb +393 -0
  42. data/lib/buildr/java/pom.rb +191 -0
  43. data/lib/buildr/java/test_result.rb +54 -0
  44. data/lib/buildr/java/tests.rb +111 -0
  45. data/lib/buildr/packaging/archive.rb +586 -0
  46. data/lib/buildr/packaging/artifact.rb +1113 -0
  47. data/lib/buildr/packaging/artifact_namespace.rb +1010 -0
  48. data/lib/buildr/packaging/artifact_search.rb +138 -0
  49. data/lib/buildr/packaging/package.rb +237 -0
  50. data/lib/buildr/packaging/version_requirement.rb +189 -0
  51. data/lib/buildr/packaging/zip.rb +189 -0
  52. data/lib/buildr/packaging/ziptask.rb +387 -0
  53. data/lib/buildr/version.rb +18 -0
  54. data/rakelib/release.rake +99 -0
  55. data/spec/addon/checkstyle_spec.rb +58 -0
  56. data/spec/core/application_spec.rb +576 -0
  57. data/spec/core/build_spec.rb +922 -0
  58. data/spec/core/common_spec.rb +670 -0
  59. data/spec/core/compile_spec.rb +656 -0
  60. data/spec/core/console_spec.rb +65 -0
  61. data/spec/core/doc_spec.rb +194 -0
  62. data/spec/core/extension_spec.rb +200 -0
  63. data/spec/core/project_spec.rb +736 -0
  64. data/spec/core/test_spec.rb +1131 -0
  65. data/spec/core/transport_spec.rb +452 -0
  66. data/spec/core/util_spec.rb +154 -0
  67. data/spec/ide/idea_spec.rb +1952 -0
  68. data/spec/java/commands_spec.rb +79 -0
  69. data/spec/java/compiler_spec.rb +274 -0
  70. data/spec/java/custom_pom_spec.rb +165 -0
  71. data/spec/java/doc_spec.rb +55 -0
  72. data/spec/java/packaging_spec.rb +786 -0
  73. data/spec/java/pom_spec.rb +162 -0
  74. data/spec/java/test_coverage_helper.rb +257 -0
  75. data/spec/java/tests_spec.rb +224 -0
  76. data/spec/packaging/archive_spec.rb +686 -0
  77. data/spec/packaging/artifact_namespace_spec.rb +757 -0
  78. data/spec/packaging/artifact_spec.rb +1351 -0
  79. data/spec/packaging/packaging_helper.rb +63 -0
  80. data/spec/packaging/packaging_spec.rb +690 -0
  81. data/spec/sandbox.rb +166 -0
  82. data/spec/spec_helpers.rb +420 -0
  83. data/spec/version_requirement_spec.rb +145 -0
  84. data/spec/xpath_matchers.rb +123 -0
  85. metadata +295 -0
@@ -0,0 +1,1131 @@
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
+
17
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
18
+
19
+
20
+ module TestHelper
21
+ def touch_last_successful_test_run(test_task, timestamp = Time.now)
22
+ test_task.instance_eval do
23
+ record_successful_run
24
+ File.utime(timestamp, timestamp, last_successful_run_file)
25
+ end
26
+ end
27
+ end
28
+
29
+
30
+ describe Buildr::TestTask do
31
+ def test_task
32
+ @test_task ||= define('foo').test
33
+ end
34
+
35
+ it 'should respond to :compile and return compile task' do
36
+ test_task.compile.should be_kind_of(Buildr::CompileTask)
37
+ end
38
+
39
+ it 'should respond to :compile and add sources to compile' do
40
+ test_task.compile 'sources'
41
+ test_task.compile.sources.should include('sources')
42
+ end
43
+
44
+ it 'should respond to :compile and add action for test:compile' do
45
+ write 'src/test/java/Test.java', 'class Test {}'
46
+ test_task.compile { task('action').invoke }
47
+ lambda { test_task.compile.invoke }.should run_tasks('action')
48
+ end
49
+
50
+ it 'should execute compile tasks first' do
51
+ write 'src/main/java/Nothing.java', 'class Nothing {}'
52
+ write 'src/test/java/Test.java', 'class Test {}'
53
+ define 'foo'
54
+ lambda { project('foo').test.compile.invoke }.should run_tasks(%w[foo:compile foo:test:compile])
55
+ end
56
+
57
+ it 'should respond to :resources and return resources task' do
58
+ test_task.resources.should be_kind_of(Buildr::ResourcesTask)
59
+ end
60
+
61
+ it 'should respond to :resources and add prerequisites to test:resources' do
62
+ file('prereq').should_receive :invoke_prerequisites
63
+ test_task.resources 'prereq'
64
+ test_task.compile.invoke
65
+ end
66
+
67
+ it 'should respond to :resources and add action for test:resources' do
68
+ task 'action'
69
+ test_task.resources { task('action').invoke }
70
+ lambda { test_task.resources.invoke }.should run_tasks('action')
71
+ end
72
+
73
+ it 'should respond to :setup and return setup task' do
74
+ test_task.setup.name.should =~ /test:setup$/
75
+ end
76
+
77
+ it 'should respond to :setup and add prerequisites to test:setup' do
78
+ test_task.setup 'prereq'
79
+ test_task.setup.prerequisites.should include('prereq')
80
+ end
81
+
82
+ it 'should respond to :setup and add action for test:setup' do
83
+ task 'action'
84
+ test_task.setup { task('action').invoke }
85
+ lambda { test_task.setup.invoke }.should run_tasks('action')
86
+ end
87
+
88
+ it 'should respond to :teardown and return teardown task' do
89
+ test_task.teardown.name.should =~ /test:teardown$/
90
+ end
91
+
92
+ it 'should respond to :teardown and add prerequisites to test:teardown' do
93
+ test_task.teardown 'prereq'
94
+ test_task.teardown.prerequisites.should include('prereq')
95
+ end
96
+
97
+ it 'should respond to :teardown and add action for test:teardown' do
98
+ task 'action'
99
+ test_task.teardown { task('action').invoke }
100
+ lambda { test_task.teardown.invoke }.should run_tasks('action')
101
+ end
102
+
103
+ it 'should respond to :with and return self' do
104
+ test_task.with.should be(test_task)
105
+ end
106
+
107
+ it 'should respond to :with and add artifacfs to compile task dependencies' do
108
+ test_task.with 'test.jar', 'acme:example:jar:1.0'
109
+ test_task.compile.dependencies.should include(File.expand_path('test.jar'))
110
+ test_task.compile.dependencies.should include(artifact('acme:example:jar:1.0'))
111
+ end
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
+
123
+ it 'should respond to :with and add artifacfs to task dependencies' do
124
+ test_task.with 'test.jar', 'acme:example:jar:1.0'
125
+ test_task.dependencies.should include(File.expand_path('test.jar'))
126
+ test_task.dependencies.should include(artifact('acme:example:jar:1.0'))
127
+ end
128
+
129
+ it 'should response to :options and return test framework options' do
130
+ test_task.using :foo=>'bar'
131
+ test_task.options[:foo].should eql('bar')
132
+ end
133
+
134
+ it 'should respond to :using and return self' do
135
+ test_task.using.should be(test_task)
136
+ end
137
+
138
+ it 'should respond to :using and set value options' do
139
+ test_task.using('foo'=>'FOO', 'bar'=>'BAR')
140
+ test_task.options[:foo].should eql('FOO')
141
+ test_task.options[:bar].should eql('BAR')
142
+ end
143
+
144
+ it 'should start without pre-selected test framework' do
145
+ test_task.framework.should be_nil
146
+ end
147
+
148
+ it 'should respond to :using and select test framework' do
149
+ test_task.using(:testng)
150
+ test_task.framework.should eql(:testng)
151
+ end
152
+
153
+ it 'should infer test framework from compiled language' do
154
+ lambda { test_task.compile.using(:javac) }.should change { test_task.framework }.to(:testng)
155
+ end
156
+
157
+ it 'should respond to :include and return self' do
158
+ test_task.include.should be(test_task)
159
+ end
160
+
161
+ it 'should respond to :include and add inclusion patterns' do
162
+ test_task.include 'Foo', 'Bar'
163
+ test_task.send(:include?, 'Foo').should be_true
164
+ test_task.send(:include?, 'Bar').should be_true
165
+ end
166
+
167
+ it 'should respond to :exclude and return self' do
168
+ test_task.exclude.should be(test_task)
169
+ end
170
+
171
+ it 'should respond to :exclude and add exclusion patterns' do
172
+ test_task.exclude 'FooTest', 'BarTest'
173
+ test_task.send(:include?, 'FooTest').should be_false
174
+ test_task.send(:include?, 'BarTest').should be_false
175
+ test_task.send(:include?, 'BazTest').should be_true
176
+ end
177
+
178
+ it 'should execute setup task before running tests' do
179
+ mock = double('actions')
180
+ test_task.setup { mock.setup }
181
+ test_task.enhance { mock.tests }
182
+ mock.should_receive(:setup).ordered
183
+ mock.should_receive(:tests).ordered
184
+ test_task.invoke
185
+ end
186
+
187
+ it 'should execute teardown task after running tests' do
188
+ mock = double('actions')
189
+ test_task.teardown { mock.teardown }
190
+ test_task.enhance { mock.tests }
191
+ mock.should_receive(:tests).ordered
192
+ mock.should_receive(:teardown).ordered
193
+ test_task.invoke
194
+ end
195
+
196
+ it 'should not execute teardown if setup failed' do
197
+ test_task.setup { fail }
198
+ lambda { test_task.invoke rescue nil }.should_not run_task(test_task.teardown)
199
+ end
200
+
201
+ it 'should use the main compile dependencies' do
202
+ define('foo') { compile.using(:javac).with 'group:id:jar:1.0' }
203
+ project('foo').test.dependencies.should include(artifact('group:id:jar:1.0'))
204
+ end
205
+
206
+ it 'should include the main compile target in its dependencies' do
207
+ define('foo') { compile.using(:javac) }
208
+ project('foo').test.dependencies.should include(project('foo').compile.target)
209
+ end
210
+
211
+ it 'should include the main compile target in its dependencies, even when using non standard directories' do
212
+ write 'src/java/Nothing.java', 'class Nothing {}'
213
+ define('foo') { compile path_to('src/java') }
214
+ project('foo').test.dependencies.should include(project('foo').compile.target)
215
+ end
216
+
217
+ it 'should include the main resources target in its dependencies' do
218
+ write 'src/main/resources/config.xml'
219
+ define('foo').test.dependencies.should include(project('foo').resources.target)
220
+ end
221
+
222
+ it 'should use the test compile dependencies' do
223
+ define('foo') { test.compile.using(:javac).with 'group:id:jar:1.0' }
224
+ project('foo').test.dependencies.should include(artifact('group:id:jar:1.0'))
225
+ end
226
+
227
+ it 'should include the test compile target in its dependencies' do
228
+ define('foo') { test.compile.using(:javac) }
229
+ project('foo').test.dependencies.should include(project('foo').test.compile.target)
230
+ end
231
+
232
+ it 'should include the test compile target in its dependencies, even when using non standard directories' do
233
+ write 'src/test/Test.java', 'class Test {}'
234
+ define('foo') { test.compile path_to('src/test') }
235
+ project('foo').test.dependencies.should include(project('foo').test.compile.target)
236
+ end
237
+
238
+ it 'should add test compile target ahead of regular compile target' do
239
+ write 'src/main/java/Code.java'
240
+ write 'src/test/java/Test.java'
241
+ define 'foo'
242
+ depends = project('foo').test.dependencies
243
+ depends.index(project('foo').test.compile.target).should < depends.index(project('foo').compile.target)
244
+ end
245
+
246
+ it 'should include the test resources target in its dependencies' do
247
+ write 'src/test/resources/config.xml'
248
+ define('foo').test.dependencies.should include(project('foo').test.resources.target)
249
+ end
250
+
251
+ it 'should add test resource target ahead of regular resource target' do
252
+ write 'src/main/resources/config.xml'
253
+ write 'src/test/resources/config.xml'
254
+ define 'foo'
255
+ depends = project('foo').test.dependencies
256
+ depends.index(project('foo').test.resources.target).should < depends.index(project('foo').resources.target)
257
+ end
258
+
259
+ it 'should not have a last successful run timestamp before the tests are run' do
260
+ test_task.timestamp.should == Rake::EARLY
261
+ end
262
+
263
+ it 'should clean after itself (test files)' do
264
+ define('foo') { test.compile.using(:javac) }
265
+ mkpath project('foo').test.compile.target.to_s
266
+ lambda { task('clean').invoke }.should change { File.exist?(project('foo').test.compile.target.to_s) }.to(false)
267
+ end
268
+
269
+ it 'should clean after itself (reports)' do
270
+ define 'foo'
271
+ mkpath project('foo').test.report_to.to_s
272
+ lambda { task('clean').invoke }.should change { File.exist?(project('foo').test.report_to.to_s) }.to(false)
273
+ end
274
+
275
+ it 'should only run tests explicitly specified if options.test is :only' do
276
+ Buildr.options.test = :only
277
+ write 'bar/src/main/java/Bar.java', 'public class Bar {}'
278
+ define('bar', :version=>'1.0', :base_dir=>'bar') { package :jar }
279
+ define('foo') { compile.with project('bar') }
280
+ lambda { task('foo:test').invoke rescue nil }.should_not run_tasks('bar:test')
281
+ end
282
+ end
283
+
284
+
285
+ describe Buildr::TestTask, 'with no tests' do
286
+ it 'should pass' do
287
+ lambda { define('foo').test.invoke }.should_not raise_error
288
+ end
289
+
290
+ it 'should report no failed tests' do
291
+ lambda { verbose(true) { define('foo').test.invoke } }.should_not show_error(/fail/i)
292
+ end
293
+
294
+ it 'should return no failed tests' do
295
+ define('foo') { test.using(:testng) }
296
+ project('foo').test.invoke
297
+ project('foo').test.failed_tests.should be_empty
298
+ end
299
+
300
+ it 'should return no passing tests' do
301
+ define('foo') { test.using(:testng) }
302
+ project('foo').test.invoke
303
+ project('foo').test.passed_tests.should be_empty
304
+ end
305
+
306
+ it 'should execute teardown task' do
307
+ lambda { define('foo').test.invoke }.should run_task('foo:test:teardown')
308
+ end
309
+ end
310
+
311
+
312
+ describe Buildr::TestTask, 'with passing tests' do
313
+ def test_task
314
+ @test_task ||= begin
315
+ define 'foo' do
316
+ test.using(:testng)
317
+ test.instance_eval do
318
+ @framework.stub(:tests).and_return(%w[PassingTest1 PassingTest2])
319
+ @framework.stub(:run).and_return(%w[PassingTest1 PassingTest2])
320
+ end
321
+ end
322
+ project('foo').test
323
+ end
324
+ end
325
+
326
+ it 'should pass' do
327
+ lambda { test_task.invoke }.should_not raise_error
328
+ end
329
+
330
+ it 'should report no failed tests' do
331
+ lambda { verbose(true) { test_task.invoke } }.should_not show_error(/fail/i)
332
+ end
333
+
334
+ it 'should return passed tests' do
335
+ test_task.invoke
336
+ test_task.passed_tests.should == %w[PassingTest1 PassingTest2]
337
+ end
338
+
339
+ it 'should return no failed tests' do
340
+ test_task.invoke
341
+ test_task.failed_tests.should be_empty
342
+ end
343
+
344
+ it 'should execute teardown task' do
345
+ lambda { test_task.invoke }.should run_task('foo:test:teardown')
346
+ end
347
+
348
+ it 'should update the last successful run timestamp' do
349
+ before = Time.now ; test_task.invoke ; after = Time.now
350
+ (before-1..after+1).should cover(test_task.timestamp)
351
+ end
352
+ end
353
+
354
+
355
+ describe Buildr::TestTask, 'with failed test' do
356
+ include TestHelper
357
+
358
+ def test_task
359
+ @test_task ||= begin
360
+ define 'foo' do
361
+ test.using(:testng)
362
+ test.instance_eval do
363
+ @framework.stub(:tests).and_return(%w[FailingTest PassingTest])
364
+ @framework.stub(:run).and_return(['PassingTest'])
365
+ end
366
+ end
367
+ project('foo').test
368
+ end
369
+ end
370
+
371
+ it 'should fail' do
372
+ lambda { test_task.invoke }.should raise_error(RuntimeError, /Tests failed/)
373
+ end
374
+
375
+ it 'should report failed tests' do
376
+ lambda { verbose(true) { test_task.invoke rescue nil } }.should show_error(/FailingTest/)
377
+ end
378
+
379
+ it 'should record failed tests' do
380
+ test_task.invoke rescue nil
381
+ File.read(project('foo').path_to('target', "#{test_task.framework}-failed")).should == 'FailingTest'
382
+ end
383
+
384
+ it 'should return failed tests' do
385
+ test_task.invoke rescue nil
386
+ test_task.failed_tests.should == ['FailingTest']
387
+ end
388
+
389
+ it 'should return passing tests as well' do
390
+ test_task.invoke rescue nil
391
+ test_task.passed_tests.should == ['PassingTest']
392
+ end
393
+
394
+ it 'should know what tests failed last time' do
395
+ test_task.invoke rescue nil
396
+ project('foo').test.last_failures.should == ['FailingTest']
397
+ end
398
+
399
+ it 'should not fail if fail_on_failure is false' do
400
+ test_task.using(:fail_on_failure=>false).invoke
401
+ lambda { test_task.invoke }.should_not raise_error
402
+ end
403
+
404
+ it 'should report failed tests even if fail_on_failure is false' do
405
+ test_task.using(:fail_on_failure=>false)
406
+ lambda { verbose(true) { test_task.invoke } }.should show_error(/FailingTest/)
407
+ end
408
+
409
+ it 'should return failed tests even if fail_on_failure is false' do
410
+ test_task.using(:fail_on_failure=>false).invoke
411
+ test_task.failed_tests.should == ['FailingTest']
412
+ end
413
+
414
+ it 'should execute teardown task' do
415
+ lambda { test_task.invoke rescue nil }.should run_task('foo:test:teardown')
416
+ end
417
+
418
+ it 'should not update the last successful run timestamp' do
419
+ a_second_ago = Time.now - 1
420
+ touch_last_successful_test_run test_task, a_second_ago
421
+ test_task.invoke rescue nil
422
+ test_task.timestamp.should <= a_second_ago
423
+ end
424
+ end
425
+
426
+
427
+ describe Buildr::Project, '#test' do
428
+ it 'should return the project\'s test task' do
429
+ define('foo') { test.should be(task('test')) }
430
+ end
431
+
432
+ it 'should accept prerequisites for task' do
433
+ define('foo') { test 'prereq' }
434
+ project('foo').test.prerequisites.should include('prereq')
435
+ end
436
+
437
+ it 'should accept actions for task' do
438
+ task 'action'
439
+ define('foo') { test { task('action').invoke } }
440
+ lambda { project('foo').test.invoke }.should run_tasks('action')
441
+ end
442
+
443
+ it 'should set fail_on_failure true by default' do
444
+ define('foo').test.options[:fail_on_failure].should be_true
445
+ end
446
+
447
+ it 'should set fork mode by default' do
448
+ define('foo').test.options[:fork].should == :once
449
+ end
450
+
451
+ it 'should set properties to empty hash by default' do
452
+ define('foo').test.options[:properties].should == {}
453
+ end
454
+
455
+ it 'should set environment variables to empty hash by default' do
456
+ define('foo').test.options[:environment].should == {}
457
+ end
458
+
459
+ it 'should inherit options from parent project' do
460
+ define 'foo' do
461
+ test.using :fail_on_failure=>false, :fork=>:each, :properties=>{ :foo=>'bar' }, :environment=>{ 'config'=>'config.yaml' }
462
+ define 'bar' do
463
+ test.using :testng
464
+ test.options[:fail_on_failure].should be_false
465
+ test.options[:fork].should == :each
466
+ test.options[:properties][:foo].should == 'bar'
467
+ test.options[:environment]['config'].should == 'config.yaml'
468
+ end
469
+ end
470
+ end
471
+
472
+ it 'should clone options from parent project when using #using' do
473
+ define 'foo' do
474
+ define 'bar' do
475
+ test.using :fail_on_failure=>false, :fork=>:each, :properties=>{ :foo=>'bar' }, :environment=>{ 'config'=>'config.yaml' }
476
+ test.using :testng
477
+ end.invoke
478
+ test.options[:fail_on_failure].should be_true
479
+ test.options[:fork].should == :once
480
+ test.options[:properties].should == {}
481
+ test.options[:environment].should == {}
482
+ end
483
+ end
484
+
485
+ it 'should clone options from parent project when using #options' do
486
+ define 'foo' do
487
+ define 'bar' do
488
+ test.options[:fail_on_failure] = false
489
+ test.options[:fork] = :each
490
+ test.options[:properties][:foo] = 'bar'
491
+ test.options[:environment]['config'] = 'config.yaml'
492
+ test.using :testng
493
+ end.invoke
494
+ test.options[:fail_on_failure].should be_true
495
+ test.options[:fork].should == :once
496
+ test.options[:properties].should == {}
497
+ test.options[:environment].should == {}
498
+ end
499
+ end
500
+
501
+ it 'should accept to set a test property in the top project' do
502
+ define 'foo' do
503
+ test.options[:properties][:foo] = 'bar'
504
+ end
505
+ project('foo').test.options[:properties][:foo].should == 'bar'
506
+ end
507
+
508
+ it 'should accept to set a test property in a subproject' do
509
+ define 'foo' do
510
+ define 'bar' do
511
+ test.options[:properties][:bar] = 'baz'
512
+ end
513
+ end
514
+ project('foo:bar').test.options[:properties][:bar].should == 'baz'
515
+ end
516
+
517
+ it 'should not change options of unrelated projects when using #options' do
518
+ define 'foo' do
519
+ test.options[:properties][:foo] = 'bar'
520
+ end
521
+ define 'bar' do
522
+ test.options[:properties].should == {}
523
+ end
524
+ end
525
+
526
+ it "should run from project's build task" do
527
+ write 'src/main/java/Foo.java'
528
+ write 'src/test/java/FooTest.java'
529
+ define('foo')
530
+ lambda { task('foo:build').invoke }.should run_task('foo:test')
531
+ end
532
+ end
533
+
534
+
535
+ describe Buildr::Project, '#test.compile' do
536
+ it 'should identify compiler from project' do
537
+ write 'src/test/java/com/example/Test.java'
538
+ define('foo') do
539
+ test.compile.compiler.should eql(:javac)
540
+ end
541
+ end
542
+
543
+ it 'should include identified sources' do
544
+ write 'src/test/java/Test.java'
545
+ define('foo') do
546
+ test.compile.sources.should include(_('src/test/java'))
547
+ end
548
+ end
549
+
550
+ it 'should compile to target/test/<code>' do
551
+ define 'foo' do
552
+ layout[:target] = _('targeted')
553
+ test.compile.using(:javac)
554
+ test.compile.target.should eql(file('targeted/test/classes'))
555
+ end
556
+ end
557
+
558
+ it 'should use main compile dependencies' do
559
+ define 'foo' do
560
+ compile.using(:javac).with 'group:id:jar:1.0'
561
+ test.compile.using(:javac)
562
+ end
563
+ project('foo').test.compile.dependencies.should include(artifact('group:id:jar:1.0'))
564
+ end
565
+
566
+ it 'should include the main compiled target in its dependencies' do
567
+ define 'foo' do
568
+ compile.using(:javac).into 'bytecode'
569
+ test.compile.using(:javac)
570
+ end
571
+ project('foo').test.compile.dependencies.should include(file('bytecode'))
572
+ end
573
+
574
+ it 'should include the test framework dependencies' do
575
+ define 'foo' do
576
+ test.compile.using(:javac)
577
+ test.using(:testng)
578
+ end
579
+ project('foo').test.compile.dependencies.should include(*artifacts(TestNG.dependencies))
580
+ end
581
+
582
+ it 'should clean after itself' do
583
+ write 'src/test/java/Nothing.java', 'class Nothing {}'
584
+ define('foo') { test.compile.into 'bytecode' }
585
+ project('foo').test.compile.invoke
586
+ lambda { project('foo').clean.invoke }.should change { File.exist?('bytecode') }.to(false)
587
+ end
588
+ end
589
+
590
+
591
+ describe Buildr::Project, '#test.resources' do
592
+ it 'should ignore resources unless they exist' do
593
+ define('foo').test.resources.sources.should be_empty
594
+ project('foo').test.resources.target.should be_nil
595
+ end
596
+
597
+ it 'should pick resources from src/test/resources if found' do
598
+ mkpath 'src/test/resources'
599
+ define('foo') { test.resources.sources.should include(file('src/test/resources')) }
600
+ end
601
+
602
+ it 'should copy to the resources target directory' do
603
+ write 'src/test/resources/config.xml', '</xml>'
604
+ define('foo') do
605
+ layout[:target] = _('targeted')
606
+ end.test.invoke
607
+
608
+ file('targeted/test/resources/config.xml').should contain('</xml>')
609
+ end
610
+
611
+ it 'should create target directory even if no files to copy' do
612
+ define('foo') do
613
+ test.resources.filter.into('resources')
614
+ end
615
+ lambda { file(File.expand_path('resources')).invoke }.should change { File.exist?('resources') }.to(true)
616
+ end
617
+
618
+ it 'should execute alongside compile task' do
619
+ task 'action'
620
+ define('foo') { test.resources { task('action').invoke } }
621
+ lambda { project('foo').test.compile.invoke }.should run_tasks('action')
622
+ end
623
+ end
624
+
625
+
626
+ describe Buildr::TestTask, '#invoke' do
627
+ include TestHelper
628
+
629
+ def test_task
630
+ @test_task ||= define('foo') {
631
+ test.using(:testng)
632
+ test.instance_eval do
633
+ @framework.stub(:tests).and_return(['PassingTest'])
634
+ @framework.stub(:run).and_return(['PassingTest'])
635
+ end
636
+ }.test
637
+ end
638
+
639
+ it 'should require dependencies to exist' do
640
+ lambda { test_task.with('no-such.jar').invoke }.should \
641
+ raise_error(RuntimeError, /Don't know how to build/)
642
+ end
643
+
644
+ it 'should run all dependencies as prerequisites' do
645
+ file(File.expand_path('no-such.jar')) { task('prereq').invoke }
646
+ lambda { test_task.with('no-such.jar').invoke }.should run_tasks(%w[prereq foo:test])
647
+ end
648
+
649
+ it 'should run tests if they have never run' do
650
+ lambda { test_task.invoke }.should run_task('foo:test')
651
+ end
652
+
653
+ it 'should not run tests if test option is off' do
654
+ Buildr.options.test = false
655
+ lambda { test_task.invoke }.should_not run_task('foo:test')
656
+ end
657
+
658
+ describe 'when there was a successful test run already' do
659
+ before do
660
+ @a_second_ago = Time.now - 1
661
+ src = %w[main/java/Foo.java main/resources/config.xml test/java/FooTest.java test/resources/config-test.xml].map { |f| File.join('src', f) }
662
+ target = %w[classes/Foo.class resources/config.xml test/classes/FooTest.class test/resources/config-test.xml].map { |f| File.join('target', f) }
663
+ files = ['buildfile'] + src + target
664
+ files.each { |file| write file }
665
+ dirs = (src + target).map { |file| file.pathmap('%d') }
666
+ (files + dirs ).each { |path| File.utime(@a_second_ago, @a_second_ago, path) }
667
+ touch_last_successful_test_run test_task, @a_second_ago
668
+ end
669
+
670
+ it 'should not run tests if nothing changed' do
671
+ lambda { test_task.invoke; sleep 1 }.should_not run_task('foo:test')
672
+ end
673
+
674
+ it 'should run tests if options.test is :all' do
675
+ Buildr.options.test = :all
676
+ lambda { test_task.invoke; sleep 1 }.should run_task('foo:test')
677
+ end
678
+
679
+ it 'should run tests if main compile target changed' do
680
+ touch project('foo').compile.target.to_s
681
+ lambda { test_task.invoke; sleep 1 }.should run_task('foo:test')
682
+ end
683
+
684
+ it 'should run tests if test compile target changed' do
685
+ touch test_task.compile.target.to_s
686
+ lambda { test_task.invoke; sleep 1 }.should run_task('foo:test')
687
+ end
688
+
689
+ it 'should run tests if main resources changed' do
690
+ touch project('foo').resources.target.to_s
691
+ lambda { test_task.invoke }.should run_task('foo:test')
692
+ end
693
+
694
+ it 'should run tests if test resources changed' do
695
+ touch test_task.resources.target.to_s
696
+ lambda { test_task.invoke; sleep 1 }.should run_task('foo:test')
697
+ end
698
+
699
+ it 'should run tests if compile-dependent project changed' do
700
+ write 'bar/src/main/java/Bar.java', 'public class Bar {}'
701
+ define('bar', :version=>'1.0', :base_dir=>'bar') { package :jar }
702
+ project('foo').compile.with project('bar')
703
+ lambda { test_task.invoke; sleep 1 }.should run_task('foo:test')
704
+ end
705
+
706
+ it 'should run tests if test-dependent project changed' do
707
+ write 'bar/src/main/java/Bar.java', 'public class Bar {}'
708
+ define('bar', :version=>'1.0', :base_dir=>'bar') { package :jar }
709
+ test_task.with project('bar')
710
+ lambda { test_task.invoke; sleep 1 }.should run_task('foo:test')
711
+ end
712
+
713
+ it 'should run tests if buildfile changed' do
714
+ touch 'buildfile'
715
+ test_task.should_receive(:run_tests)
716
+ lambda { test_task.invoke; sleep 1 }.should run_task('foo:test')
717
+ end
718
+
719
+ it 'should not run tests if buildfile changed but IGNORE_BUILDFILE is true' do
720
+ begin
721
+ ENV["IGNORE_BUILDFILE"] = "true"
722
+ test_task.should_not_receive(:run_tests)
723
+ test_task.invoke
724
+ ensure
725
+ ENV["IGNORE_BUILDFILE"] = nil
726
+ end
727
+ end
728
+ end
729
+ end
730
+
731
+ describe Rake::Task, 'test' do
732
+ it 'should be recursive' do
733
+ define('foo') { define 'bar' }
734
+ lambda { task('test').invoke }.should run_tasks('foo:test', 'foo:bar:test')
735
+ end
736
+
737
+ it 'should be local task' do
738
+ define('foo') { define 'bar' }
739
+ lambda do
740
+ in_original_dir project('foo:bar').base_dir do
741
+ task('test').invoke
742
+ end
743
+ end.should run_task('foo:bar:test').but_not('foo:test')
744
+ end
745
+
746
+ it 'should stop at first failure' do
747
+ define('myproject') do
748
+ define('foo') { test { fail } }
749
+ define('bar') { test { fail } }
750
+ end
751
+ lambda { task('test').invoke rescue nil }.should run_tasks('myproject:bar:test').but_not('myproject:foo:test')
752
+ end
753
+
754
+ it 'should ignore failure if options.test is :all' do
755
+ define('foo') { test { fail } }
756
+ define('bar') { test { fail } }
757
+ options.test = :all
758
+ lambda { task('test').invoke rescue nil }.should run_tasks('foo:test', 'bar:test')
759
+ end
760
+
761
+ it 'should ignore failure in subprojects if options.test is :all' do
762
+ define('foo') {
763
+ define('p1') { test { fail } }
764
+ define('p2') { test { } }
765
+ define('p3') { test { fail } }
766
+ }
767
+ define('bar') { test { fail } }
768
+ options.test = :all
769
+ lambda { task('test').invoke rescue nil }.should run_tasks('foo:p1:test', 'foo:p2:test', 'foo:p3:test', 'bar:test')
770
+ end
771
+
772
+ it 'should ignore failure in subprojects if environment variable test is \'all\'' do
773
+ define('foo') {
774
+ define('p1') { test { fail } }
775
+ define('p2') { test { } }
776
+ define('p3') { test { fail } }
777
+ }
778
+ define('bar') { test { fail } }
779
+ ENV['test'] = 'all'
780
+ lambda { task('test').invoke rescue nil }.should run_tasks('foo:p1:test', 'foo:p2:test', 'foo:p3:test', 'bar:test')
781
+ end
782
+
783
+ it 'should ignore failure if options.test is :all and target is build task ' do
784
+ define('foo') { test { fail } }
785
+ define('bar') { test { fail } }
786
+ options.test = :all
787
+ lambda { task('build').invoke rescue nil }.should run_tasks('foo:test', 'bar:test')
788
+ end
789
+
790
+ it 'should ignore failure if environment variable test is \'all\'' do
791
+ define('foo') { test { fail } }
792
+ define('bar') { test { fail } }
793
+ ENV['test'] = 'all'
794
+ lambda { task('test').invoke rescue nil }.should run_tasks('foo:test', 'bar:test')
795
+ end
796
+
797
+ it 'should ignore failure if environment variable TEST is \'all\'' do
798
+ define('foo') { test { fail } }
799
+ define('bar') { test { fail } }
800
+ ENV['TEST'] = 'all'
801
+ lambda { task('test').invoke rescue nil }.should run_tasks('foo:test', 'bar:test')
802
+ end
803
+
804
+ it 'should execute no tests if options.test is false' do
805
+ define('foo') { test { fail } }
806
+ define('bar') { test { fail } }
807
+ options.test = false
808
+ lambda { task('test').invoke rescue nil }.should_not run_tasks('foo:test', 'bar:test')
809
+ end
810
+
811
+ it 'should execute no tests if environment variable test is \'no\'' do
812
+ define('foo') { test { fail } }
813
+ define('bar') { test { fail } }
814
+ ENV['test'] = 'no'
815
+ lambda { task('test').invoke rescue nil }.should_not run_tasks('foo:test', 'bar:test')
816
+ end
817
+
818
+ it 'should execute no tests if environment variable TEST is \'no\'' do
819
+ define('foo') { test { fail } }
820
+ define('bar') { test { fail } }
821
+ ENV['TEST'] = 'no'
822
+ lambda { task('test').invoke rescue nil }.should_not run_tasks('foo:test', 'bar:test')
823
+ end
824
+
825
+ it "should not compile tests if environment variable test is 'no'" do
826
+ write "src/test/java/HelloTest.java", "public class HelloTest { public void testTest() {}}"
827
+ define('foo') { test { fail } }
828
+ ENV['test'] = 'no'
829
+ lambda { task('test').invoke rescue nil }.should_not run_tasks('foo:test:compile')
830
+ end
831
+ end
832
+
833
+ describe 'test rule' do
834
+ include TestHelper
835
+
836
+ it 'should execute test task on local project' do
837
+ define('foo') { define 'bar' }
838
+ lambda { task('test:something').invoke }.should run_task('foo:test')
839
+ end
840
+
841
+ it 'should reset tasks to specific pattern' do
842
+ define 'foo' do
843
+ test.using(:testng)
844
+ test.instance_eval do
845
+ @framework.stub(:tests).and_return(%w[something nothing])
846
+ @framework.stub(:run).and_return(%w[something])
847
+ end
848
+ define 'bar' do
849
+ test.using(:testng)
850
+ test.instance_eval do
851
+ @framework.stub(:tests).and_return(%w[something nothing])
852
+ @framework.stub(:run).and_return(%w[something])
853
+ end
854
+ end
855
+ end
856
+ task('test:something').invoke
857
+ %w[foo foo:bar].map { |name| project(name) }.each do |project|
858
+ project.test.tests.should include('something')
859
+ project.test.tests.should_not include('nothing')
860
+ end
861
+ end
862
+
863
+ it 'should apply *name* pattern' do
864
+ define 'foo' do
865
+ test.using(:testng)
866
+ test.instance_eval do
867
+ @framework.stub(:tests).and_return(['prefix-something-suffix'])
868
+ @framework.stub(:run).and_return(['prefix-something-suffix'])
869
+ end
870
+ end
871
+ task('test:something').invoke
872
+ project('foo').test.tests.should include('prefix-something-suffix')
873
+ end
874
+
875
+ it 'should not apply *name* pattern if asterisks used' do
876
+ define 'foo' do
877
+ test.using(:testng)
878
+ test.instance_eval do
879
+ @framework.stub(:tests).and_return(%w[prefix-something prefix-something-suffix])
880
+ @framework.stub(:run).and_return(%w[prefix-something])
881
+ end
882
+ end
883
+ task('test:*something').invoke
884
+ project('foo').test.tests.should include('prefix-something')
885
+ project('foo').test.tests.should_not include('prefix-something-suffix')
886
+ end
887
+
888
+ it 'should accept multiple tasks separated by commas' do
889
+ define 'foo' do
890
+ test.using(:testng)
891
+ test.instance_eval do
892
+ @framework.stub(:tests).and_return(%w[foo bar baz])
893
+ @framework.stub(:run).and_return(%w[foo bar])
894
+ end
895
+ end
896
+ task('test:foo,bar').invoke
897
+ project('foo').test.tests.should include('foo')
898
+ project('foo').test.tests.should include('bar')
899
+ project('foo').test.tests.should_not include('baz')
900
+ end
901
+
902
+ it 'should execute only the named tests' do
903
+ write 'src/test/java/SomeTest.java',
904
+ 'public class SomeTest { @org.testng.annotations.Test public void testNothing() {} }'
905
+ write 'src/test/java/BadTest.java',
906
+ 'public class BadTest { @org.testng.annotations.Test public void testFailure() {} }'
907
+ define 'foo'
908
+ task('test:SomeTest').invoke
909
+ end
910
+
911
+ it 'should execute the named tests even if the test task is not needed' do
912
+ define 'foo' do
913
+ test.using(:testng)
914
+ test.instance_eval do
915
+ @framework.stub(:tests).and_return(%w[something nothing])
916
+ @framework.stub(:run).and_return(%w[something])
917
+ end
918
+ end
919
+ touch_last_successful_test_run project('foo').test
920
+ task('test:something').invoke
921
+ project('foo').test.tests.should include('something')
922
+ end
923
+
924
+ it 'should not execute excluded tests' do
925
+ define 'foo' do
926
+ test.using(:testng)
927
+ test.instance_eval do
928
+ @framework.stub(:tests).and_return(%w[something nothing])
929
+ @framework.stub(:run).and_return(%w[something])
930
+ end
931
+ end
932
+ task('test:*,-nothing').invoke
933
+ project('foo').test.tests.should include('something')
934
+ project('foo').test.tests.should_not include('nothing')
935
+ end
936
+
937
+ it 'should not execute tests in excluded package' do
938
+ write 'src/test/java/com/example/foo/SomeTest.java',
939
+ 'package com.example.foo; public class SomeTest { @org.testng.annotations.Test public void testNothing() {} }'
940
+ write 'src/test/java/com/example/bar/BadTest.java',
941
+ 'package com.example.bar; public class BadTest { @org.testng.annotations.Test public void testFailure() {} }'
942
+ define 'foo' do
943
+ test.using(:testng)
944
+ end
945
+ task('test:-com.example.bar').invoke
946
+ project('foo').test.tests.should include('com.example.foo.SomeTest')
947
+ project('foo').test.tests.should_not include('com.example.bar.BadTest')
948
+ end
949
+
950
+ it 'should not execute excluded tests with wildcards' do
951
+ define 'foo' do
952
+ test.using(:testng)
953
+ test.instance_eval do
954
+ @framework.stub(:tests).and_return(%w[something nothing])
955
+ @framework.stub(:tests).and_return(%w[])
956
+ end
957
+ end
958
+ task('test:something,-s*,-n*').invoke
959
+ project('foo').test.tests.should_not include('something')
960
+ project('foo').test.tests.should_not include('nothing')
961
+ end
962
+
963
+ it 'should execute all tests except excluded tests' do
964
+ define 'foo' do
965
+ test.using(:testng)
966
+ test.instance_eval do
967
+ @framework.stub(:tests).and_return(%w[something anything nothing])
968
+ @framework.stub(:run).and_return(%w[something anything])
969
+ end
970
+ end
971
+ task('test:-nothing').invoke
972
+ project('foo').test.tests.should include('something', 'anything')
973
+ project('foo').test.tests.should_not include('nothing')
974
+ end
975
+
976
+ it 'should ignore exclusions in buildfile' do
977
+ define 'foo' do
978
+ test.using(:testng)
979
+ test.exclude 'something'
980
+ test.instance_eval do
981
+ @framework.stub(:tests).and_return(%w[something anything nothing])
982
+ @framework.stub(:run).and_return(%w[something anything])
983
+ end
984
+ end
985
+ task('test:-nothing').invoke
986
+ project('foo').test.tests.should include('something', 'anything')
987
+ project('foo').test.tests.should_not include('nothing')
988
+ end
989
+
990
+ it 'should ignore inclusions in buildfile' do
991
+ define 'foo' do
992
+ test.using(:testng)
993
+ test.include 'something'
994
+ test.instance_eval do
995
+ @framework.stub(:tests).and_return(%w[something nothing])
996
+ @framework.stub(:run).and_return(%w[nothing])
997
+ end
998
+ end
999
+ task('test:nothing').invoke
1000
+ project('foo').test.tests.should include('nothing')
1001
+ project('foo').test.tests.should_not include('something')
1002
+ end
1003
+
1004
+ it 'should not execute a test if it''s both included and excluded' do
1005
+ define 'foo' do
1006
+ test.using(:testng)
1007
+ test.instance_eval do
1008
+ @framework.stub(:tests).and_return(['nothing'])
1009
+ end
1010
+ end
1011
+ task('test:nothing,-nothing').invoke
1012
+ project('foo').test.tests.should_not include('nothing')
1013
+ end
1014
+
1015
+ it 'should not update the last successful test run timestamp' do
1016
+ define 'foo' do
1017
+ test.using(:testng)
1018
+ test.instance_eval do
1019
+ @framework.stub(:tests).and_return(%w[something nothing])
1020
+ @framework.stub(:run).and_return(%w[something])
1021
+ end
1022
+ end
1023
+ a_second_ago = Time.now - 1
1024
+ touch_last_successful_test_run project('foo').test, a_second_ago
1025
+ task('test:something').invoke
1026
+ project('foo').test.timestamp.should <= a_second_ago
1027
+ end
1028
+ end
1029
+
1030
+ describe 'test failed' do
1031
+ include TestHelper
1032
+
1033
+ def test_task
1034
+ @test_task ||= begin
1035
+ define 'foo' do
1036
+ test.using(:testng)
1037
+ test.instance_eval do
1038
+ @framework.stub(:tests).and_return(%w[FailingTest PassingTest])
1039
+ @framework.stub(:run).and_return(['PassingTest'])
1040
+ end
1041
+ end
1042
+ project('foo').test
1043
+ end
1044
+ end
1045
+
1046
+ it 'should run the tests that failed the last time' do
1047
+ define 'foo' do
1048
+ test.using(:testng)
1049
+ test.instance_eval do
1050
+ @framework.stub(:tests).and_return(%w[FailingTest PassingTest])
1051
+ @framework.stub(:run).and_return(['PassingTest'])
1052
+ end
1053
+ end
1054
+ write project('foo').path_to(:target, "testng-failed"), "FailingTest"
1055
+ task('test:failed').invoke rescue nil
1056
+ project('foo').test.tests.should include('FailingTest')
1057
+ project('foo').test.tests.should_not include('PassingTest')
1058
+ end
1059
+
1060
+ it 'should run failed tests, respecting excluded tests' do
1061
+ define 'foo' do
1062
+ test.using(:testng).exclude('ExcludedTest')
1063
+ test.instance_eval do
1064
+ @framework.stub(:tests).and_return(%w[FailingTest PassingTest ExcludedTest])
1065
+ @framework.stub(:run).and_return(['PassingTest'])
1066
+ end
1067
+ end
1068
+ write project('foo').path_to(:target, "testng-failed"), "FailingTest\nExcludedTest"
1069
+ task('test:failed').invoke rescue nil
1070
+ project('foo').test.tests.should include('FailingTest')
1071
+ project('foo').test.tests.should_not include('ExcludedTest')
1072
+ end
1073
+
1074
+ it 'should run only the tests that failed the last time, even when failed tests have dependencies' do
1075
+ define 'parent' do
1076
+ define 'foo' do
1077
+ test.using(:testng)
1078
+ test.instance_eval do
1079
+ @framework.stub(:tests).and_return(['PassingTest'])
1080
+ @framework.stub(:run).and_return(['PassingTest'])
1081
+ end
1082
+ end
1083
+ define 'bar' do
1084
+ test.using(:testng)
1085
+ test.enhance ["parent:foo:test"]
1086
+ test.instance_eval do
1087
+ @framework.stub(:tests).and_return(%w[FailingTest PassingTest])
1088
+ @framework.stub(:run).and_return(['PassingTest'])
1089
+ end
1090
+ end
1091
+ end
1092
+ write project('parent:bar').path_to(:target, "testng-failed"), "FailingTest"
1093
+ task('test:failed').invoke rescue nil
1094
+ project('parent:foo').test.tests.should_not include('PassingTest')
1095
+ project('parent:bar').test.tests.should include('FailingTest')
1096
+ project('parent:bar').test.tests.should_not include('PassingTest')
1097
+ end
1098
+
1099
+ end
1100
+
1101
+
1102
+ describe Buildr::Options, 'test' do
1103
+ it 'should be true by default' do
1104
+ Buildr.options.test.should be_true
1105
+ end
1106
+
1107
+ %w[skip no off false].each do |value|
1108
+ it "should be false if test environment variable is '#{value}'" do
1109
+ lambda { ENV['test'] = value }.should change { Buildr.options.test }.to(false)
1110
+ end
1111
+ end
1112
+
1113
+ %w[skip no off false].each do |value|
1114
+ it "should be false if TEST environment variable is '#{value}'" do
1115
+ lambda { ENV['TEST'] = value }.should change { Buildr.options.test }.to(false)
1116
+ end
1117
+ end
1118
+
1119
+ it 'should be :all if test environment variable is all' do
1120
+ lambda { ENV['test'] = 'all' }.should change { Buildr.options.test }.to(:all)
1121
+ end
1122
+
1123
+ it 'should be :all if TEST environment variable is all' do
1124
+ lambda { ENV['TEST'] = 'all' }.should change { Buildr.options.test }.to(:all)
1125
+ end
1126
+
1127
+ it 'should be true and warn for any other value' do
1128
+ ENV['TEST'] = 'funky'
1129
+ lambda { Buildr.options.test.should be(true) }.should show_warning(/expecting the environment variable/i)
1130
+ end
1131
+ end