You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildr.apache.org by as...@apache.org on 2008/01/08 01:49:06 UTC

svn commit: r609822 - in /incubator/buildr/trunk: ./ bin/ lib/ lib/core/ lib/ide/ lib/java/ spec/

Author: assaf
Date: Mon Jan  7 16:49:04 2008
New Revision: 609822

URL: http://svn.apache.org/viewvc?rev=609822&view=rev
Log:
Mosty reorganizing stuff

Added:
    incubator/buildr/trunk/spec/java_compilers.rb
    incubator/buildr/trunk/spec/java_test_frameworks.rb
Modified:
    incubator/buildr/trunk/Rakefile
    incubator/buildr/trunk/bin/buildr
    incubator/buildr/trunk/lib/core.rb
    incubator/buildr/trunk/lib/core/build.rb
    incubator/buildr/trunk/lib/core/checks.rb
    incubator/buildr/trunk/lib/core/compile.rb
    incubator/buildr/trunk/lib/core/project.rb
    incubator/buildr/trunk/lib/core/test.rb
    incubator/buildr/trunk/lib/ide.rb
    incubator/buildr/trunk/lib/ide/eclipse.rb
    incubator/buildr/trunk/lib/ide/idea.rb
    incubator/buildr/trunk/lib/java.rb
    incubator/buildr/trunk/lib/java/java.rb
    incubator/buildr/trunk/lib/java/test_frameworks.rb
    incubator/buildr/trunk/spec/compile_spec.rb
    incubator/buildr/trunk/spec/spec_helpers.rb
    incubator/buildr/trunk/spec/test_spec.rb

Modified: incubator/buildr/trunk/Rakefile
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/Rakefile?rev=609822&r1=609821&r2=609822&view=diff
==============================================================================
--- incubator/buildr/trunk/Rakefile (original)
+++ incubator/buildr/trunk/Rakefile Mon Jan  7 16:49:04 2008
@@ -15,7 +15,7 @@
     spec.homepage     = "http://incubator.apache.org/#{spec.name}/"
     spec.summary      = 'A build system that doesn\'t suck'
     spec.files        = FileList['lib/**/*', 'README', 'CHANGELOG', 'LICENSE', 'NOTICE', 'DISCLAIMER',
-                                 'Rakefile', 'spec/**/*', 'doc/**/*'].collect
+                                 'Rakefile', 'spec/**/*', 'doc/**/*'].to_ary
     spec.require_path = 'lib'
     spec.has_rdoc     = true
     spec.extra_rdoc_files = ['README', 'CHANGELOG', 'LICENSE', 'NOTICE', 'DISCLAIMER']

Modified: incubator/buildr/trunk/bin/buildr
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/bin/buildr?rev=609822&r1=609821&r2=609822&view=diff
==============================================================================
--- incubator/buildr/trunk/bin/buildr (original)
+++ incubator/buildr/trunk/bin/buildr Mon Jan  7 16:49:04 2008
@@ -1,3 +1,6 @@
+#!/usr/bin/env ruby
+
+require 'rubygems'
 begin
   require 'buildr'
 rescue LoadError

Modified: incubator/buildr/trunk/lib/core.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/core.rb?rev=609822&r1=609821&r2=609822&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/core.rb (original)
+++ incubator/buildr/trunk/lib/core.rb Mon Jan  7 16:49:04 2008
@@ -8,14 +8,3 @@
 require 'core/test'
 require 'core/checks'
 require 'core/generate'
-
-class Buildr::Project
-  # Project has visibility to everything in the Buildr namespace. what follows are specific extensions.
-  # Put first, so other extensions can over-ride Buildr methods.
-  include Buildr
-  include Buildr::Build
-  include Buildr::Compile
-  include Buildr::Test
-  include Buildr::Package
-  include Buildr::Checks
-end

Modified: incubator/buildr/trunk/lib/core/build.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/core/build.rb?rev=609822&r1=609821&r2=609822&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/core/build.rb (original)
+++ incubator/buildr/trunk/lib/core/build.rb Mon Jan  7 16:49:04 2008
@@ -238,3 +238,8 @@
   end
 
 end
+
+
+class Buildr::Project
+  include Buildr::Build
+end

Modified: incubator/buildr/trunk/lib/core/checks.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/core/checks.rb?rev=609822&r1=609821&r2=609822&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/core/checks.rb (original)
+++ incubator/buildr/trunk/lib/core/checks.rb Mon Jan  7 16:49:04 2008
@@ -358,3 +358,8 @@
   end
 
 end
+
+
+class Buildr::Project
+  include Buildr::Checks
+end

Modified: incubator/buildr/trunk/lib/core/compile.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/core/compile.rb?rev=609822&r1=609821&r2=609822&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/core/compile.rb (original)
+++ incubator/buildr/trunk/lib/core/compile.rb Mon Jan  7 16:49:04 2008
@@ -530,3 +530,8 @@
   end
 
 end
+
+
+class Buildr::Project
+  include Buildr::Compile
+end

Modified: incubator/buildr/trunk/lib/core/project.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/core/project.rb?rev=609822&r1=609821&r2=609822&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/core/project.rb (original)
+++ incubator/buildr/trunk/lib/core/project.rb Mon Jan  7 16:49:04 2008
@@ -383,6 +383,9 @@
     end
 
 
+    # Project has visibility to everything in the Buildr namespace.
+    include Buildr
+
     # The project name. For example, 'foo' for the top-level project, and 'foo:bar'
     # for its sub-project.
     attr_reader :name
@@ -873,5 +876,6 @@
       projects
     end
   end
+
 
 end

Modified: incubator/buildr/trunk/lib/core/test.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/core/test.rb?rev=609822&r1=609821&r2=609822&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/core/test.rb (original)
+++ incubator/buildr/trunk/lib/core/test.rb Mon Jan  7 16:49:04 2008
@@ -22,9 +22,14 @@
         @frameworks[name.to_sym] or raise ArgumentError, "No #{name} framework available. Did you install it?"
       end
 
-      # Identify which compiler applies for this project.
+      # Identify which test framework applies for this project.
       def identify_from(project)
-        @frameworks.values.detect { |framework| compiler.supports?(project) }
+        # Look for a suitable test framework based on the compiled language,
+        # which may return multiple candidates, e.g. JUnit and TestNG for Java.
+        # Pick the one used in the parent project, if not, whichever comes first.
+        candidates = @frameworks.values.select { |framework| framework.supports?(project) }
+        parent = project.parent.test.framework if project.parent
+        candidates.detect { |framework| framework.name == parent } || candidates.first
       end
 
       # Adds a test framework to the list of supported frameworks.
@@ -608,4 +613,9 @@
     HELP
   end
 
+end
+
+
+class Buildr::Project
+  include Buildr::Test
 end

Modified: incubator/buildr/trunk/lib/ide.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/ide.rb?rev=609822&r1=609821&r2=609822&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/ide.rb (original)
+++ incubator/buildr/trunk/lib/ide.rb Mon Jan  7 16:49:04 2008
@@ -1,6 +1,2 @@
 require 'ide/eclipse'
 require 'ide/idea'
-
-class Buildr::Project
-  include Buildr::Eclipse, Buildr::Idea
-end

Modified: incubator/buildr/trunk/lib/ide/eclipse.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/ide/eclipse.rb?rev=609822&r1=609821&r2=609822&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/ide/eclipse.rb (original)
+++ incubator/buildr/trunk/lib/ide/eclipse.rb Mon Jan  7 16:49:04 2008
@@ -2,6 +2,7 @@
 require "core/project"
 require "java/artifact"
 
+
 module Buildr
   module Eclipse #:nodoc:
 
@@ -158,3 +159,8 @@
 
   end
 end # module Buildr
+
+
+class Buildr::Project
+  include Buildr::Eclipse
+end

Modified: incubator/buildr/trunk/lib/ide/idea.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/ide/idea.rb?rev=609822&r1=609821&r2=609822&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/ide/idea.rb (original)
+++ incubator/buildr/trunk/lib/ide/idea.rb Mon Jan  7 16:49:04 2008
@@ -4,6 +4,7 @@
 require 'stringio'
 require 'rexml/document'
 
+
 module Buildr
   module Idea #:nodoc:
 
@@ -165,3 +166,8 @@
 
   end
 end # module Buildr
+
+
+class Buildr::Project
+  include Buildr::Idea
+end

Modified: incubator/buildr/trunk/lib/java.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/java.rb?rev=609822&r1=609821&r2=609822&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/java.rb (original)
+++ incubator/buildr/trunk/lib/java.rb Mon Jan  7 16:49:04 2008
@@ -1,7 +1,3 @@
 require 'java/compilers'
 require 'java/test_frameworks'
 require 'java/packaging'
-
-class Buildr::Project
-  include Buildr::Java::Packaging
-end

Modified: incubator/buildr/trunk/lib/java/java.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/java/java.rb?rev=609822&r1=609821&r2=609822&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/java/java.rb (original)
+++ incubator/buildr/trunk/lib/java/java.rb Mon Jan  7 16:49:04 2008
@@ -365,7 +365,8 @@
 
     def self.import(cls)
       wrapper.load
-      cls.split('.').inject(wrapper) { |wrapper, name| wrapper.send(name) }
+      Rjb.import(cls)
+      #cls.split('.').inject(wrapper) { |wrapper, name| wrapper.send(name) }
     end
 
   end

Modified: incubator/buildr/trunk/lib/java/test_frameworks.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/lib/java/test_frameworks.rb?rev=609822&r1=609821&r2=609822&view=diff
==============================================================================
--- incubator/buildr/trunk/lib/java/test_frameworks.rb (original)
+++ incubator/buildr/trunk/lib/java/test_frameworks.rb Mon Jan  7 16:49:04 2008
@@ -109,7 +109,20 @@
 
     def files(path) #:nodoc:
       # Ignore anonymous classes.
-      super(path).reject { |name| name =~ /\$/ }
+      candidates = super(path).reject { |name| name =~ /\$/ }
+=begin
+      # Ignore classes that do not extend junit.framework.TestCase.
+      urls = ["#{path}/"] + Buildr.artifacts(REQUIRES)
+      urls = urls.map { |url| Java.import('java.net.URL').new("file://#{url}") }
+      class_loader = Java.import('java.net.URLClassLoader').new(urls)
+      unit_test = class_loader.loadClass('junit.framework.TestCase')
+      base = Pathname.new(path)
+      super(path).select do |file|
+        class_name = Pathname.new(file).relative_path_from(base).to_s.ext('').gsub(File::SEPARATOR, ',')
+        java_class = class_loader.loadClass(class_name) 
+        unit_test.isAssignableFrom(java_class)
+      end
+=end
     end
 
     def supports?(project) #:nodoc:

Modified: incubator/buildr/trunk/spec/compile_spec.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/compile_spec.rb?rev=609822&r1=609821&r2=609822&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/compile_spec.rb (original)
+++ incubator/buildr/trunk/spec/compile_spec.rb Mon Jan  7 16:49:04 2008
@@ -633,217 +633,3 @@
     project('foo').javadoc.invoke
   end
 end
-
-
-describe 'javac compiler' do
-  it 'should identify itself from source directories' do
-    write 'src/main/java/Test.java', 'class Test {}' 
-    define('foo').compile.compiler.should eql(:javac)
-  end
-
-  it 'should report the language as :java' do
-    define('foo').compile.using(:javac).language.should eql(:java)
-  end
-
-  it 'should set the target directory to target/classes' do
-    define 'foo' do
-      lambda { compile.using(:javac) }.should change { compile.target.to_s }.to(File.expand_path('target/classes'))
-    end
-  end
-
-  it 'should not override existing target directory' do
-    define 'foo' do
-      compile.into('classes')
-      lambda { compile.using(:javac) }.should_not change { compile.target }
-    end
-  end
-
-  it 'should not change existing list of sources' do
-    define 'foo' do
-      compile.from('sources')
-      lambda { compile.using(:javac) }.should_not change { compile.sources }
-    end
-  end
-
-  it 'should include as classpath dependency' do
-    write 'src/dependency/Dependency.java', 'class Dependency {}'
-    define 'dependency', :version=>'1.0' do
-      compile.from('src/dependency').into('target/dependency')
-      package(:jar)
-    end
-    write 'src/test/DependencyTest.java', 'class DependencyTest { Dependency _var; }'
-    lambda { define('foo').compile.from('src/test').with(project('dependency')).invoke }.should run_task('foo:compile')
-  end
-end
-
-
-describe 'javac compiler options' do
-  def compile_task
-    @compile_task ||= define('foo').compile.using(:javac)
-  end
-
-  def javac_args
-    Compiler::Javac.new.send(:javac_args_from, compile_task.options)
-  end
-
-  it 'should set warnings option to false by default' do
-    compile_task.options.warnings.should be_false
-  end
-
-  it 'should set wranings option to true when running with --verbose option' do
-    verbose true
-    compile_task.options.warnings.should be_true
-  end
-
-  it 'should use -nowarn argument when warnings is false' do
-    compile_task.using(:warnings=>false)
-    javac_args.should include('-nowarn') 
-  end
-
-  it 'should not use -nowarn argument when warnings is true' do
-    compile_task.using(:warnings=>true)
-    javac_args.should_not include('-nowarn') 
-  end
-
-  it 'should not use -verbose argument by default' do
-    javac_args.should_not include('-verbose') 
-  end
-
-  it 'should use -verbose argument when running with --trace option' do
-    trace true
-    javac_args.should include('-verbose') 
-  end
-
-  it 'should set debug option to true by default' do
-    compile_task.options.debug.should be_true
-  end
-
-  it 'should set debug option to false based on Buildr.options' do
-    Buildr.options.debug = false
-    compile_task.options.debug.should be_false
-  end
-
-  it 'should set debug option to false based on debug environment variable' do
-    ENV['debug'] = 'no'
-    compile_task.options.debug.should be_false
-  end
-
-  it 'should set debug option to false based on DEBUG environment variable' do
-    ENV['DEBUG'] = 'no'
-    compile_task.options.debug.should be_false
-  end
-
-  it 'should use -g argument when debug option is true' do
-    compile_task.using(:debug=>true)
-    javac_args.should include('-g')
-  end
-
-  it 'should not use -g argument when debug option is false' do
-    compile_task.using(:debug=>false)
-    javac_args.should_not include('-g')
-  end
-
-  it 'should set deprecation option to false by default' do
-    compile_task.options.deprecation.should be_false
-  end
-
-  it 'should use -deprecation argument when deprecation is true' do
-    compile_task.using(:deprecation=>true)
-    javac_args.should include('-deprecation')
-  end
-
-  it 'should not use -deprecation argument when deprecation is false' do
-    compile_task.using(:deprecation=>false)
-    javac_args.should_not include('-deprecation')
-  end
-
-  it 'should not set source option by default' do
-    compile_task.options.source.should be_nil
-    javac_args.should_not include('-source')
-  end
-
-  it 'should not set target option by default' do
-    compile_task.options.target.should be_nil
-    javac_args.should_not include('-target')
-  end
-
-  it 'should use -source nn argument if source option set' do
-    compile_task.using(:source=>'1.5')
-    javac_args.should include('-source', '1.5')
-  end
-
-  it 'should use -target nn argument if target option set' do
-    compile_task.using(:target=>'1.5')
-    javac_args.should include('-target', '1.5')
-  end
-
-  it 'should set lint option to false by default' do
-    compile_task.options.lint.should be_false
-  end
-
-  it 'should use -lint argument if lint option is true' do
-    compile_task.using(:lint=>true)
-    javac_args.should include('-Xlint')
-  end
-
-  it 'should use -lint argument with value of option' do
-    compile_task.using(:lint=>'all')
-    javac_args.should include('-Xlint:all')
-  end
-
-  it 'should use -lint argument with value of option as array' do
-    compile_task.using(:lint=>['path', 'serial'])
-    javac_args.should include('-Xlint:path,serial')
-  end
-
-  it 'should not set other option by default' do
-    compile_task.options.other.should be_nil
-  end
-
-  it 'should pass other argument if other option is string' do
-    compile_task.using(:other=>'-Xprint')
-    javac_args.should include('-Xprint')
-  end
-
-  it 'should pass other argument if other option is array' do
-    compile_task.using(:other=>['-Xstdout', 'msgs'])
-    javac_args.should include('-Xstdout', 'msgs')
-  end
-
-  it 'should complain about options it doesn\'t know' do
-    write 'source/Test.java', 'class Test {}'
-    compile_task.using(:unknown=>'option')
-    lambda { compile_task.from('source').invoke }.should raise_error(ArgumentError, /no such option/i)
-  end
-
-  it 'should inherit options from parent' do
-    define 'foo' do
-      compile.using(:warnings=>true, :debug=>true, :deprecation=>true, :source=>'1.5', :target=>'1.4')
-      define 'bar' do
-        compile.using(:javac)
-        compile.options.warnings.should be_true
-        compile.options.debug.should be_true
-        compile.options.deprecation.should be_true
-        compile.options.source.should eql('1.5')
-        compile.options.target.should eql('1.4')
-      end
-    end
-  end
-
-  it 'should only inherit options it knows' do
-    define 'foo' do
-      compile.using(:warnings=>true, :errors=>true)
-      define 'bar' do
-        compile.using(:javac)
-        compile.options.warnings.should be_true
-        compile.options.errors.should be_nil
-      end
-    end
-  end
-
-  after do
-    Buildr.options.debug = nil
-    ENV.delete "debug"
-    ENV.delete "DEBUG"
-  end
-end

Added: incubator/buildr/trunk/spec/java_compilers.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/java_compilers.rb?rev=609822&view=auto
==============================================================================
--- incubator/buildr/trunk/spec/java_compilers.rb (added)
+++ incubator/buildr/trunk/spec/java_compilers.rb Mon Jan  7 16:49:04 2008
@@ -0,0 +1,215 @@
+require File.join(File.dirname(__FILE__), 'spec_helpers')
+
+
+describe 'javac compiler' do
+  it 'should identify itself from source directories' do
+    write 'src/main/java/Test.java', 'class Test {}' 
+    define('foo').compile.compiler.should eql(:javac)
+  end
+
+  it 'should report the language as :java' do
+    define('foo').compile.using(:javac).language.should eql(:java)
+  end
+
+  it 'should set the target directory to target/classes' do
+    define 'foo' do
+      lambda { compile.using(:javac) }.should change { compile.target.to_s }.to(File.expand_path('target/classes'))
+    end
+  end
+
+  it 'should not override existing target directory' do
+    define 'foo' do
+      compile.into('classes')
+      lambda { compile.using(:javac) }.should_not change { compile.target }
+    end
+  end
+
+  it 'should not change existing list of sources' do
+    define 'foo' do
+      compile.from('sources')
+      lambda { compile.using(:javac) }.should_not change { compile.sources }
+    end
+  end
+
+  it 'should include as classpath dependency' do
+    write 'src/dependency/Dependency.java', 'class Dependency {}'
+    define 'dependency', :version=>'1.0' do
+      compile.from('src/dependency').into('target/dependency')
+      package(:jar)
+    end
+    write 'src/test/DependencyTest.java', 'class DependencyTest { Dependency _var; }'
+    lambda { define('foo').compile.from('src/test').with(project('dependency')).invoke }.should run_task('foo:compile')
+  end
+end
+
+
+describe 'javac compiler options' do
+  def compile_task
+    @compile_task ||= define('foo').compile.using(:javac)
+  end
+
+  def javac_args
+    Compiler::Javac.new.send(:javac_args_from, compile_task.options)
+  end
+
+  it 'should set warnings option to false by default' do
+    compile_task.options.warnings.should be_false
+  end
+
+  it 'should set wranings option to true when running with --verbose option' do
+    verbose true
+    compile_task.options.warnings.should be_true
+  end
+
+  it 'should use -nowarn argument when warnings is false' do
+    compile_task.using(:warnings=>false)
+    javac_args.should include('-nowarn') 
+  end
+
+  it 'should not use -nowarn argument when warnings is true' do
+    compile_task.using(:warnings=>true)
+    javac_args.should_not include('-nowarn') 
+  end
+
+  it 'should not use -verbose argument by default' do
+    javac_args.should_not include('-verbose') 
+  end
+
+  it 'should use -verbose argument when running with --trace option' do
+    trace true
+    javac_args.should include('-verbose') 
+  end
+
+  it 'should set debug option to true by default' do
+    compile_task.options.debug.should be_true
+  end
+
+  it 'should set debug option to false based on Buildr.options' do
+    Buildr.options.debug = false
+    compile_task.options.debug.should be_false
+  end
+
+  it 'should set debug option to false based on debug environment variable' do
+    ENV['debug'] = 'no'
+    compile_task.options.debug.should be_false
+  end
+
+  it 'should set debug option to false based on DEBUG environment variable' do
+    ENV['DEBUG'] = 'no'
+    compile_task.options.debug.should be_false
+  end
+
+  it 'should use -g argument when debug option is true' do
+    compile_task.using(:debug=>true)
+    javac_args.should include('-g')
+  end
+
+  it 'should not use -g argument when debug option is false' do
+    compile_task.using(:debug=>false)
+    javac_args.should_not include('-g')
+  end
+
+  it 'should set deprecation option to false by default' do
+    compile_task.options.deprecation.should be_false
+  end
+
+  it 'should use -deprecation argument when deprecation is true' do
+    compile_task.using(:deprecation=>true)
+    javac_args.should include('-deprecation')
+  end
+
+  it 'should not use -deprecation argument when deprecation is false' do
+    compile_task.using(:deprecation=>false)
+    javac_args.should_not include('-deprecation')
+  end
+
+  it 'should not set source option by default' do
+    compile_task.options.source.should be_nil
+    javac_args.should_not include('-source')
+  end
+
+  it 'should not set target option by default' do
+    compile_task.options.target.should be_nil
+    javac_args.should_not include('-target')
+  end
+
+  it 'should use -source nn argument if source option set' do
+    compile_task.using(:source=>'1.5')
+    javac_args.should include('-source', '1.5')
+  end
+
+  it 'should use -target nn argument if target option set' do
+    compile_task.using(:target=>'1.5')
+    javac_args.should include('-target', '1.5')
+  end
+
+  it 'should set lint option to false by default' do
+    compile_task.options.lint.should be_false
+  end
+
+  it 'should use -lint argument if lint option is true' do
+    compile_task.using(:lint=>true)
+    javac_args.should include('-Xlint')
+  end
+
+  it 'should use -lint argument with value of option' do
+    compile_task.using(:lint=>'all')
+    javac_args.should include('-Xlint:all')
+  end
+
+  it 'should use -lint argument with value of option as array' do
+    compile_task.using(:lint=>['path', 'serial'])
+    javac_args.should include('-Xlint:path,serial')
+  end
+
+  it 'should not set other option by default' do
+    compile_task.options.other.should be_nil
+  end
+
+  it 'should pass other argument if other option is string' do
+    compile_task.using(:other=>'-Xprint')
+    javac_args.should include('-Xprint')
+  end
+
+  it 'should pass other argument if other option is array' do
+    compile_task.using(:other=>['-Xstdout', 'msgs'])
+    javac_args.should include('-Xstdout', 'msgs')
+  end
+
+  it 'should complain about options it doesn\'t know' do
+    write 'source/Test.java', 'class Test {}'
+    compile_task.using(:unknown=>'option')
+    lambda { compile_task.from('source').invoke }.should raise_error(ArgumentError, /no such option/i)
+  end
+
+  it 'should inherit options from parent' do
+    define 'foo' do
+      compile.using(:warnings=>true, :debug=>true, :deprecation=>true, :source=>'1.5', :target=>'1.4')
+      define 'bar' do
+        compile.using(:javac)
+        compile.options.warnings.should be_true
+        compile.options.debug.should be_true
+        compile.options.deprecation.should be_true
+        compile.options.source.should eql('1.5')
+        compile.options.target.should eql('1.4')
+      end
+    end
+  end
+
+  it 'should only inherit options it knows' do
+    define 'foo' do
+      compile.using(:warnings=>true, :errors=>true)
+      define 'bar' do
+        compile.using(:javac)
+        compile.options.warnings.should be_true
+        compile.options.errors.should be_nil
+      end
+    end
+  end
+
+  after do
+    Buildr.options.debug = nil
+    ENV.delete "debug"
+    ENV.delete "DEBUG"
+  end
+end

Added: incubator/buildr/trunk/spec/java_test_frameworks.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/java_test_frameworks.rb?rev=609822&view=auto
==============================================================================
--- incubator/buildr/trunk/spec/java_test_frameworks.rb (added)
+++ incubator/buildr/trunk/spec/java_test_frameworks.rb Mon Jan  7 16:49:04 2008
@@ -0,0 +1,206 @@
+require File.join(File.dirname(__FILE__), 'spec_helpers')
+
+
+describe Buildr::JUnit do
+  before do
+    write "src/test/java/PassingTest.java", 
+      "public class PassingTest extends junit.framework.TestCase { public void testNothing() {} }"
+    write "src/test/java/FailingTest.java", 
+      "public class FailingTest extends junit.framework.TestCase { public void testNothing() { assertTrue(false); } }"
+    define "foo"
+  end
+
+  it "should include JUnit requirements" do
+    project("foo").test.requires.should include(*JUnit::REQUIRES)
+    project("foo").test.compile.dependencies.should include(*artifacts(JUnit::REQUIRES))
+    project("foo").test.dependencies.should include(*artifacts(JUnit::REQUIRES))
+  end
+
+  it "should include JMock requirements" do
+    project("foo").test.requires.should include(*JMock::REQUIRES)
+    project("foo").test.compile.dependencies.should include(*artifacts(JMock::REQUIRES))
+    project("foo").test.dependencies.should include(*artifacts(JMock::REQUIRES))
+  end
+
+  it "should include classes starting with and ending with Test" do
+    ["TestThis", "ThisTest", "ThisThat"].each do |name|
+      write "target/test/classes/#{name}.class"
+    end
+    project("foo").test.files.map { |file| File.basename(file) }.should == ["TestThis.class", "ThisTest.class"]
+  end
+
+  it "should ignore inner classes" do
+    ["TestThis", "TestThis$Innner"].each do |name|
+      write "target/test/classes/#{name}.class"
+    end
+    project("foo").test.files.map { |file| File.basename(file) }.should == ["TestThis.class"]
+  end
+
+  it "should pass when JUnit test case passes" do
+    project("foo").test.include "PassingTest"
+    lambda { project("foo").test.invoke }.should_not raise_error
+  end
+
+  it "should fail when JUnit test case fails" do
+    project("foo").test.include "FailingTest"
+    lambda { project("foo").test.invoke }.should raise_error(RuntimeError, /Tests failed/)
+  end
+
+  it 'should report failed test names' do
+    project("foo").test.include "FailingTest"
+    project("foo").test.invoke rescue
+    project("foo").test.failed_tests.should eql(['FailingTest'])
+  end
+
+  it "should report to reports/junit" do
+    project("foo").test.report_to.should be(project("foo").file("reports/junit"))
+    project("foo").test.include("PassingTest").invoke
+    project("foo").file("reports/junit/TEST-PassingTest.txt").should exist
+    project("foo").file("reports/junit/TEST-PassingTest.xml").should exist
+  end
+
+  it "should pass properties to JVM" do
+    write "src/test/java/PropertyTest.java", <<-JAVA
+      public class PropertyTest extends junit.framework.TestCase {
+        public void testProperty() {
+          assertEquals("value", System.getProperty("name"));
+        }
+      }
+    JAVA
+    project("foo").test.include "PropertyTest"
+    project("foo").test.using :properties=>{ 'name'=>'value' }
+    project("foo").test.invoke
+  end
+
+  it "should set current directory" do
+    mkpath "baz"
+    write "baz/src/test/java/CurrentDirectoryTest.java", <<-JAVA
+      public class CurrentDirectoryTest extends junit.framework.TestCase {
+        public void testCurrentDirectory() throws Exception {
+          assertEquals("#{File.expand_path('baz')}", new java.io.File(".").getCanonicalPath());
+        }
+      }
+    JAVA
+    define "bar" do
+      define "baz" do
+        test.include "CurrentDirectoryTest"
+      end
+    end
+    project("bar:baz").test.invoke
+  end
+end
+
+
+describe Rake::Task, "junit:report" do
+
+  it "should default to the target directory reports/junit" do
+    JUnit.report.target.should eql("reports/junit")
+  end
+
+  it "should generate report into the target directory" do
+    JUnit.report.target = "test-report"
+    lambda { task("junit:report").invoke }.should change { File.exist?(JUnit.report.target) }.to(true)
+  end
+
+  it "should clean after itself" do
+    mkpath JUnit.report.target
+    lambda { task("clean").invoke }.should change { File.exist?(JUnit.report.target) }.to(false)
+  end
+
+  it "should generate a consolidated XML report" do
+    lambda { task("junit:report").invoke }.should change { File.exist?("reports/junit/TESTS-TestSuites.xml") }.to(true)
+  end
+
+  it "should default to generating a report with frames" do
+    JUnit.report.frames.should be_true
+  end
+
+  it "should generate single page when frames is false" do
+    JUnit.report.frames = false
+    task("junit:report").invoke
+    file("reports/junit/html/junit-noframes.html").should exist
+  end
+
+  it "should generate frame page when frames is false" do
+    JUnit.report.frames = true
+    task("junit:report").invoke
+    file("reports/junit/html/index.html").should exist
+  end
+
+  it "should generate reports from all projects that ran test cases" do
+    write "src/test/java/TestSomething.java",
+      "public class TestSomething extends junit.framework.TestCase { public void testNothing() {} }"
+    define "foo"
+    project("foo").test.invoke
+    task("junit:report").invoke
+    FileList["reports/junit/html/*TestSomething.html"].size.should be(1)
+  end
+
+  after do
+    JUnit.instance_eval { @report = nil }
+  end
+end
+
+
+describe Buildr::TestNG do
+  before do
+    write "src/test/java/PassingTest.java", 
+      "public class PassingTest { @org.testng.annotations.Test public void testNothing() {} }"
+    write "src/test/java/FailingTest.java", 
+      "public class FailingTest { @org.testng.annotations.Test public void testNothing() { org.testng.AssertJUnit.assertTrue(false); } }"
+    define("foo") { test.using :testng }
+  end
+
+  it "should include TestNG requirements" do
+    project("foo").test.requires.should include(*TestNG::REQUIRES)
+    project("foo").test.compile.dependencies.should include(*artifacts(TestNG::REQUIRES))
+    project("foo").test.dependencies.should include(*artifacts(TestNG::REQUIRES))
+  end
+
+  it "should include TestNG requirements" do
+    project("foo").test.requires.should include(*JMock::REQUIRES)
+    project("foo").test.compile.dependencies.should include(*artifacts(JMock::REQUIRES))
+    project("foo").test.dependencies.should include(*artifacts(JMock::REQUIRES))
+  end
+
+  it "should include classes starting with and ending with Test" do
+    ["TestThis", "ThisTest", "ThisThat"].each do |name|
+      write File.join(project("foo").test.compile.target.to_s, name).ext("class")
+    end
+    project("foo").test.files.map { |file| File.basename(file) }.should == ["TestThis.class", "ThisTest.class"]
+  end
+
+  it "should ignore inner classes" do
+    ["TestThis", "TestThis$Innner"].each do |name|
+      write "target/test/classes/#{name}.class"
+    end
+    project("foo").test.files.map { |file| File.basename(file) }.should == ["TestThis.class"]
+  end
+
+  it "should pass when TestNG test case passes" do
+    project("foo").test.include "PassingTest"
+    lambda { project("foo").test.invoke }.should_not raise_error
+  end
+
+  it "should fail when TestNG test case fails" do
+    project("foo").test.include "FailingTest"
+    lambda { project("foo").test.invoke }.should raise_error(RuntimeError, /Tests failed/)
+  end
+
+  it 'should report failed test names' do
+    project("foo").test.include "FailingTest"
+    project("foo").test.invoke rescue
+    project("foo").test.failed_tests.should eql(['FailingTest'])
+  end
+
+  it "should report to reports/testng" do
+    project("foo").test.report_to.should be(project("foo").file("reports/testng"))
+  end
+
+  it "should generate reports" do
+    project("foo").test.include "PassingTest"
+    lambda { project("foo").test.invoke }.should change { File.exist?(project("foo").test.report_to.to_s) }.to(true)
+  end
+end
+
+

Modified: incubator/buildr/trunk/spec/spec_helpers.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/spec_helpers.rb?rev=609822&r1=609821&r2=609822&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/spec_helpers.rb (original)
+++ incubator/buildr/trunk/spec/spec_helpers.rb Mon Jan  7 16:49:04 2008
@@ -1,6 +1,7 @@
 # This file gets loaded twice when running 'spec spec/*' and not with pleasent results,
 # so ignore the second attempt to load it.
 unless $LOADED_FEATURES.include?(__FILE__)
+
   require 'rubygems'
   $LOAD_PATH.unshift File.expand_path('../lib', File.dirname(__FILE__))
   require 'buildr'

Modified: incubator/buildr/trunk/spec/test_spec.rb
URL: http://svn.apache.org/viewvc/incubator/buildr/trunk/spec/test_spec.rb?rev=609822&r1=609821&r2=609822&view=diff
==============================================================================
--- incubator/buildr/trunk/spec/test_spec.rb (original)
+++ incubator/buildr/trunk/spec/test_spec.rb Mon Jan  7 16:49:04 2008
@@ -239,158 +239,6 @@
 end
 
 
-describe Buildr::JUnit do
-  before do
-    write "src/test/java/PassingTest.java", 
-      "public class PassingTest extends junit.framework.TestCase { public void testNothing() {} }"
-    write "src/test/java/FailingTest.java", 
-      "public class FailingTest extends junit.framework.TestCase { public void testNothing() { assertTrue(false); } }"
-    define "foo"
-  end
-
-  it "should include JUnit requirements" do
-    project("foo").test.requires.should include(*JUnit::REQUIRES)
-    project("foo").test.compile.dependencies.should include(*artifacts(JUnit::REQUIRES))
-    project("foo").test.dependencies.should include(*artifacts(JUnit::REQUIRES))
-  end
-
-  it "should include JMock requirements" do
-    project("foo").test.requires.should include(*JMock::REQUIRES)
-    project("foo").test.compile.dependencies.should include(*artifacts(JMock::REQUIRES))
-    project("foo").test.dependencies.should include(*artifacts(JMock::REQUIRES))
-  end
-
-  it "should include classes starting with and ending with Test" do
-    ["TestThis", "ThisTest", "ThisThat"].each do |name|
-      write "target/test/classes/#{name}.class"
-    end
-    project("foo").test.files.map { |file| File.basename(file) }.should == ["TestThis.class", "ThisTest.class"]
-  end
-
-  it "should ignore inner classes" do
-    ["TestThis", "TestThis$Innner"].each do |name|
-      write "target/test/classes/#{name}.class"
-    end
-    project("foo").test.files.map { |file| File.basename(file) }.should == ["TestThis.class"]
-  end
-
-  it "should pass when JUnit test case passes" do
-    project("foo").test.include "PassingTest"
-    lambda { project("foo").test.invoke }.should_not raise_error
-  end
-
-  it "should fail when JUnit test case fails" do
-    project("foo").test.include "FailingTest"
-    lambda { project("foo").test.invoke }.should raise_error(RuntimeError, /Tests failed/)
-  end
-
-  it 'should report failed test names' do
-    project("foo").test.include "FailingTest"
-    project("foo").test.invoke rescue
-    project("foo").test.failed_tests.should eql(['FailingTest'])
-  end
-
-  it "should report to reports/junit" do
-    project("foo").test.report_to.should be(project("foo").file("reports/junit"))
-    project("foo").test.include("PassingTest").invoke
-    project("foo").file("reports/junit/TEST-PassingTest.txt").should exist
-    project("foo").file("reports/junit/TEST-PassingTest.xml").should exist
-  end
-
-  it "should pass properties to JVM" do
-    write "src/test/java/PropertyTest.java", <<-JAVA
-      public class PropertyTest extends junit.framework.TestCase {
-        public void testProperty() {
-          assertEquals("value", System.getProperty("name"));
-        }
-      }
-    JAVA
-    project("foo").test.include "PropertyTest"
-    project("foo").test.using :properties=>{ 'name'=>'value' }
-    project("foo").test.invoke
-  end
-
-  it "should set current directory" do
-    mkpath "baz"
-    write "baz/src/test/java/CurrentDirectoryTest.java", <<-JAVA
-      public class CurrentDirectoryTest extends junit.framework.TestCase {
-        public void testCurrentDirectory() throws Exception {
-          assertEquals("#{File.expand_path('baz')}", new java.io.File(".").getCanonicalPath());
-        }
-      }
-    JAVA
-    define "bar" do
-      define "baz" do
-        test.include "CurrentDirectoryTest"
-      end
-    end
-    project("bar:baz").test.invoke
-  end
-end
-
-
-describe Buildr::TestTask, " using testng" do
-  before do
-    write "src/test/java/PassingTest.java", 
-      "public class PassingTest { @org.testng.annotations.Test public void testNothing() {} }"
-    write "src/test/java/FailingTest.java", 
-      "public class FailingTest { @org.testng.annotations.Test public void testNothing() { org.testng.AssertJUnit.assertTrue(false); } }"
-    define("foo") { test.using :testng }
-  end
-
-  it "should include TestNG requirements" do
-    project("foo").test.requires.should include(*TestNG::REQUIRES)
-    project("foo").test.compile.dependencies.should include(*artifacts(TestNG::REQUIRES))
-    project("foo").test.dependencies.should include(*artifacts(TestNG::REQUIRES))
-  end
-
-  it "should include TestNG requirements" do
-    project("foo").test.requires.should include(*JMock::REQUIRES)
-    project("foo").test.compile.dependencies.should include(*artifacts(JMock::REQUIRES))
-    project("foo").test.dependencies.should include(*artifacts(JMock::REQUIRES))
-  end
-
-  it "should include classes starting with and ending with Test" do
-    ["TestThis", "ThisTest", "ThisThat"].each do |name|
-      write File.join(project("foo").test.compile.target.to_s, name).ext("class")
-    end
-    project("foo").test.files.map { |file| File.basename(file) }.should == ["TestThis.class", "ThisTest.class"]
-  end
-
-  it "should ignore inner classes" do
-    ["TestThis", "TestThis$Innner"].each do |name|
-      write "target/test/classes/#{name}.class"
-    end
-    project("foo").test.files.map { |file| File.basename(file) }.should == ["TestThis.class"]
-  end
-
-  it "should pass when TestNG test case passes" do
-    project("foo").test.include "PassingTest"
-    lambda { project("foo").test.invoke }.should_not raise_error
-  end
-
-  it "should fail when TestNG test case fails" do
-    project("foo").test.include "FailingTest"
-    lambda { project("foo").test.invoke }.should raise_error(RuntimeError, /Tests failed/)
-  end
-
-  it 'should report failed test names' do
-    project("foo").test.include "FailingTest"
-    project("foo").test.invoke rescue
-    project("foo").test.failed_tests.should eql(['FailingTest'])
-  end
-
-  it "should report to reports/testng" do
-    project("foo").test.report_to.should be(project("foo").file("reports/testng"))
-  end
-
-  it "should generate reports" do
-    project("foo").test.include "PassingTest"
-    lambda { project("foo").test.invoke }.should change { File.exist?(project("foo").test.report_to.to_s) }.to(true)
-  end
-end
-
-
 
 describe Buildr::Project.method(:test) do
   it "should return the project's test task" do
@@ -686,57 +534,6 @@
   it "should be true and warn for any other value" do
     ENV["TEST"] = "funky"
     lambda { Buildr.options.test.should be(true) }.should warn_that(/expecting the environment variable/i)
-  end
-end
-
-
-describe Rake::Task, "junit:report" do
-
-  it "should default to the target directory reports/junit" do
-    JUnit.report.target.should eql("reports/junit")
-  end
-
-  it "should generate report into the target directory" do
-    JUnit.report.target = "test-report"
-    lambda { task("junit:report").invoke }.should change { File.exist?(JUnit.report.target) }.to(true)
-  end
-
-  it "should clean after itself" do
-    mkpath JUnit.report.target
-    lambda { task("clean").invoke }.should change { File.exist?(JUnit.report.target) }.to(false)
-  end
-
-  it "should generate a consolidated XML report" do
-    lambda { task("junit:report").invoke }.should change { File.exist?("reports/junit/TESTS-TestSuites.xml") }.to(true)
-  end
-
-  it "should default to generating a report with frames" do
-    JUnit.report.frames.should be_true
-  end
-
-  it "should generate single page when frames is false" do
-    JUnit.report.frames = false
-    task("junit:report").invoke
-    file("reports/junit/html/junit-noframes.html").should exist
-  end
-
-  it "should generate frame page when frames is false" do
-    JUnit.report.frames = true
-    task("junit:report").invoke
-    file("reports/junit/html/index.html").should exist
-  end
-
-  it "should generate reports from all projects that ran test cases" do
-    write "src/test/java/TestSomething.java",
-      "public class TestSomething extends junit.framework.TestCase { public void testNothing() {} }"
-    define "foo"
-    project("foo").test.invoke
-    task("junit:report").invoke
-    FileList["reports/junit/html/*TestSomething.html"].size.should be(1)
-  end
-
-  after do
-    JUnit.instance_eval { @report = nil }
   end
 end