diff options
author | Kartik Null Cating-Subramanian <ksubramanian@chef.io> | 2015-04-30 20:26:52 -0400 |
---|---|---|
committer | Bryan McLellan <btm@chef.io> | 2015-05-01 18:44:19 -0400 |
commit | c65ec07f280aa310b1bd63f632fc9fce543165ce (patch) | |
tree | 3212d29f5d427fb8a6978cab16ee234d01f17564 /spec/integration/client/client_spec.rb | |
parent | b49faa5611ec56ff545e05dd896e6bba858c8916 (diff) | |
download | chef-c65ec07f280aa310b1bd63f632fc9fce543165ce.tar.gz |
Add an integration test of chef-client with empty ENV.
Diffstat (limited to 'spec/integration/client/client_spec.rb')
-rw-r--r-- | spec/integration/client/client_spec.rb | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb index b5c5e12781..69822b8a25 100644 --- a/spec/integration/client/client_spec.rb +++ b/spec/integration/client/client_spec.rb @@ -47,6 +47,8 @@ describe "chef-client" do # cf. CHEF-4914 let(:chef_client) { "ruby '#{chef_dir}/chef-client' --minimal-ohai" } + let(:critical_env_vars) { %w(PATH RUBYOPT BUNDLE_GEMFILE).map {|o| "#{o}=#{ENV[o]}"} .join(' ') } + when_the_repository "has a cookbook with a no-op recipe" do before { file 'cookbooks/x/recipes/default.rb', '' } @@ -56,8 +58,23 @@ local_mode true cookbook_path "#{path_to('cookbooks')}" EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir) - result.error! + result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir) + end + + it "should complete successfully with no other environment variables", :skip => (Chef::Platform.windows?) do + file 'config/client.rb', <<EOM +local_mode true +cookbook_path "#{path_to('cookbooks')}" +EOM + + begin + result = shell_out("env -i #{critical_env_vars} #{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir) + result.error! + rescue + Chef::Log.info "Bare invocation will have the following load-path." + Chef::Log.info shell_out!("env -i #{critical_env_vars} ruby -e 'puts $:'").stdout + raise + end end it "should complete successfully with --no-listen" do |