ruby-changes:62938
From: Nobuyoshi <ko1@a...>
Date: Mon, 14 Sep 2020 18:28:37 +0900 (JST)
Subject: [ruby-changes:62938] f7f849e30c (master): [ruby/tmpdir] Test also TMP and TEMP environment variables
https://git.ruby-lang.org/ruby.git/commit/?id=f7f849e30c From f7f849e30cbf462e521b0843a9bb2cbea1bd4d11 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Mon, 13 Jul 2020 19:44:52 +0900 Subject: [ruby/tmpdir] Test also TMP and TEMP environment variables https://github.com/ruby/tmpdir/commit/414c00ebe6 diff --git a/test/test_tmpdir.rb b/test/test_tmpdir.rb index 5cd0b5e..039b5be 100644 --- a/test/test_tmpdir.rb +++ b/test/test_tmpdir.rb @@ -15,21 +15,26 @@ class TestTmpdir < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_tmpdir.rb#L15 skip "no meaning on this platform" if /mswin|mingw/ =~ RUBY_PLATFORM Dir.mktmpdir do |tmpdir| # ToDo: fix for parallel test - olddir, ENV["TMPDIR"] = ENV["TMPDIR"], tmpdir + envs = %w[TMPDIR TMP TEMP] + oldenv = envs.each_with_object({}) {|v, h| h[v] = ENV.delete(v)} begin - assert_equal(tmpdir, Dir.tmpdir) - File.chmod(0777, tmpdir) - assert_not_equal(tmpdir, Dir.tmpdir) - newdir = Dir.mktmpdir("d", tmpdir) do |dir| - assert_file.directory? dir - assert_equal(tmpdir, File.dirname(dir)) - dir + envs.each do |e| + ENV[e] = tmpdir + assert_equal(tmpdir, Dir.tmpdir) + File.chmod(0777, tmpdir) + assert_not_equal(tmpdir, Dir.tmpdir) + newdir = Dir.mktmpdir("d", tmpdir) do |dir| + assert_file.directory? dir + assert_equal(tmpdir, File.dirname(dir)) + dir + end + assert_file.not_exist?(newdir) + File.chmod(01777, tmpdir) + assert_equal(tmpdir, Dir.tmpdir) + ENV[e] = nil end - assert_file.not_exist?(newdir) - File.chmod(01777, tmpdir) - assert_equal(tmpdir, Dir.tmpdir) ensure - ENV["TMPDIR"] = olddir + ENV.update(oldenv) end end end -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/