diff options
Diffstat (limited to 'features/steps/run_solo.rb')
-rw-r--r-- | features/steps/run_solo.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/features/steps/run_solo.rb b/features/steps/run_solo.rb index b2b244cfb6..e1fea20253 100644 --- a/features/steps/run_solo.rb +++ b/features/steps/run_solo.rb @@ -40,3 +40,39 @@ When /^I run chef-solo with the '(.+)' recipe$/ do |recipe_name| print_output if ENV['LOG_LEVEL'] == 'debug' end + + +# This is kind of a crazy-ass setup, but it works. +When /^I run chef-solo without cookbooks$/ do + + # Set up the cache dir. + cache_dir = "#{tmpdir}/chef-solo-cache-features" + system("mkdir -p #{cache_dir}") + cleanup_dirs << cache_dir + + # Empty Cookbook dir + system("mkdir #{cache_dir}/cookbooks") + + # Config file + config_file = "#{tmpdir}/chef-solo-config-features.rb" + File.open(config_file, "w") do |fp| + fp.write("cookbook_path \"#{cache_dir}/cookbooks\"\n") + fp.write("file_cache_path \"#{cache_dir}/cookbooks\"\n") + end + cleanup_files << config_file + + binary_path = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'chef', 'bin', 'chef-solo')) + command = "#{binary_path} -c #{config_file}" + command += " -l debug" if ENV['LOG_LEVEL'] == 'debug' + + # Run it + puts "Running solo: #{command}" if ENV['LOG_LEVEL'] == 'debug' + + status = Chef::Mixin::Command.popen4(command) do |p, i, o, e| + @stdout = o.gets(nil) + @stderr = o.gets(nil) + end + @status = status + + print_output if ENV['LOG_LEVEL'] == 'debug' +end
\ No newline at end of file |