From c6940be8d454571cb76f36e177d31c9565728260 Mon Sep 17 00:00:00 2001 From: Clinton Wolfe Date: Thu, 11 Apr 2019 15:30:30 -0400 Subject: [PATCH] Make license touching for functional and int testing portable to windows Signed-off-by: Clinton Wolfe --- Rakefile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Rakefile b/Rakefile index 795fe78d1..e44cc9897 100644 --- a/Rakefile +++ b/Rakefile @@ -8,6 +8,7 @@ require 'passgen' require 'train' require_relative 'tasks/maintainers' require_relative 'tasks/spdx' +require 'fileutils' Bundler::GemHelper.install_tasks name: 'inspec' @@ -71,21 +72,21 @@ namespace :test do end task :accept_license do - sh 'mkdir -p $HOME/.chef/accepted_licenses' + FileUtils.mkdir_p(File.join(Dir.home, '.chef', 'accepted_licenses') # If the user has not accepted the license, touch the acceptance # file, but also touch a marker that it is only for testing. unless File.exist?(File.join(Dir.home, '.chef', 'accepted_licenses', 'inspec')) puts "\n\nTemporarily accepting Chef user license for the duration of testing...\n" - sh 'touch $HOME/.chef/accepted_licenses/inspec' - sh 'touch $HOME/.chef/accepted_licenses/inspec.for_testing' + FileUtils.touch(File.join(Dir.home, '.chef', 'accepted_licenses', 'inspec') + FileUtils.touch(File.join(Dir.home, '.chef', 'accepted_licenses', 'inspec.for_testing') end # Regardless of what happens, when this process exits, check for cleanup. at_exit do if File.exist?(File.join(Dir.home, '.chef', 'accepted_licenses', 'inspec.for_testing')) puts "\n\nRemoving temporary Chef user license acceptance file that was placed for test duration.\n" - sh 'rm -f $HOME/.chef/accepted_licenses/inspec' - sh 'rm -f $HOME/.chef/accepted_licenses/inspec.for_testing' + FileUtils.rm_f(File.join(Dir.home, '.chef', 'accepted_licenses', 'inspec') + FileUtils.rm_f(File.join(Dir.home, '.chef', 'accepted_licenses', 'inspec.for_testing') end end end