From 3010b4047727a17fe5b09df15ee3ea1b7efc2cc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20D=C3=BCrst?= Date: Tue, 27 Jul 2021 17:05:06 +0900 Subject: [PATCH] Adjust test/ruby/enc/test_emoji_breaks.rb to handle Emoji Version 13.1 Deal with the issue that the emoji files in emoji/13.1 have Unicode Emoji version 13.1, but at the same time the files in 13.0.0/ucd/emoji are still at Emoji version 13.0. Specifically: - Add a version attribute to TestEmojiBreaks::BreakFile - Take the version for emoji-variant-sequences.txt from the Unicode version, removing the last two characters. - Improve information in exceptions for file name and version mismatches. --- test/ruby/enc/test_emoji_breaks.rb | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test/ruby/enc/test_emoji_breaks.rb b/test/ruby/enc/test_emoji_breaks.rb index 8f73a728d6..e765b10233 100644 --- a/test/ruby/enc/test_emoji_breaks.rb +++ b/test/ruby/enc/test_emoji_breaks.rb @@ -32,12 +32,13 @@ class TestEmojiBreaks::BreakTest end class TestEmojiBreaks::BreakFile - attr_reader :basename, :fullname + attr_reader :basename, :fullname, :version FILES = [] - def initialize(basename, path) + def initialize(basename, path, version) @basename = basename @fullname = "#{path}/#{basename}.txt" # File.expand_path(path + version, __dir__) + @version = version FILES << self end @@ -53,9 +54,9 @@ class TestEmojiBreaks < Test::Unit::TestCase EMOJI_DATA_PATH = File.expand_path("../../../enc/unicode/data/emoji/#{EMOJI_VERSION}", __dir__) EMOJI_DATA_FILES = %w[emoji-sequences emoji-test emoji-zwj-sequences].map do |basename| - BreakFile.new(basename, EMOJI_DATA_PATH) + BreakFile.new(basename, EMOJI_DATA_PATH, EMOJI_VERSION) end - UNICODE_DATA_FILE = BreakFile.new('emoji-variation-sequences', UNICODE_DATA_PATH) + UNICODE_DATA_FILE = BreakFile.new('emoji-variation-sequences', UNICODE_DATA_PATH, UNICODE_VERSION[0..-3]) # [0..-3] deals with a versioning mismatch problem in Unicode EMOJI_DATA_FILES << UNICODE_DATA_FILE def self.data_files_available? @@ -80,12 +81,12 @@ TestEmojiBreaks.data_files_available? and class TestEmojiBreaks file_tests = [] IO.foreach(file.fullname, encoding: Encoding::UTF_8) do |line| line.chomp! - raise "File Name Mismatch" if $.==1 and not line=="# #{file.basename}.txt" - version_mismatch = false if line=="# Version: #{EMOJI_VERSION}" + raise "File Name Mismatch: line: #{line}, expected filename: #{file.basename}.txt" if $.==1 and not line=="# #{file.basename}.txt" + version_mismatch = false if line =~ /^# Version: #{file.version}/ next if /\A(#|\z)/.match? line file_tests << BreakTest.new(file.basename, $., *line.split('#')) rescue 'whatever' end - raise "File Version Mismatch" if version_mismatch + raise "File Version Mismatch: file: #{file.fullname}, version: #{file.version}" if version_mismatch tests += file_tests end tests