You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by la...@apache.org on 2010/02/28 23:13:22 UTC
svn commit: r917307 - in /buildr/trunk: CHANGELOG lib/buildr/core/test.rb
spec/core/test_spec.rb
Author: lacton
Date: Sun Feb 28 22:13:22 2010
New Revision: 917307
URL: http://svn.apache.org/viewvc?rev=917307&view=rev
Log:
BUILDR-267 Skipping tests is only done after they are compiled (Antoine Toulme)
Modified:
buildr/trunk/CHANGELOG
buildr/trunk/lib/buildr/core/test.rb
buildr/trunk/spec/core/test_spec.rb
Modified: buildr/trunk/CHANGELOG
URL: http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=917307&r1=917306&r2=917307&view=diff
==============================================================================
--- buildr/trunk/CHANGELOG (original)
+++ buildr/trunk/CHANGELOG Sun Feb 28 22:13:22 2010
@@ -31,7 +31,9 @@
* Fixed: BUILDR-183 Can't define root artifact namespace outside of project
(Ittay Dror)
* Fixed: BUILDR-223 Release Task: customizable commit message (Alexis Midon)
-* Fixed: BUILDR-233 Can't specify version in artifact namespace
+* Fixed: BUILDR-233 Can't specify version in artifact namespace
+* Fixed: BUILDR-267 Skipping tests is only done after they are compiled
+ (Antoine Toulme)
* Fixed: BUILDR-281 Application#initialize fails if home dir isn't writable
* Fixed: BUILDR-327 Specifying :plugin eclipse nature explicitly fails
* Fixed: BUILDR-330 Install task should re-install artifact even if they
Modified: buildr/trunk/lib/buildr/core/test.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/core/test.rb?rev=917307&r1=917306&r2=917307&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/core/test.rb (original)
+++ buildr/trunk/lib/buildr/core/test.rb Sun Feb 28 22:13:22 2010
@@ -624,8 +624,26 @@
resources.send :associate_with, project, :test
project.path_to(:source, :test, :resources).tap { |dir| resources.from dir if File.exist?(dir) }
+ # We define a module inline that will inject cancelling the task if tests are skipped.
+ module SkipIfNoTest
+
+ def self.extended(base)
+ base.instance_eval {alias :execute_before_skip_if_no_test :execute}
+ base.instance_eval {alias :execute :execute_after_skip_if_no_test}
+ end
+
+ def execute_after_skip_if_no_test(args) #:nodoc:
+ if Buildr.options.test == false
+ trace "Skipping #{to_s} for #{project.name} as tests are skipped"
+ return
+ end
+ execute_before_skip_if_no_test(args)
+ end
+ end
+
# Similar to the regular compile task but using different paths.
compile = CompileTask.define_task('test:compile'=>[project.compile, resources])
+ compile.extend SkipIfNoTest
compile.send :associate_with, project, :test
test.enhance [compile]
Modified: buildr/trunk/spec/core/test_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/core/test_spec.rb?rev=917307&r1=917306&r2=917307&view=diff
==============================================================================
--- buildr/trunk/spec/core/test_spec.rb (original)
+++ buildr/trunk/spec/core/test_spec.rb Sun Feb 28 22:13:22 2010
@@ -797,6 +797,13 @@
ENV['TEST'] = 'no'
lambda { task('test').invoke rescue nil }.should_not run_tasks('foo:test', 'bar:test')
end
+
+ it "should not compile tests if environment variable test is 'no'" do
+ write "src/test/java/HelloTest.java", "public class HelloTest { public void testTest() {}}"
+ define('foo') { test { fail } }
+ ENV['test'] = 'no'
+ lambda { task('test').invoke rescue nil }.should_not run_tasks('foo:test:compile')
+ end
end
describe 'test rule' do