diff options
author | Kartik Null Cating-Subramanian <ksubramanian@chef.io> | 2015-04-30 20:26:52 -0400 |
---|---|---|
committer | Kartik Null Cating-Subramanian <ksubramanian@chef.io> | 2015-05-01 13:45:11 -0400 |
commit | 6de110e6570e0787b89f44e8c890d318fe905a32 (patch) | |
tree | 2551ad48eae49fd70a7f709682317bd211279863 | |
parent | 2887bd9512be87eef15e4d669f45f310f12ab74f (diff) | |
download | chef-ksubrama/no_env.tar.gz |
Add an integration test of chef-client with empty ENV.ksubrama/no_env
-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 |