buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From as...@apache.org
Subject svn commit: r697909 - in /incubator/buildr/trunk: lib/buildr/groovy.rb lib/buildr/groovy/bdd.rb lib/buildr/groovy/compiler.rb lib/buildr/java.rb lib/buildr/java/bdd.rb lib/buildr/java/bdd_frameworks.rb spec/groovy/bdd_spec.rb spec/java/bdd_spec.rb
Date Mon, 22 Sep 2008 17:28:23 GMT
Author: assaf
Date: Mon Sep 22 10:28:23 2008
New Revision: 697909

URL: http://svn.apache.org/viewvc?rev=697909&view=rev
Log:
Some fixes along the lines of the previous commit for Groovy and BDD specs.

Added:
    incubator/buildr/trunk/lib/buildr/groovy/bdd.rb
    incubator/buildr/trunk/lib/buildr/java/bdd.rb
      - copied, changed from r697908, incubator/buildr/trunk/lib/buildr/java/bdd_frameworks.rb
    incubator/buildr/trunk/spec/groovy/bdd_spec.rb
Removed:
    incubator/buildr/trunk/lib/buildr/java/bdd_frameworks.rb
Modified:
    incubator/buildr/trunk/lib/buildr/groovy.rb
    incubator/buildr/trunk/lib/buildr/groovy/compiler.rb
    incubator/buildr/trunk/lib/buildr/java.rb
    incubator/buildr/trunk/spec/java/bdd_spec.rb

Modified: incubator/buildr/trunk/lib/buildr/groovy.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/groovy.rb?rev=697909&r1=697908&r2=697909&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/groovy.rb (original)
+++ incubator/buildr/trunk/lib/buildr/groovy.rb Mon Sep 22 10:28:23 2008
@@ -14,4 +14,5 @@
 # the License.
 
 
-require 'buildr/groovy/compiler'
\ No newline at end of file
+require 'buildr/groovy/compiler'
+require 'buildr/groovy/bdd'
\ No newline at end of file

Added: incubator/buildr/trunk/lib/buildr/groovy/bdd.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/groovy/bdd.rb?rev=697909&view=auto
==============================================================================
--- incubator/buildr/trunk/lib/buildr/groovy/bdd.rb (added)
+++ incubator/buildr/trunk/lib/buildr/groovy/bdd.rb Mon Sep 22 10:28:23 2008
@@ -0,0 +1,90 @@
+module Buildr::Groovy
+
+  # EasyB is a Groovy based BDD framework.
+  # To use in your project:
+  #
+  #   test.using :easyb
+  # 
+  # This framework will search in your project for:
+  #   src/spec/groovy/**/*Story.groovy
+  #   src/spec/groovy/**/*Behavior.groovy
+  #
+  # Support the following options:
+  # * :format -- Report format :txt or :xml, default is :txt
+  # * :properties -- Hash of properties passed to the test suite.
+  # * :java_args -- Arguments passed to the JVM.
+  class EasyB < TestFramework::JavaBDD
+    @lang = :groovy
+    @bdd_dir = :spec
+
+    VERSION = "0.7" unless const_defined?(:VERSION)
+    TESTS_PATTERN = [ /(Story|Behavior).groovy$/ ]
+    OPTIONS = [:format, :properties, :java_args]
+
+    class << self
+      def version
+        Buildr.settings.build['jbehave'] || VERSION
+      end
+
+      def dependencies
+        @dependencies ||= ["org.easyb:easyb:jar:#{version}",
+          'org.codehaus.groovy:groovy:jar:1.5.3','asm:asm:jar:2.2.3',
+          'commons-cli:commons-cli:jar:1.0','antlr:antlr:jar:2.7.7']
+      end
+
+      def applies_to?(project) #:nodoc:
+        %w{
+          **/*Behaviour.groovy **/*Behavior.groovy **/*Story.groovy
+        }.any? { |glob| !Dir[project.path_to(:source, bdd_dir, lang, glob)].empty? }
+      end
+
+    private
+      def const_missing(const)
+        return super unless const == :REQUIRES # TODO: remove in 1.5
+        Buildr.application.deprecated "Please use JBehave.dependencies/.version instead of
JBehave::REQUIRES/VERSION"
+        dependencies
+      end
+    end
+
+    def tests(dependencies) #:nodoc:
+      Dir[task.project.path_to(:source, bdd_dir, lang, "**/*.groovy")].
+        select { |name| TESTS_PATTERN.any? { |pat| pat === name } }
+    end
+
+    def run(tests, dependencies) #:nodoc:
+      options = { :format => :txt }.merge(self.options).only(*OPTIONS)
+    
+      if :txt == options[:format]
+        easyb_format, ext = 'txtstory', '.txt'
+      elsif :xml == options[:format]
+        easyb_format, ext = 'xmlbehavior', '.xml'
+      else
+        raise "Invalid format #{options[:format]} expected one of :txt :xml"
+      end
+    
+      cmd_args = [ 'org.disco.easyb.SpecificationRunner' ]
+      cmd_options = { :properties => options[:properties],
+                      :java_args => options[:java_args],
+                      :classpath => dependencies }
+
+      tests.inject([]) do |passed, test|
+        name = test.sub(/.*?groovy[\/\\]/, '').pathmap('%X')
+        report = File.join(task.report_to.to_s, name + ext)
+        mkpath report.pathmap('%d'), :verbose => false
+        begin
+          Java::Commands.java cmd_args,
+             "-#{easyb_format}", report,
+             test, cmd_options.merge(:name => name)
+        rescue => e
+          passed
+        else
+          passed << test
+        end
+      end
+    end
+  
+  end # EasyB
+  
+end
+
+Buildr::TestFramework << Buildr::Groovy::EasyB
\ No newline at end of file

Modified: incubator/buildr/trunk/lib/buildr/groovy/compiler.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/groovy/compiler.rb?rev=697909&r1=697908&r2=697909&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/groovy/compiler.rb (original)
+++ incubator/buildr/trunk/lib/buildr/groovy/compiler.rb Mon Sep 22 10:28:23 2008
@@ -14,7 +14,7 @@
 # the License.
 
 
-module Buildr::Compiler
+module Buildr::Groovy
 
   # Groovyc compiler:
   #  compile.using(:groovyc)
@@ -48,7 +48,7 @@
   # * :target            -- Bytecode compatibility.
   # * :javac             -- Hash of options passed to the ant javac task
   #
-  class Groovyc < Base
+  class Groovyc < Compiler::Base
     
     # The groovyc compiler jars are added to classpath at load time,
     # if you want to customize artifact versions, you must set them on the
@@ -135,4 +135,4 @@
 
 # Groovy compiler comes first, ahead of Javac, this allows it to pick
 # projects that mix Groovy and Java code by spotting Groovy code first.
-Buildr::Compiler.compilers.unshift Buildr::Compiler::Groovyc
+Buildr::Compiler.compilers.unshift Buildr::Groovy::Groovyc

Modified: incubator/buildr/trunk/lib/buildr/java.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/java.rb?rev=697909&r1=697908&r2=697909&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/java.rb (original)
+++ incubator/buildr/trunk/lib/buildr/java.rb Mon Sep 22 10:28:23 2008
@@ -17,7 +17,7 @@
 require RUBY_PLATFORM == 'java' ? 'buildr/java/jruby' : 'buildr/java/rjb'
 require 'buildr/java/compiler'
 require 'buildr/java/tests'
-require 'buildr/java/bdd_frameworks'
+require 'buildr/java/bdd'
 require 'buildr/java/packaging'
 require 'buildr/java/commands'
 require 'buildr/java/deprecated'

Copied: incubator/buildr/trunk/lib/buildr/java/bdd.rb (from r697908, incubator/buildr/trunk/lib/buildr/java/bdd_frameworks.rb)
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/buildr/java/bdd.rb?p2=incubator/buildr/trunk/lib/buildr/java/bdd.rb&p1=incubator/buildr/trunk/lib/buildr/java/bdd_frameworks.rb&r1=697908&r2=697909&rev=697909&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/buildr/java/bdd_frameworks.rb (original)
+++ incubator/buildr/trunk/lib/buildr/java/bdd.rb Mon Sep 22 10:28:23 2008
@@ -25,8 +25,6 @@
     class << self
       attr_reader :lang, :bdd_dir
     end
-    @bdd_dir = :spec
-    @lang = :java
     attr_accessor :lang, :bdd_dir
 
     def initialize(task, options)
@@ -48,6 +46,7 @@
   
   class RSpec < TestFramework::JavaBDD
     @lang = :ruby
+    @bdd_dir = :spec    
   
     TESTS_PATTERN = [ /_spec.rb$/ ]
     OPTIONS = [:properties, :java_args]
@@ -101,6 +100,7 @@
 
   class JtestR < TestFramework::JavaBDD
     @lang = :ruby
+    @bdd_dir = :spec    
   end
 
   
@@ -116,6 +116,8 @@
   # * :properties -- Hash of properties to the test suite
   # * :java_args -- Arguments passed to the JVM
   class JBehave < TestFramework::JavaBDD
+    @lang = :java
+    @bdd_dir = :spec
 
     VERSION = "1.0.1" unless const_defined?('VERSION')
     TESTS_PATTERN = [ /Behaviou?r$/ ] #:nodoc:
@@ -164,94 +166,8 @@
     
   end
 
-
-  # EasyB is a Groovy based BDD framework.
-  # To use in your project:
-  #
-  #   test.using :easyb
-  # 
-  # This framework will search in your project for:
-  #   src/spec/groovy/**/*Story.groovy
-  #   src/spec/groovy/**/*Behavior.groovy
-  #
-  # Support the following options:
-  # * :format -- Report format :txt or :xml, default is :txt
-  # * :properties -- Hash of properties passed to the test suite.
-  # * :java_args -- Arguments passed to the JVM.
-  class EasyB < TestFramework::JavaBDD
-    @lang = :groovy
-
-    VERSION = "0.7" unless const_defined?(:VERSION)
-    TESTS_PATTERN = [ /(Story|Behavior).groovy$/ ]
-    OPTIONS = [:format, :properties, :java_args]
-
-    class << self
-      def version
-        Buildr.settings.build['jbehave'] || VERSION
-      end
-
-      def dependencies
-        @dependencies ||= ["org.easyb:easyb:jar:#{version}",
-          'org.codehaus.groovy:groovy:jar:1.5.3','asm:asm:jar:2.2.3',
-          'commons-cli:commons-cli:jar:1.0','antlr:antlr:jar:2.7.7']
-      end
-
-      def applies_to?(project) #:nodoc:
-        %w{
-          **/*Behaviour.groovy **/*Behavior.groovy **/*Story.groovy
-        }.any? { |glob| !Dir[project.path_to(:source, bdd_dir, lang, glob)].empty? }
-      end
-
-    private
-      def const_missing(const)
-        return super unless const == :REQUIRES # TODO: remove in 1.5
-        Buildr.application.deprecated "Please use JBehave.dependencies/.version instead of
JBehave::REQUIRES/VERSION"
-        dependencies
-      end
-    end
-
-    def tests(dependencies) #:nodoc:
-      Dir[task.project.path_to(:source, bdd_dir, lang, "**/*.groovy")].
-        select { |name| TESTS_PATTERN.any? { |pat| pat === name } }
-    end
-
-    def run(tests, dependencies) #:nodoc:
-      options = { :format => :txt }.merge(self.options).only(*OPTIONS)
-      
-      if :txt == options[:format]
-        easyb_format, ext = 'txtstory', '.txt'
-      elsif :xml == options[:format]
-        easyb_format, ext = 'xmlbehavior', '.xml'
-      else
-        raise "Invalid format #{options[:format]} expected one of :txt :xml"
-      end
-      
-      cmd_args = [ 'org.disco.easyb.SpecificationRunner' ]
-      cmd_options = { :properties => options[:properties],
-                      :java_args => options[:java_args],
-                      :classpath => dependencies }
-
-      tests.inject([]) do |passed, test|
-        name = test.sub(/.*?groovy[\/\\]/, '').pathmap('%X')
-        report = File.join(task.report_to.to_s, name + ext)
-        mkpath report.pathmap('%d'), :verbose => false
-        begin
-          Java::Commands.java cmd_args,
-             "-#{easyb_format}", report,
-             test, cmd_options.merge(:name => name)
-        rescue => e
-          passed
-        else
-          passed << test
-        end
-      end
-    end
-    
-  end # EasyB
-
 end
 
 Buildr::TestFramework << Buildr::RSpec
 Buildr::TestFramework << Buildr::JtestR
 Buildr::TestFramework << Buildr::JBehave
-Buildr::TestFramework << Buildr::EasyB
\ No newline at end of file

Added: incubator/buildr/trunk/spec/groovy/bdd_spec.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/groovy/bdd_spec.rb?rev=697909&view=auto
==============================================================================
--- incubator/buildr/trunk/spec/groovy/bdd_spec.rb (added)
+++ incubator/buildr/trunk/spec/groovy/bdd_spec.rb Mon Sep 22 10:28:23 2008
@@ -0,0 +1,80 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with this
+# work for additional information regarding copyright ownership.  The ASF
+# licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+require File.join(File.dirname(__FILE__), '../spec_helpers')
+
+
+describe Buildr::Groovy::EasyB do
+  
+  def foo(*args, &prc)
+    define('foo', *args) do
+      test.using :easyb
+      if prc
+        instance_eval(&prc)
+      else
+        self
+      end
+    end
+  end
+
+  it 'should apply to a project having EasyB sources' do
+    define('one', :base_dir => 'one') do
+      write _('src/spec/groovy/SomeBehaviour.groovy'), 'true;'
+      Buildr::Groovy::EasyB.applies_to?(self).should be_true
+    end
+    define('two', :base_dir => 'two') do
+      write _('src/test/groovy/SomeBehaviour.groovy'), 'true;'
+      Buildr::Groovy::EasyB.applies_to?(self).should be_false
+    end
+    define('three', :base_dir => 'three') do
+      write _('src/spec/groovy/SomeStory.groovy'), 'true;'
+      Buildr::Groovy::EasyB.applies_to?(self).should be_true
+    end
+    define('four', :base_dir => 'four') do
+      write _('src/test/groovy/SomeStory.groovy'), 'true;'
+      Buildr::Groovy::EasyB.applies_to?(self).should be_false
+    end
+  end
+
+  it 'should be selected by :easyb name' do
+    foo { test.framework.should eql(:easyb) }
+  end
+
+  it 'should select a java compiler if java sources are found' do
+    foo do
+      write _('src/spec/java/SomeBehavior.java'), 'public class SomeBehavior {}'
+      test.compile.language.should eql(:java)
+    end
+  end
+  
+  it 'should include src/spec/groovy/*Behavior.groovy' do
+    foo do 
+      spec = _('src/spec/groovy/SomeBehavior.groovy')
+      write spec, 'true'
+      test.invoke
+      test.tests.should include(spec)
+    end
+  end
+
+  it 'should include src/spec/groovy/*Story.groovy' do
+    foo do 
+      spec = _('src/spec/groovy/SomeStory.groovy')
+      write spec, 'true'
+      test.invoke
+      test.tests.should include(spec)
+    end
+  end
+  
+end # EasyB
\ No newline at end of file

Modified: incubator/buildr/trunk/spec/java/bdd_spec.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/java/bdd_spec.rb?rev=697909&r1=697908&r2=697909&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/java/bdd_spec.rb (original)
+++ incubator/buildr/trunk/spec/java/bdd_spec.rb Mon Sep 22 10:28:23 2008
@@ -35,7 +35,7 @@
   it 'should include src/spec/ruby/**/*_spec.rb' do
     verbose true
     foo do 
-      spec = _(:source, :spec, :ruby, 'some_spec.rb')
+      spec = _('src/spec/ruby/some_spec.rb')
       write spec, ''
       test.invoke
       test.tests.should include(spec)
@@ -84,19 +84,19 @@
 
   it 'should apply to projects having JBehave sources' do
     define('one', :base_dir => 'one') do
-      write _(:source, :spec, :java, 'SomeBehaviour.java'), 'public class SomeBehaviour {}'
+      write _('src/spec/java/SomeBehaviour.java'), 'public class SomeBehaviour {}'
       JBehave.applies_to?(self).should be_true
     end
     define('two', :base_dir => 'two') do
-      write _(:source, :test, :java, 'SomeBehaviour.java'), 'public class SomeBehaviour {}'
+      write _('src/test/java/SomeBehaviour.java'), 'public class SomeBehaviour {}'
       JBehave.applies_to?(self).should be_false
     end
     define('three', :base_dir => 'three') do
-      write _(:source, :spec, :java, 'SomeBehavior.java'), 'public class SomeBehavior {}'
+      write _('src/spec/java/SomeBehavior.java'), 'public class SomeBehavior {}'
       JBehave.applies_to?(self).should be_true
     end
     define('four', :base_dir => 'four') do
-      write _(:source, :test, :java, 'SomeBehavior.java'), 'public class SomeBehavior {}'
+      write _('src/test/java/SomeBehavior.java'), 'public class SomeBehavior {}'
       JBehave.applies_to?(self).should be_false
     end
   end
@@ -106,8 +106,8 @@
   end
 
   it 'should select a java compiler for its sources' do 
+    write 'src/test/java/SomeBehavior.java', 'public class SomeBehavior {}'
     foo do
-      write _(:source, :spec, :java, 'SomeBehavior.java'), 'public class SomeBehavior {}'
       test.compile.language.should eql(:java)
     end
   end
@@ -171,68 +171,3 @@
   end
 
 end # JBehave
-
-describe Buildr::EasyB do
-  
-  def foo(*args, &prc)
-    define('foo', *args) do
-      test.using :easyb
-      if prc
-        instance_eval(&prc)
-      else
-        self
-      end
-    end
-  end
-
-  it 'should apply to a project having EasyB sources' do
-    define('one', :base_dir => 'one') do
-      write _(:source, :spec, :groovy, 'SomeBehaviour.groovy'), 'true;'
-      EasyB.applies_to?(self).should be_true
-    end
-    define('two', :base_dir => 'two') do
-      write _(:source, :test, :groovy, 'SomeBehaviour.groovy'), 'true;'
-      EasyB.applies_to?(self).should be_false
-    end
-    define('three', :base_dir => 'three') do
-      write _(:source, :spec, :groovy, 'SomeStory.groovy'), 'true;'
-      EasyB.applies_to?(self).should be_true
-    end
-    define('four', :base_dir => 'four') do
-      write _(:source, :test, :groovy, 'SomeStory.groovy'), 'true;'
-      EasyB.applies_to?(self).should be_false
-    end
-  end
-
-  it 'should be selected by :easyb name' do
-    foo { test.framework.should eql(:easyb) }
-  end
-
-  it 'should select a java compiler if java sources are found' do
-    foo do
-      write _(:source, :spec, :java, 'SomeBehavior.java'), 'public class SomeBehavior {}'
-      test.compile.language.should eql(:java)
-    end
-  end
-  
-  it 'should include src/spec/groovy/*Behavior.groovy' do
-    foo do 
-      spec = _(:source, :spec, :groovy, 'SomeBehavior.groovy')
-      write spec, 'true'
-      test.invoke
-      test.tests.should include(spec)
-    end
-  end
-
-  it 'should include src/spec/groovy/*Story.groovy' do
-    foo do 
-      spec = _(:source, :spec, :groovy, 'SomeStory.groovy')
-      write spec, 'true'
-      test.invoke
-      test.tests.should include(spec)
-    end
-  end
-  
-end # EasyB
-
-



Mime
View raw message