From e22f3bf91f455165f0649ee14cacbfd4347e530f Mon Sep 17 00:00:00 2001 From: normal Date: Wed, 11 Jul 2018 08:33:37 +0000 Subject: test/test_{tempfile,tmpdir}: get rid of leftover files I ran out of inodes in $TMPDIR git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/test_tempfile.rb | 5 ++++- test/test_tmpdir.rb | 14 ++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/test_tempfile.rb b/test/test_tempfile.rb index 8c49498d18..4b31e7f158 100644 --- a/test/test_tempfile.rb +++ b/test/test_tempfile.rb @@ -400,6 +400,9 @@ puts Tempfile.new('foo').path actual = Dir.glob(TRAVERSAL_PATH + '*').count assert_equal expect, actual ensure - t&.close + if t + File.unlink(t.path) + t.close + end end end diff --git a/test/test_tmpdir.rb b/test/test_tmpdir.rb index 202098cefa..eba94056e4 100644 --- a/test/test_tmpdir.rb +++ b/test/test_tmpdir.rb @@ -64,15 +64,17 @@ class TestTmpdir < Test::Unit::TestCase def test_mktmpdir_traversal expect = Dir.glob(TRAVERSAL_PATH + '*').count - Dir.mktmpdir(TRAVERSAL_PATH + 'foo') - actual = Dir.glob(TRAVERSAL_PATH + '*').count - assert_equal expect, actual + Dir.mktmpdir(TRAVERSAL_PATH + 'foo') do + actual = Dir.glob(TRAVERSAL_PATH + '*').count + assert_equal expect, actual + end end def test_mktmpdir_traversal_array expect = Dir.glob(TRAVERSAL_PATH + '*').count - Dir.mktmpdir([TRAVERSAL_PATH, 'foo']) - actual = Dir.glob(TRAVERSAL_PATH + '*').count - assert_equal expect, actual + Dir.mktmpdir([TRAVERSAL_PATH, 'foo']) do + actual = Dir.glob(TRAVERSAL_PATH + '*').count + assert_equal expect, actual + end end end -- cgit v1.2.3