From 7b0957def9b0fb68b11e8fca6d78983b994740e1 Mon Sep 17 00:00:00 2001 From: Dylan Ratcliffe Date: Wed, 19 Jun 2019 18:54:02 +0200 Subject: [PATCH] Added handling of bad execs --- templates/test_spec.rb.erb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/templates/test_spec.rb.erb b/templates/test_spec.rb.erb index 92775019..a0cc0256 100644 --- a/templates/test_spec.rb.erb +++ b/templates/test_spec.rb.erb @@ -29,6 +29,20 @@ describe "<%= cls.name %>" do end <% end -%> + before :each do + # Curtrently there is some code within Puppet that will try to execute + # commands when compiling a catalog even though it shouldn't. One example is + # the groups attribute of the user resource on AIX. If we are running on + # Windows but pretending to be UNIX this will definitely fail so we need to + # mock it (or vice versa) + # Details: + # https://github.com/puppetlabs/puppet/blob/master/lib/puppet/util/execution.rb#L191 + expected_null_file = Puppet::Util::Platform.windows? ? 'NUL' : '/dev/null' + unless File.exist? expected_null_file + Puppet::Util::Execution.stubs(:execute).raises(Puppet::ExecutionFailure.new("Onceover caused this")) + end + end + <% if @after_conditions -%> after :each do <% @after_conditions.each do |function| -%>