diff options
author | Rein Henrichs <reinh@reinh.com> | 2009-10-13 18:21:06 -0700 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-10-15 15:58:26 +1100 |
commit | 8a7308249783fc75d450fc2428cba52a5ad30a10 (patch) | |
tree | 8b4b9557fb169fac7a2f12778df09c3b5d864812 | |
parent | 54ded1bd2b8c023d6e480c21f1b2b03f3b7859ba (diff) | |
download | puppet-8a7308249783fc75d450fc2428cba52a5ad30a10.tar.gz puppet-8a7308249783fc75d450fc2428cba52a5ad30a10.tar.xz puppet-8a7308249783fc75d450fc2428cba52a5ad30a10.zip |
Fix #2707 config_version fails more helpfully
Use Puppet::Util.execute to run the config_version command and reraise
its potential Puppet::ExecutionFailure exception as a more useful
Pupppet::ParseError
-rw-r--r-- | lib/puppet/parser/parser_support.rb | 5 | ||||
-rwxr-xr-x | spec/unit/parser/parser.rb | 10 |
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/puppet/parser/parser_support.rb b/lib/puppet/parser/parser_support.rb index 4fe2a5a0d..7a8fa812a 100644 --- a/lib/puppet/parser/parser_support.rb +++ b/lib/puppet/parser/parser_support.rb @@ -484,7 +484,10 @@ class Puppet::Parser::Parser return @version end - @version = %x{#{Puppet[:config_version]}}.chomp + @version = Puppet::Util.execute([Puppet[:config_version]]).strip + + rescue Puppet::ExecutionFailure => e + raise Puppet::ParseError, "Unable to set config_version: #{e.message}" end # Add a new file to be checked when we're checking to see if we should be diff --git a/spec/unit/parser/parser.rb b/spec/unit/parser/parser.rb index 842dc1904..78caf18b0 100755 --- a/spec/unit/parser/parser.rb +++ b/spec/unit/parser/parser.rb @@ -324,9 +324,17 @@ describe Puppet::Parser do it "should use the output of the config_version setting if one is provided" do Puppet.settings.stubs(:[]).with(:config_version).returns("/my/foo") - @parser.expects(:`).with("/my/foo").returns "output\n" + Puppet::Util.expects(:execute).with(["/my/foo"]).returns "output\n" @parser.version.should == "output" end + + it "should raise a puppet parser error if executing config_version fails" do + Puppet.settings.stubs(:[]).with(:config_version).returns("test") + Puppet::Util.expects(:execute).raises(Puppet::ExecutionFailure.new("msg")) + + lambda { @parser.version }.should raise_error(Puppet::ParseError) + end + end describe Puppet::Parser,"when looking up definitions" do |