You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by to...@apache.org on 2016/08/15 06:10:40 UTC
[3/7] buildr git commit: remove Scala specs
remove Scala specs
Project: http://git-wip-us.apache.org/repos/asf/buildr/repo
Commit: http://git-wip-us.apache.org/repos/asf/buildr/commit/06d9c660
Tree: http://git-wip-us.apache.org/repos/asf/buildr/tree/06d9c660
Diff: http://git-wip-us.apache.org/repos/asf/buildr/diff/06d9c660
Branch: refs/heads/master
Commit: 06d9c6604f1d6488a7da58058262de9b1184b1ad
Parents: 02f5ede
Author: Antoine Toulme <an...@lunar-ocean.com>
Authored: Sun Aug 14 21:48:55 2016 -0700
Committer: Antoine Toulme <an...@lunar-ocean.com>
Committed: Sun Aug 14 21:48:55 2016 -0700
----------------------------------------------------------------------
doc/languages.textile | 2 +-
lib/buildr/scala/bdd.rb | 125 -------------------
lib/buildr/scala/doc.rb | 1 -
.../scala/org/apache/buildr/Specs2Runner.java | 7 +-
.../apache/buildr/SpecsSingletonRunner.class | Bin 1891 -> 1890 bytes
spec/scala/bdd_spec.rb | 101 ---------------
6 files changed, 5 insertions(+), 231 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/buildr/blob/06d9c660/doc/languages.textile
----------------------------------------------------------------------
diff --git a/doc/languages.textile b/doc/languages.textile
index 5e45546..ec1b985 100644
--- a/doc/languages.textile
+++ b/doc/languages.textile
@@ -351,7 +351,7 @@ h4. Specs
Specs is automatically selected whenever there are @.scala@ source files under the @src/spec/scala@ directory. It is also possible to force selection of the test framework by using the @test.using :specs@ directive. This can sometimes be useful when Scala sources may be found in *both* @src/test/scala@ and @src/spec/scala@. Normally in such cases, ScalaTest will have selection precedence, meaning that in case of a conflict between it and Specs, ScalaTest will be chosen.
-Any objects which extend the @org.specs.Specification@ superclass will be automatically detected and run. Note that any *classes* which extend @Specification@ will also be invoked. As such classes will not have a @main@ method, such an invocation will raise an error.
+Any objects which extend the @org.specs.Specification@ or @org.specs2.Specification@ superclass will be automatically detected and run. Note that any *classes* which extend @Specification@ will also be invoked. As such classes will not have a @main@ method, such an invocation will raise an error.
A simple specification might look like this:
http://git-wip-us.apache.org/repos/asf/buildr/blob/06d9c660/lib/buildr/scala/bdd.rb
----------------------------------------------------------------------
diff --git a/lib/buildr/scala/bdd.rb b/lib/buildr/scala/bdd.rb
index c2a6f52..e72d65f 100644
--- a/lib/buildr/scala/bdd.rb
+++ b/lib/buildr/scala/bdd.rb
@@ -15,125 +15,6 @@
module Buildr::Scala #:nodoc:
- # Specs is a Scala based BDD framework.
- # To use in your project:
- #
- # test.using :specs
- #
- # This framework will search in your project for:
- # src/spec/scala/**/*.scala
- class Specs < Buildr::TestFramework::JavaBDD
- @lang = :scala
- @bdd_dir = :spec
-
- VERSION = case
- when Buildr::Scala.version?("2.8.0")
- '1.6.5'
- when Buildr::Scala.version?("2.8.1"), Buildr::Scala.version?("2.8.2"), Buildr::Scala.version?("2.9.0")
- '1.6.8'
- else
- '1.6.9'
- end
-
- class << self
- def version
- custom = Buildr.settings.build['scala.specs']
- (custom =~ /:/) ? Buildr.artifact(custom).version : VERSION
- end
-
- def specs
- custom = Buildr.settings.build['scala.specs']
- [ (custom =~ /:/) ? custom : "org.scala-tools.testing:#{artifact}:jar:#{version}" ]
- end
-
- def artifact
- custom = Buildr.settings.build['scala.specs.artifact']
- return custom unless custom.nil?
-
- if Buildr::Scala.version >= "2.11"
- "specs_2.10"
- else
- "specs_#{Buildr::Scala.version_without_build}"
- end
- end
-
- def dependencies
- unless @dependencies
- super
- # Add utility classes (e.g. SpecsSingletonRunner) and other dependencies
- @dependencies |= [ File.join(File.dirname(__FILE__)) ] +
- specs +
- Check.dependencies + JUnit.dependencies + Scalac.dependencies + ["org.scala-lang.modules:scala-xml_2.11:jar:1.0.5"]
- end
- @dependencies
- end
-
- def applies_to?(project) #:nodoc:
- scala_files = Dir[project.path_to(:source, bdd_dir, lang, '**/*.scala')]
- return false if scala_files.empty?
- scala_files.detect { |f| find(f, /\s+(org\.specs\.)/) }
- end
-
- private
- def const_missing(const)
- return super unless const == :REQUIRES # TODO: remove in 1.5
- Buildr.application.deprecated "Please use Scala::Specs.dependencies/.version instead of ScalaSpecs::REQUIRES/VERSION"
- dependencies
- end
-
- def find(file, pattern)
- File.open(file, "r") do |infile|
- while (line = infile.gets)
- return true if line.match(pattern)
- end
- end
- false
- end
- end
-
- def initialize(task, options) #:nodoc:
- super
-
- specs = task.project.path_to(:source, :spec, :scala)
- task.compile.from specs if File.directory?(specs)
-
- resources = task.project.path_to(:source, :spec, :resources)
- task.resources.from resources if File.directory?(resources)
- end
-
- def tests(dependencies)
- candidates = filter_classes(dependencies, :interfaces => ['org.specs.Specification'])
-
- Java.load # Java is already loaded, but just in case
-
- filter = Java.org.apache.buildr.JavaTestFilter.new(dependencies.to_java(Java.java.lang.String))
- filter.add_fields ['MODULE$'].to_java(Java.java.lang.String)
- filter.filter(candidates.to_java(Java.java.lang.String)).map { |s| s[0..(s.size - 2)] }
- end
-
- def run(specs, dependencies) #:nodoc:
- cmd_options = { :properties => options[:properties],
- :java_args => options[:java_args],
- :classpath => dependencies,
- :name => false }
-
- runner = 'org.apache.buildr.SpecsSingletonRunner'
- specs.inject [] do |passed, spec|
- begin
- unless Util.win_os?
- Java::Commands.java(runner, task.compile.target.to_s, '-c', spec + '$', cmd_options)
- else
- Java::Commands.java(runner, task.compile.target.to_s, spec + '$', cmd_options)
- end
- rescue => e
- passed
- else
- passed << spec
- end
- end
- end
- end
-
class Specs2 < Buildr::TestFramework::JavaBDD
@lang = :scala
@bdd_dir = :spec
@@ -277,10 +158,4 @@ module Buildr::Scala #:nodoc:
end
end
-# Backwards compatibility stuff. Remove in 1.5.
-module Buildr #:nodoc:
- ScalaSpecs = Scala::Specs
-end
-
-Buildr::TestFramework << Buildr::Scala::Specs
Buildr::TestFramework << Buildr::Scala::Specs2
http://git-wip-us.apache.org/repos/asf/buildr/blob/06d9c660/lib/buildr/scala/doc.rb
----------------------------------------------------------------------
diff --git a/lib/buildr/scala/doc.rb b/lib/buildr/scala/doc.rb
index 9d9cf0c..d30a10f 100644
--- a/lib/buildr/scala/doc.rb
+++ b/lib/buildr/scala/doc.rb
@@ -80,7 +80,6 @@ module Buildr #:nodoc:
class VScaladoc < Base
VERSION = '1.2-m1'
- Buildr.repositories.remote << 'https://oss.sonatype.org/content/groups/scala-tools'
class << self
def dependencies
http://git-wip-us.apache.org/repos/asf/buildr/blob/06d9c660/lib/buildr/scala/org/apache/buildr/Specs2Runner.java
----------------------------------------------------------------------
diff --git a/lib/buildr/scala/org/apache/buildr/Specs2Runner.java b/lib/buildr/scala/org/apache/buildr/Specs2Runner.java
index f0e38cf..55c52b1 100644
--- a/lib/buildr/scala/org/apache/buildr/Specs2Runner.java
+++ b/lib/buildr/scala/org/apache/buildr/Specs2Runner.java
@@ -24,9 +24,10 @@ public class Specs2Runner {
public static void main(String[] args) {
try {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
- Class clazz = loader.loadClass("org.specs2.runner.ClassRunner");
- Object instance = clazz.newInstance();
- Method main = clazz.getMethod("main", String[].class);
+ Class clazz = loader.loadClass("org.specs2.runner.ClassRunner$");
+ Field singleton = clazz.getField("MODULE$");
+ Object instance = singleton.get(null);
+ Method main = clazz.getMethod("run", String[].class);
main.invoke(instance, new Object[] { args });
} catch (Exception e) {
throw new RuntimeException(e);
http://git-wip-us.apache.org/repos/asf/buildr/blob/06d9c660/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class
----------------------------------------------------------------------
diff --git a/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class b/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class
index 7a27b57..4318e43 100644
Binary files a/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class and b/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class differ
http://git-wip-us.apache.org/repos/asf/buildr/blob/06d9c660/spec/scala/bdd_spec.rb
----------------------------------------------------------------------
diff --git a/spec/scala/bdd_spec.rb b/spec/scala/bdd_spec.rb
index fb946da..25167ab 100644
--- a/spec/scala/bdd_spec.rb
+++ b/spec/scala/bdd_spec.rb
@@ -15,104 +15,6 @@
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
-if Java.java.lang.System.getProperty("java.runtime.version") >= "1.6"
-
-describe Buildr::Scala::Specs do
-
- it 'should be the default when tests in src/spec/scala reference "org.specs"' do
- write 'src/spec/scala/com/example/MySpecs.scala', <<-SCALA
- package com.example
- object MySpecs extends org.specs.Specification {
- "it" should {
- "add" in {
- val sum = 1 + 1
- sum mustEqual 2
- }
- }
- }
- SCALA
- define 'foo'
- project('foo').test.framework.should eql(:specs)
- end
-
- it 'should include Specs dependencies' do
- define('foo') { test.using(:specs) }
- project('foo').test.compile.dependencies.should include(*artifacts(Scala::Specs.dependencies))
- project('foo').test.dependencies.should include(*artifacts(Scala::Specs.dependencies))
- end
-
- it 'should include ScalaCheck dependencies' do
- define('foo') { test.using(:specs) }
- project('foo').test.compile.dependencies.should include(*artifacts(Scala::Check.dependencies))
- project('foo').test.dependencies.should include(*artifacts(Scala::Check.dependencies))
- end
-
- it 'should include public objects extending org.specs.Specification' do
- write 'src/spec/scala/com/example/MySpecs.scala', <<-SCALA
- package com.example
- object MySpecs extends org.specs.Specification {
- "it" should {
- "add" in {
- val sum = 1 + 1
- sum mustEqual 2
- }
- }
- }
- SCALA
- define('foo').test.invoke
- project('foo').test.tests.should include('com.example.MySpecs')
- end
-
- it 'should include public objects extending org.specs.Specification even with companion classes' do
- write 'src/spec/scala/com/example/MySpecs.scala', <<-SCALA
- package com.example
- object MySpecs extends org.specs.Specification {
- "it" should {
- "add" in {
- val sum = 1 + 1
- sum mustEqual 2
- }
- }
- }
- class MySpecs extends org.specs.runner.JUnit4(MySpecs)
- SCALA
- define('foo').test.invoke
- project('foo').test.tests.should include('com.example.MySpecs')
- end
-
- it 'should pass when spec passes' do
- write 'src/spec/scala/PassingSpecs.scala', <<-SCALA
- object PassingSpecs extends org.specs.Specification {
- "it" should {
- "add" in {
- val sum = 1 + 1
- sum mustEqual 2
- }
- }
- }
- SCALA
- lambda { define('foo').test.invoke }.should_not raise_error
- end
-
- it 'should fail when spec fails' do
- write 'src/spec/scala/StringSpecs.scala', <<-SCALA
- import org.specs._
- import org.specs.runner._
-
- object StringSpecs extends Specification {
- "empty string" should {
- "have a zero length" in {
- ("".length) mustEqual(1)
- }
- }
- }
- SCALA
- define('foo')
- project('foo').test.invoke rescue
- project('foo').test.failed_tests.should include('StringSpecs')
- end
-end
-
describe Buildr::Scala::Specs2 do
it 'should be the default when tests in src/spec/scala reference "org.specs2"' do
@@ -217,6 +119,3 @@ describe Buildr::Scala::Specs2 do
end
end
-elsif Buildr::VERSION >= '1.5'
- raise "JVM version guard in #{__FILE__} should be removed since it is assumed that Java 1.5 is no longer supported."
-end