lib/java/test.rb in buildr-0.22.0 vs lib/java/test.rb in buildr-1.0.0
- old
+ new
@@ -320,12 +320,30 @@
Project.projects.select { |project| project.base_dir == Rake.application.original_dir }.
map { |project| project.test }.each { |task| task.junit.instance_eval { @include = ["*#{test}"] ; @exclude.clear } }.
each(&:invoke)
end
- # Require tests after build unless TEST option is off.
- # For example:
- # rake build
- # rake build TEST=off
- task("build") { task("test").invoke } unless ENV["TEST"] =~ /(off|false|no)/
+
+ class Options
+
+ # Runs test cases after the build when true (default). This forces test cases to execute
+ # after the build, including when running build related tasks like install, deploy and release.
+ #
+ # You can skip test cases by turning this option off directly, or by setting the environment
+ # variable TEST to "no". For example:
+ # rake build # With tests
+ # rake build TEST=no # Without tests
+ attr_accessor :test
+
+ end
+
+ options.test = (ENV["TEST"] || ENV["test"]) !~ /(no|off|false)/
+
+ task("build") do |task|
+ # Make sure this happens as the last action on the build, so all other enhancements
+ # are made to run before starting the test cases.
+ task.enhance do
+ task("test").invoke if Buildr.options.test
+ end
+ end
end