Skip to content

Commit

Permalink
Windows simply causes an error to open invalid path
Browse files Browse the repository at this point in the history
  • Loading branch information
unak committed May 1, 2019
1 parent fc3e80c commit dcb6a6a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion test/test_tempfile.rb
Expand Up @@ -381,15 +381,27 @@ def test_open_traversal_dir
t = Tempfile.open([TRAVERSAL_PATH, 'foo'])
actual = Dir.glob(TRAVERSAL_PATH + '*').count
assert_equal expect, actual
rescue Errno::EINVAL
if /mswin|mingw/ =~ RUBY_PLATFORM
assert "ok"
else
raise $!
end
ensure
t.close!
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
rescue Errno::EINVAL
if /mswin|mingw/ =~ RUBY_PLATFORM
assert "ok"
else
raise $!
end
ensure
t&.close!
end
Expand All @@ -399,6 +411,12 @@ def test_create_traversal_dir
t = Tempfile.create(TRAVERSAL_PATH + 'foo')
actual = Dir.glob(TRAVERSAL_PATH + '*').count
assert_equal expect, actual
rescue Errno::EINVAL
if /mswin|mingw/ =~ RUBY_PLATFORM
assert "ok"
else
raise $!
end
ensure
if t
t.close
Expand Down

0 comments on commit dcb6a6a

Please sign in to comment.