Sha256: ec83d369504299315e1f9d6b27a6423234adfa72a150257b1ac65e2ff0b77f48

Contents?: true

Size: 1.83 KB

Versions: 39

Compression:

Stored size: 1.83 KB

Contents

#! /usr/bin/env ruby
require 'spec_helper'

describe Puppet::Type.type(:exec).provider(:shell), :unless => Puppet.features.microsoft_windows? do
  let(:resource) { Puppet::Type.type(:exec).new(:title => 'foo', :provider => 'shell') }
  let(:provider) { described_class.new(resource) }

  describe "#run" do
    it "should be able to run builtin shell commands" do
      output, status = provider.run("if [ 1 = 1 ]; then echo 'blah'; fi")
      status.exitstatus.should == 0
      output.should == "blah\n"
    end

    it "should be able to run commands with single quotes in them" do
      output, status = provider.run("echo 'foo  bar'")
      status.exitstatus.should == 0
      output.should == "foo  bar\n"
    end

    it "should be able to run commands with double quotes in them" do
      output, status = provider.run('echo "foo  bar"')
      status.exitstatus.should == 0
      output.should == "foo  bar\n"
    end

    it "should be able to run multiple commands separated by a semicolon" do
      output, status = provider.run("echo 'foo' ; echo 'bar'")
      status.exitstatus.should == 0
      output.should == "foo\nbar\n"
    end

    it "should be able to read values from the environment parameter" do
      resource[:environment] = "FOO=bar"
      output, status = provider.run("echo $FOO")
      status.exitstatus.should == 0
      output.should == "bar\n"
    end

    it "#14060: should interpolate inside the subshell, not outside it" do
      resource[:environment] = "foo=outer"
      output, status = provider.run("foo=inner; echo \"foo is $foo\"")
      status.exitstatus.should == 0
      output.should == "foo is inner\n"
    end
  end

  describe "#validatecmd" do
    it "should always return true because builtins don't need path or to be fully qualified" do
      provider.validatecmd('whateverdoesntmatter').should == true
    end
  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
puppet-3.8.7 spec/unit/provider/exec/shell_spec.rb
puppet-3.8.7-x86-mingw32 spec/unit/provider/exec/shell_spec.rb
puppet-3.8.7-x64-mingw32 spec/unit/provider/exec/shell_spec.rb
puppet-3.8.6 spec/unit/provider/exec/shell_spec.rb
puppet-3.8.6-x86-mingw32 spec/unit/provider/exec/shell_spec.rb
puppet-3.8.6-x64-mingw32 spec/unit/provider/exec/shell_spec.rb
puppet-3.8.5 spec/unit/provider/exec/shell_spec.rb
puppet-3.8.5-x86-mingw32 spec/unit/provider/exec/shell_spec.rb
puppet-3.8.5-x64-mingw32 spec/unit/provider/exec/shell_spec.rb
puppet-3.8.4 spec/unit/provider/exec/shell_spec.rb
puppet-3.8.4-x86-mingw32 spec/unit/provider/exec/shell_spec.rb
puppet-3.8.4-x64-mingw32 spec/unit/provider/exec/shell_spec.rb
puppet-3.8.3 spec/unit/provider/exec/shell_spec.rb
puppet-3.8.3-x86-mingw32 spec/unit/provider/exec/shell_spec.rb
puppet-3.8.3-x64-mingw32 spec/unit/provider/exec/shell_spec.rb
puppet-3.8.2 spec/unit/provider/exec/shell_spec.rb
puppet-3.8.2-x86-mingw32 spec/unit/provider/exec/shell_spec.rb
puppet-3.8.2-x64-mingw32 spec/unit/provider/exec/shell_spec.rb
puppet-3.8.1 spec/unit/provider/exec/shell_spec.rb
puppet-3.8.1-x86-mingw32 spec/unit/provider/exec/shell_spec.rb