From 6de110e6570e0787b89f44e8c890d318fe905a32 Mon Sep 17 00:00:00 2001 From: Kartik Null Cating-Subramanian Date: Thu, 30 Apr 2015 20:26:52 -0400 Subject: Add an integration test of chef-client with empty ENV. --- spec/integration/client/client_spec.rb | 21 +++++++++++++++++++-- 1 file 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', < 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 -- cgit v1.2.1