You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2020/06/17 19:28:46 UTC

[whimsy] branch master updated: svn now raises ArgumentError for bad args

This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 4059afe  svn now raises ArgumentError for bad args
4059afe is described below

commit 4059afeee43e706381ff7c8021e01f31dc344add
Author: Sebb <se...@apache.org>
AuthorDate: Wed Jun 17 20:28:37 2020 +0100

    svn now raises ArgumentError for bad args
---
 lib/spec/lib/svn_spec.rb           | 14 ++++++++++++++
 lib/spec/lib/svn_wunderbar_spec.rb | 16 ++++++++++++++++
 lib/whimsy/asf/svn.rb              |  5 +++--
 3 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/lib/spec/lib/svn_spec.rb b/lib/spec/lib/svn_spec.rb
index 4b8156e..cad0cd3 100644
--- a/lib/spec/lib/svn_spec.rb
+++ b/lib/spec/lib/svn_spec.rb
@@ -231,6 +231,20 @@ describe ASF::SVN do
   end
 
   describe "ASF::SVN.svn" do
+    it "svn(nil,nil) should raise error" do
+      expect { ASF::SVN.svn(nil,nil) }.to raise_error(ArgumentError, 'command must not be nil')
+    end
+    it "svn('st',nil) should raise error" do
+      expect { ASF::SVN.svn('st',nil) }.to raise_error(ArgumentError, 'path must not be nil')
+    end
+    it "svn('st','',{xyz: true}) should raise error" do
+      expect { ASF::SVN.svn('st','',{xyz: true}) }.to raise_error(ArgumentError, 'Following options not recognised: [:xyz]')
+    end
+    it "svn('st','',{args: true}) should raise error" do
+      expect { ASF::SVN.svn('st','',{args: true}) }.to raise_error(ArgumentError, "args 'true' must be string or array")
+    end
+
+
     it "svn('info', path) should return 'Name: path'" do
       repo = File.join(ASF::SVN.svnurl('attic-xdocs'),'_template.xml')
       out, err = ASF::SVN.svn('info',repo)
diff --git a/lib/spec/lib/svn_wunderbar_spec.rb b/lib/spec/lib/svn_wunderbar_spec.rb
index 3afecf4..e7f5530 100644
--- a/lib/spec/lib/svn_wunderbar_spec.rb
+++ b/lib/spec/lib/svn_wunderbar_spec.rb
@@ -31,6 +31,22 @@ describe "ASF::SVN.svn_!" do
 end
 
 describe "ASF::SVN.svn_" do
+  it "svn_(nil,nil,nil) should raise error" do
+    expect { ASF::SVN.svn_(nil,nil,nil) }.to raise_error(ArgumentError, 'command must not be nil')
+  end
+  it "svn_('st',nil,nil) should raise error" do
+    expect { ASF::SVN.svn_('st',nil,nil) }.to raise_error(ArgumentError, 'path must not be nil')
+  end
+  it "svn_('st','',nil) should raise error" do
+    expect { ASF::SVN.svn_('st','',nil) }.to raise_error(ArgumentError, 'wunderbar (_) must not be nil')
+  end
+  it "svn_('st','',_,{xyz: true}) should raise error" do
+    expect { ASF::SVN.svn_('st','',true,{xyz: true}) }.to raise_error(ArgumentError, 'Following options not recognised: [:xyz]')
+  end
+  it "svn_('st','',_,{args: true}) should raise error" do
+    expect { ASF::SVN.svn_('st','',true,{args: true}) }.to raise_error(ArgumentError, "args 'true' must be string or array")
+  end
+
   it "svn_('info') should return array with Name:" do
     repo = File.join(ASF::SVN.svnurl('attic-xdocs'),'_template.xml')
 
diff --git a/lib/whimsy/asf/svn.rb b/lib/whimsy/asf/svn.rb
index c97bb9e..5907b06 100644
--- a/lib/whimsy/asf/svn.rb
+++ b/lib/whimsy/asf/svn.rb
@@ -280,6 +280,7 @@ module ASF
     # - stdout
     # - nil, err
     # - [cmd] if :dryrun
+    # May raise ArgumentError
     def self.svn(command, path , options = {})
       raise ArgumentError.new 'command must not be nil' unless command
       raise ArgumentError.new 'path must not be nil' unless path
@@ -291,7 +292,7 @@ module ASF
 
       bad_keys = options.keys - VALID_KEYS
       if bad_keys.size > 0
-        return nil, "Following options not recognised: #{bad_keys.inspect}"
+        raise ArgumentError.new "Following options not recognised: #{bad_keys.inspect}"
       end
 
       # build svn command
@@ -304,7 +305,7 @@ module ASF
         elsif args.is_a? Array
           cmd += args
         else
-          return nil, "args '#{args.inspect}' must be string or array"
+          raise ArgumentError.new "args '#{args.inspect}' must be string or array"
         end
       end