summaryrefslogtreecommitdiff
path: root/tool
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2020-12-03 21:33:31 -0800
committerTakashi Kokubun <takashikkbn@gmail.com>2020-12-03 21:33:35 -0800
commitf1757a88a4c8e2a50481de020787b37d926463df (patch)
treeb190ec9b1d10a75bb3a9366e4c6f46f2389eba86 /tool
parent30fba5f37d9058cc7e4d852ff211313f13ded3a1 (diff)
Avoid leaving too many core files in /tmp
for CIs like ci.rvm.jp.
Diffstat (limited to 'tool')
-rw-r--r--tool/lib/test/unit.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb
index 33466bdc96..888905b36c 100644
--- a/tool/lib/test/unit.rb
+++ b/tool/lib/test/unit.rb
@@ -348,7 +348,13 @@ module Test
if File.exist?('core')
require 'fileutils'
require 'time'
- core_path = "/tmp/core.#{Time.now.utc.iso8601}"
+ Dir.glob('/tmp/test-unit-core.*').each do |f|
+ if Time.now - File.mtime(f) > 7 * 24 * 60 * 60 # 7 days
+ warn "Deleting an old core file: #{f}"
+ FileUtils.rm(f)
+ end
+ end
+ core_path = "/tmp/test-unit-core.#{Time.now.utc.iso8601}"
warn "A core file is found. Saving it at: #{core_path.dump}"
FileUtils.mv('core', core_path)
end