buildr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From boisv...@apache.org
Subject svn commit: r882823 - in /buildr/trunk: lib/buildr/java/packaging.rb lib/buildr/packaging/archive.rb spec/java/packaging_spec.rb spec/packaging/archive_spec.rb
Date Sat, 21 Nov 2009 02:09:20 GMT
Author: boisvert
Date: Sat Nov 21 02:09:20 2009
New Revision: 882823

URL: http://svn.apache.org/viewvc?rev=882823&view=rev
Log:
Fail fast when trying to package/include nil values

Modified:
    buildr/trunk/lib/buildr/java/packaging.rb
    buildr/trunk/lib/buildr/packaging/archive.rb
    buildr/trunk/spec/java/packaging_spec.rb
    buildr/trunk/spec/packaging/archive_spec.rb

Modified: buildr/trunk/lib/buildr/java/packaging.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/java/packaging.rb?rev=882823&r1=882822&r2=882823&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/java/packaging.rb (original)
+++ buildr/trunk/lib/buildr/java/packaging.rb Sat Nov 21 02:09:20 2009
@@ -225,7 +225,8 @@
         #   package(:jar).with(:manifest=>'MANIFEST_MF')
         def with(*args)
           super args.pop if Hash === args.last
-          include :from=>args
+          fail "package.with() should not contain nil values" if args.include? nil
+          include :from=>args if args.size > 0
           self
         end
 

Modified: buildr/trunk/lib/buildr/packaging/archive.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/packaging/archive.rb?rev=882823&r1=882822&r2=882823&view=diff
==============================================================================
--- buildr/trunk/lib/buildr/packaging/archive.rb (original)
+++ buildr/trunk/lib/buildr/packaging/archive.rb Sat Nov 21 02:09:20 2009
@@ -62,6 +62,7 @@
       def include(*args)
         options = args.pop if Hash === args.last
         files = args.flatten
+        raise 'AchiveTask.include() values should not include nil' if files.include? nil

 
         if options.nil? || options.empty?
           @includes.include *files.flatten
@@ -74,7 +75,8 @@
           include_as files.first.to_s, options[:as]
         elsif options[:from]
           raise 'You can only use the :from option in combination with the :path option'
unless options.size == 1
-          raise 'You canont use the :from option with file names' unless files.empty?
+          raise 'You cannot use the :from option with file names' unless files.empty?
+          fail 'AchiveTask.include() :from value should not be nil' if [options[:from]].flatten.include?
nil 
           [options[:from]].flatten.each { |path| include_as path.to_s, '.' }
         elsif options[:merge]
           raise 'You can only use the :merge option in combination with the :path option'
unless options.size == 1
@@ -172,7 +174,7 @@
 
     protected
 
-      def include_as(source, as)
+    def include_as(source, as)
         @sources << proc { source }
         @actions << proc do |file_map|
           file = source.to_s
@@ -346,7 +348,8 @@
     #   zip(..).include('foo.zip', :merge=>true).include('bar.zip')
     # You can also use the method #merge.
     def include(*files)
-      @paths[''].include *files
+      fail "AchiveTask.include() called with nil values" if files.include? nil
+      @paths[''].include *files if files.compact.size > 0
       self
     end 
     alias :add :include

Modified: buildr/trunk/spec/java/packaging_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/java/packaging_spec.rb?rev=882823&r1=882822&r2=882823&view=diff
==============================================================================
--- buildr/trunk/spec/java/packaging_spec.rb (original)
+++ buildr/trunk/spec/java/packaging_spec.rb Sat Nov 21 02:09:20 2009
@@ -454,6 +454,12 @@
       jar.entries.map(&:to_s).sort.should include('empty/')
     end
   end
+  
+  it 'should raise error when calling with() with nil value' do
+    lambda {
+      define('foo', :version=>'1.0') { package(:jar).with(nil) }
+    }.should raise_error
+  end
 end
 
 

Modified: buildr/trunk/spec/packaging/archive_spec.rb
URL: http://svn.apache.org/viewvc/buildr/trunk/spec/packaging/archive_spec.rb?rev=882823&r1=882822&r2=882823&view=diff
==============================================================================
--- buildr/trunk/spec/packaging/archive_spec.rb (original)
+++ buildr/trunk/spec/packaging/archive_spec.rb Sat Nov 21 02:09:20 2009
@@ -59,6 +59,11 @@
     inspect_archive { |archive| archive.should be_empty }
   end
 
+  it 'should raise error when include() is called with nil values' do
+    lambda { archive(@archive).include(nil) }.should raise_error
+    lambda { archive(@archive).include([nil]) }.should raise_error
+  end
+
   it 'should create empty archive if called #clean method' do
     archive(@archive).include(@files).clean.invoke
     inspect_archive { |archive| archive.should be_empty }
@@ -112,6 +117,12 @@
     end
   end
 
+  it 'should raise error when using :from with nil value' do
+    lambda {
+      archive(@archive).include(:from=>nil)
+    }.should raise_error
+  end
+
   it 'should exclude entire directory and all its children' do
     mkpath "#{@dir}/sub"
     write "#{@dir}/sub/test"



Mime
View raw message