Skip to content

Commit

Permalink
Improve CacheTest#test_path_encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
byroot committed Jan 17, 2022
1 parent 1da7c3c commit 8ddb820
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/load_path_cache/cache_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,12 @@ def test_path_obj_equal?
OS_ASCII_PATH_ENCODING = RUBY_VERSION >= "3.1" ? Encoding::UTF_8 : Encoding::US_ASCII

def test_path_encoding
unless Encoding.default_external == Encoding::UTF_8
# Encoding.default_external != Encoding::UTF_8 is likely a misconfiguration or a barebone system.
# Supporting this use case would have an overhead for relatively little gain.
skip "Encoding.default_external == #{Encoding.default_external}, expected Encoding::UTF_8."
end

po = [@dir1]
cache = Cache.new(NullCache, po)

Expand All @@ -176,9 +182,9 @@ def test_path_encoding
assert_same path, internal_path

utf8_path = cache.find("béé")
assert_equal("#{@dir1}/béé.rb", utf8_path)
require utf8_path
internal_utf8_path = $LOADED_FEATURES.last
assert_equal("#{@dir1}/béé.rb", utf8_path)
assert_equal(Encoding::UTF_8, internal_utf8_path.encoding)
assert_equal(Encoding::UTF_8, utf8_path.encoding)
File.write(utf8_path, "")
Expand Down

0 comments on commit 8ddb820

Please sign in to comment.