summaryrefslogtreecommitdiff
path: root/tool/lib
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2024-04-17 08:55:08 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2024-04-19 23:06:46 +0900
commitc789e4c493cfd8abde2268b1ca2a0656851e0772 (patch)
tree844d5418e6a7d1b240bde7d5115d30d52e5d8bd5 /tool/lib
parentf17268f7d4fd217e3d79d65527c75c619db8af05 (diff)
Use isolated temporary directory in test-all too for RubyGems tests
Diffstat (limited to 'tool/lib')
-rw-r--r--tool/lib/_tmpdir.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/tool/lib/_tmpdir.rb b/tool/lib/_tmpdir.rb
new file mode 100644
index 0000000000..ddc263b563
--- /dev/null
+++ b/tool/lib/_tmpdir.rb
@@ -0,0 +1,20 @@
+require "tmpdir"
+require "fileutils"
+
+template = "rubytest."
+if (tmpdir = Dir.mktmpdir(template)).size > 50
+ # On macOS, the default TMPDIR is very long, inspite of UNIX socket
+ # path length is limited.
+ Dir.rmdir(tmpdir)
+ tmpdir = Dir.mktmpdir(template, "/tmp")
+end
+# warn "tmpdir(#{tmpdir.size}) = #{tmpdir}"
+
+pid = $$
+END {
+ if pid == $$
+ FileUtils.rm_rf(tmpdir)
+ end
+}
+
+ENV["TMPDIR"] = ENV["SPEC_TEMP_DIR"] = ENV["GEM_TEST_TMPDIR"] = tmpdir