From f1757a88a4c8e2a50481de020787b37d926463df Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Thu, 3 Dec 2020 21:33:31 -0800 Subject: Avoid leaving too many core files in /tmp for CIs like ci.rvm.jp. --- tool/lib/test/unit.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tool') 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 -- cgit v1.2.3