Return-Path: Delivered-To: apmail-buildr-commits-archive@www.apache.org Received: (qmail 53122 invoked from network); 21 Nov 2009 02:09:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 21 Nov 2009 02:09:45 -0000 Received: (qmail 62598 invoked by uid 500); 21 Nov 2009 02:09:45 -0000 Delivered-To: apmail-buildr-commits-archive@buildr.apache.org Received: (qmail 62573 invoked by uid 500); 21 Nov 2009 02:09:45 -0000 Mailing-List: contact commits-help@buildr.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@buildr.apache.org Delivered-To: mailing list commits@buildr.apache.org Received: (qmail 62564 invoked by uid 99); 21 Nov 2009 02:09:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 21 Nov 2009 02:09:44 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 21 Nov 2009 02:09:42 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id ED6012388864; Sat, 21 Nov 2009 02:09:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@buildr.apache.org From: boisvert@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091121020920.ED6012388864@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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"