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