diff --git a/test/ruby/enc/test_case_comprehensive.rb b/test/ruby/enc/test_case_comprehensive.rb index 2a759cc54d..cd6447e928 100644 --- a/test/ruby/enc/test_case_comprehensive.rb +++ b/test/ruby/enc/test_case_comprehensive.rb @@ -5,7 +5,8 @@ require "test/unit" class TestComprehensiveCaseMapping < Test::Unit::TestCase UNICODE_VERSION = RbConfig::CONFIG['UNICODE_VERSION'] - UNICODE_DATA_PATH = "../../../enc/unicode/data/#{UNICODE_VERSION}" + path = File.expand_path("../../../enc/unicode/data/#{UNICODE_VERSION}", __dir__) + UNICODE_DATA_PATH = File.directory?("#{path}/ucd") ? "#{path}/ucd" : path def self.hex2utf8(s) s.split(' ').map { |c| c.to_i(16) }.pack('U*') diff --git a/test/ruby/enc/test_regex_casefold.rb b/test/ruby/enc/test_regex_casefold.rb index cc525c268e..bc8429c8a9 100644 --- a/test/ruby/enc/test_regex_casefold.rb +++ b/test/ruby/enc/test_regex_casefold.rb @@ -17,7 +17,11 @@ class TestCaseFold < Test::Unit::TestCase end def read_tests - IO.readlines(File.expand_path("../../../enc/unicode/data/#{UNICODE_VERSION}/CaseFolding.txt", __dir__), encoding: Encoding::ASCII_8BIT) + path = "../../../enc/unicode/data/#{UNICODE_VERSION}" + name = "CaseFolding.txt" + (%w[/ucd/ /].any? do |sub| + break IO.readlines(File.expand_path("#{path}#{sub}#{name}", __dir__), encoding: Encoding::ASCII_8BIT) rescue nil + end or raise) .collect.with_index { |linedata, linenumber| [linenumber.to_i+1, linedata.chomp] } .reject { |number, data| data =~ /^(#|$)/ } .collect do |linenumber, linedata|