From 10b96900b90914b0cc1dba36f9736c038db2859d Mon Sep 17 00:00:00 2001 From: hsbt Date: Wed, 28 Mar 2018 10:03:03 +0000 Subject: Ignore file separator from tmpfile/tmpdir name. From: SHIBATA Hiroshi git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62990 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/test_tempfile.rb | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'test/test_tempfile.rb') diff --git a/test/test_tempfile.rb b/test/test_tempfile.rb index 63f5468638..ef035e358b 100644 --- a/test/test_tempfile.rb +++ b/test/test_tempfile.rb @@ -373,5 +373,31 @@ puts Tempfile.new('foo').path } assert_file.not_exist?(path) end -end + TRAVERSAL_PATH = Array.new(Dir.pwd.split('/').count, '..').join('/') + Dir.pwd + '/' + + def test_open_traversal_dir + expect = Dir.glob(TRAVERSAL_PATH + '*').count + t = Tempfile.open([TRAVERSAL_PATH, 'foo']) + actual = Dir.glob(TRAVERSAL_PATH + '*').count + assert_equal expect, actual + ensure + t.close! + end + + def test_new_traversal_dir + expect = Dir.glob(TRAVERSAL_PATH + '*').count + t = Tempfile.new(TRAVERSAL_PATH + 'foo') + actual = Dir.glob(TRAVERSAL_PATH + '*').count + assert_equal expect, actual + ensure + t.close! + end + + def test_create_traversal_dir + expect = Dir.glob(TRAVERSAL_PATH + '*').count + Tempfile.create(TRAVERSAL_PATH + 'foo') + actual = Dir.glob(TRAVERSAL_PATH + '*').count + assert_equal expect, actual + end +end -- cgit v1.2.3