diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-04-28 19:00:33 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-04-28 19:00:33 +0900 |
commit | 86431f5075d0495783776b0d7f162df387e7cde6 (patch) | |
tree | 5e021b2b94339804e450bbcf1cbec1654bb10a55 /spec | |
parent | 3497152515693cb3898bf3aea502f6e162ffe21f (diff) | |
download | ruby-86431f5075d0495783776b0d7f162df387e7cde6.tar.gz |
Remove rubyspec temporary directories
Diffstat (limited to 'spec')
-rw-r--r-- | spec/mspec/lib/mspec/helpers/tmp.rb | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/spec/mspec/lib/mspec/helpers/tmp.rb b/spec/mspec/lib/mspec/helpers/tmp.rb index 5062991d63..433c0b6d88 100644 --- a/spec/mspec/lib/mspec/helpers/tmp.rb +++ b/spec/mspec/lib/mspec/helpers/tmp.rb @@ -4,13 +4,25 @@ # directory is empty when the process exits. SPEC_TEMP_DIR_PID = Process.pid -SPEC_TEMP_DIR = File.expand_path(ENV["SPEC_TEMP_DIR"] || "rubyspec_temp/#{SPEC_TEMP_DIR_PID}") +SPEC_TEMP_DIR_LIST = [] +if tmpdir = ENV['SPEC_TEMP_DIR'] + temppath = File.expand_path(tmpdir) + "/" +else + tmpdir = File.expand_path("rubyspec_temp") + temppath = tmpdir + "/#{SPEC_TEMP_DIR_PID}" + SPEC_TEMP_DIR_LIST << tmpdir +end +SPEC_TEMP_DIR_LIST << temppath +SPEC_TEMP_DIR = temppath SPEC_TEMP_UNIQUIFIER = "0" at_exit do begin if SPEC_TEMP_DIR_PID == Process.pid - Dir.delete SPEC_TEMP_DIR if File.directory? SPEC_TEMP_DIR + while temppath = SPEC_TEMP_DIR_LIST.pop + next unless File.directory? temppath + Dir.delete temppath + end end rescue SystemCallError STDERR.puts <<-EOM @@ -18,7 +30,7 @@ at_exit do ----------------------------------------------------- The rubyspec temp directory is not empty. Ensure that all specs are cleaning up temporary files: - #{SPEC_TEMP_DIR} + #{temppath} ----------------------------------------------------- EOM |