Sha256: 81b39459f2856c74294e017e21161d4da08cb88aaca8df95f4065973ca15df5f

Contents?: true

Size: 940 Bytes

Versions: 36

Compression:

Stored size: 940 Bytes

Contents

#!/usr/bin/env ruby

require 'spec_helper'

describe Puppet::Util do
  describe "#execute" do
    it "should properly allow stdout and stderr to share a file" do
      command = "ruby -e '(1..10).each {|i| (i%2==0) ? $stdout.puts(i) : $stderr.puts(i)}'"

      Puppet::Util::Execution.execute(command, :combine => true).split.should =~ [*'1'..'10']
    end

    it "should return output and set $CHILD_STATUS" do
      command = "ruby -e 'puts \"foo\"; exit 42'"

      output = Puppet::Util::Execution.execute(command, {:failonfail => false})

      output.should == "foo\n"
      $CHILD_STATUS.exitstatus.should == 42
    end

    it "should raise an error if non-zero exit status is returned" do
      command = "ruby -e 'exit 43'"

      expect { Puppet::Util::Execution.execute(command) }.to raise_error(Puppet::ExecutionFailure, /Execution of '#{command}' returned 43: /)
      $CHILD_STATUS.exitstatus.should == 43
    end
  end
end

Version data entries

36 entries across 36 versions & 2 rubygems

Version Path
puppet-3.4.0 spec/integration/util_spec.rb
puppet-3.4.0.rc2 spec/integration/util_spec.rb
puppet-3.4.0.rc1 spec/integration/util_spec.rb
puppet-3.3.2 spec/integration/util_spec.rb
puppet-3.3.1 spec/integration/util_spec.rb
puppet-3.3.1.rc3 spec/integration/util_spec.rb
puppet-3.3.1.rc2 spec/integration/util_spec.rb
puppet-3.3.1.rc1 spec/integration/util_spec.rb
puppet-3.3.0 spec/integration/util_spec.rb
puppet-3.3.0.rc3 spec/integration/util_spec.rb
puppet-3.3.0.rc2 spec/integration/util_spec.rb
puppet-3.2.4 spec/integration/util_spec.rb
puppet-3.2.3 spec/integration/util_spec.rb
puppet-3.2.3.rc1 spec/integration/util_spec.rb
puppet-3.2.2 spec/integration/util_spec.rb
puppet-3.2.1 spec/integration/util_spec.rb
puppet-3.2.1.rc1 spec/integration/util_spec.rb
puppet-3.2.0.rc2 spec/integration/util_spec.rb
librarian-puppet-0.9.9 vendor/gems/ruby/1.9.1/gems/puppet-3.1.0/spec/integration/util_spec.rb
puppet-3.2.0.rc1 spec/integration/util_spec.rb