From: Rein Henrichs <[email protected]>

Use Puppet::Util.execute to run the config_version command and reraise
its potential Puppet::ExecutionFailure exception as a more useful
Pupppet::ParseError

Signed-off-by: Rein Henrichs <[email protected]>
---
 lib/puppet/parser/parser_support.rb |    5 ++++-
 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 4fe2a5a..7a8fa81 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 842dc19..78caf18 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
-- 
1.6.4.2


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to