From 5d4bfaccabe66d89460739ee682f1f78698c93a3 Mon Sep 17 00:00:00 2001 From: nagachika Date: Fri, 21 Oct 2022 13:36:03 +0900 Subject: merge revision(s) ab3cb29bd9bff9c16cfb9d19cc02026998282c12: Avoid defining the same test class in multiple files Should fix issues with parallel testing sometimes not running all tests. This should be viewed skipping whitespace changes. Fixes [Bug #18731] --- test/-ext-/bignum/test_big2str.rb | 38 +- test/-ext-/bignum/test_bigzero.rb | 20 +- test/-ext-/bignum/test_div.rb | 38 +- test/-ext-/bignum/test_mul.rb | 260 ++++++------ test/-ext-/bignum/test_pack.rb | 653 +++++++++++++++---------------- test/-ext-/bignum/test_str2big.rb | 52 ++- test/-ext-/funcall/test_funcall.rb | 11 - test/-ext-/funcall/test_passing_block.rb | 5 + test/date/test_date_ractor.rb | 2 +- test/fileutils/clobber.rb | 5 +- test/fileutils/test_dryrun.rb | 2 +- test/fileutils/test_nowrite.rb | 2 +- test/fileutils/test_verbose.rb | 2 +- test/fileutils/visibility_tests.rb | 5 +- test/mkmf/base.rb | 225 ++++++----- test/mkmf/test_config.rb | 16 +- test/mkmf/test_constant.rb | 56 ++- test/mkmf/test_convertible.rb | 48 ++- test/mkmf/test_egrep_cpp.rb | 14 +- test/mkmf/test_find_executable.rb | 82 ++-- test/mkmf/test_flags.rb | 92 +++-- test/mkmf/test_framework.rb | 70 ++-- test/mkmf/test_have_func.rb | 18 +- test/mkmf/test_have_library.rb | 84 ++-- test/mkmf/test_have_macro.rb | 46 ++- test/mkmf/test_install.rb | 38 +- test/mkmf/test_libs.rb | 156 ++++---- test/mkmf/test_mkmf.rb | 14 +- test/mkmf/test_pkg_config.rb | 98 +++-- test/mkmf/test_signedness.rb | 38 +- test/mkmf/test_sizeof.rb | 74 ++-- test/optparse/test_acceptable.rb | 2 +- test/optparse/test_autoconf.rb | 4 +- test/optparse/test_bash_completion.rb | 4 +- test/optparse/test_cclass.rb | 2 +- test/optparse/test_did_you_mean.rb | 2 +- test/optparse/test_getopts.rb | 4 +- test/optparse/test_kwargs.rb | 4 +- test/optparse/test_noarg.rb | 6 +- test/optparse/test_optarg.rb | 2 +- test/optparse/test_placearg.rb | 2 +- test/optparse/test_reqarg.rb | 10 +- test/optparse/test_summary.rb | 2 +- test/optparse/test_zsh_completion.rb | 4 +- test/ruby/enc/test_emoji_breaks.rb | 207 +++++----- test/ruby/enc/test_grapheme_breaks.rb | 115 +++--- test/ruby/test_inlinecache.rb | 2 +- 47 files changed, 1280 insertions(+), 1356 deletions(-) delete mode 100644 test/-ext-/funcall/test_funcall.rb --- test/ruby/enc/test_grapheme_breaks.rb | 115 +++++++++++++++++----------------- test/ruby/test_inlinecache.rb | 2 +- 2 files changed, 57 insertions(+), 60 deletions(-) (limited to 'test/ruby') diff --git a/test/ruby/enc/test_grapheme_breaks.rb b/test/ruby/enc/test_grapheme_breaks.rb index 2d210946a9..e8f3aa04a7 100644 --- a/test/ruby/enc/test_grapheme_breaks.rb +++ b/test/ruby/enc/test_grapheme_breaks.rb @@ -4,31 +4,28 @@ require "test/unit" class TestGraphemeBreaksFromFile < Test::Unit::TestCase -end - -class TestGraphemeBreaksFromFile::BreakTest - attr_reader :clusters, :string, :comment, :line_number + class BreakTest + attr_reader :clusters, :string, :comment, :line_number - def initialize(line_number, data, comment) - @line_number = line_number - @comment = comment - @clusters = data.sub(/\A\s*÷\s*/, '') - .sub(/\s*÷\s*\z/, '') - .split(/\s*÷\s*/) - .map do |cl| - cl.split(/\s*×\s*/) - .map do |ch| - c = ch.to_i(16) - # eliminate cases with surrogates - raise ArgumentError if 0xD800 <= c and c <= 0xDFFF - c.chr('UTF-8') - end.join - end - @string = @clusters.join + def initialize(line_number, data, comment) + @line_number = line_number + @comment = comment + @clusters = data.sub(/\A\s*÷\s*/, '') + .sub(/\s*÷\s*\z/, '') + .split(/\s*÷\s*/) + .map do |cl| + cl.split(/\s*×\s*/) + .map do |ch| + c = ch.to_i(16) + # eliminate cases with surrogates + raise ArgumentError if 0xD800 <= c and c <= 0xDFFF + c.chr('UTF-8') + end.join + end + @string = @clusters.join + end end -end -class TestGraphemeBreaksFromFile < Test::Unit::TestCase UNICODE_VERSION = RbConfig::CONFIG['UNICODE_VERSION'] path = File.expand_path("../../../enc/unicode/data/#{UNICODE_VERSION}", __dir__) UNICODE_DATA_PATH = File.directory?("#{path}/ucd/auxiliary") ? "#{path}/ucd/auxiliary" : path @@ -43,53 +40,53 @@ class TestGraphemeBreaksFromFile < Test::Unit::TestCase skip "Unicode data file GraphemeBreakTest not available in #{UNICODE_DATA_PATH}." end end -end -TestGraphemeBreaksFromFile.file_available? and class TestGraphemeBreaksFromFile - def read_data - tests = [] - IO.foreach(GRAPHEME_BREAK_TEST_FILE, encoding: Encoding::UTF_8) do |line| - if $. == 1 and not line.start_with?("# GraphemeBreakTest-#{UNICODE_VERSION}.txt") - raise "File Version Mismatch" + if file_available? + def read_data + tests = [] + IO.foreach(GRAPHEME_BREAK_TEST_FILE, encoding: Encoding::UTF_8) do |line| + if $. == 1 and not line.start_with?("# GraphemeBreakTest-#{UNICODE_VERSION}.txt") + raise "File Version Mismatch" + end + next if /\A#/.match? line + tests << BreakTest.new($., *line.chomp.split('#')) rescue 'whatever' end - next if /\A#/.match? line - tests << BreakTest.new($., *line.chomp.split('#')) rescue 'whatever' + tests end - tests - end - def all_tests - @@tests ||= read_data - rescue Errno::ENOENT - @@tests ||= [] - end + def all_tests + @@tests ||= read_data + rescue Errno::ENOENT + @@tests ||= [] + end - def test_each_grapheme_cluster - all_tests.each do |test| - expected = test.clusters - actual = test.string.each_grapheme_cluster.to_a - assert_equal expected, actual, - "line #{test.line_number}, expected '#{expected}', " + - "but got '#{actual}', comment: #{test.comment}" + def test_each_grapheme_cluster + all_tests.each do |test| + expected = test.clusters + actual = test.string.each_grapheme_cluster.to_a + assert_equal expected, actual, + "line #{test.line_number}, expected '#{expected}', " + + "but got '#{actual}', comment: #{test.comment}" + end end - end - def test_backslash_X - all_tests.each do |test| - clusters = test.clusters.dup - string = test.string.dup - removals = 0 - while string.sub!(/\A\X/, '') - removals += 1 - clusters.shift - expected = clusters.join + def test_backslash_X + all_tests.each do |test| + clusters = test.clusters.dup + string = test.string.dup + removals = 0 + while string.sub!(/\A\X/, '') + removals += 1 + clusters.shift + expected = clusters.join + assert_equal expected, string, + "line #{test.line_number}, removals: #{removals}, expected '#{expected}', " + + "but got '#{string}', comment: #{test.comment}" + end assert_equal expected, string, - "line #{test.line_number}, removals: #{removals}, expected '#{expected}', " + + "line #{test.line_number}, after last removal, expected '#{expected}', " + "but got '#{string}', comment: #{test.comment}" end - assert_equal expected, string, - "line #{test.line_number}, after last removal, expected '#{expected}', " + - "but got '#{string}', comment: #{test.comment}" end end end diff --git a/test/ruby/test_inlinecache.rb b/test/ruby/test_inlinecache.rb index 6c2d86aefd..d48d95d74e 100644 --- a/test/ruby/test_inlinecache.rb +++ b/test/ruby/test_inlinecache.rb @@ -3,7 +3,7 @@ require 'test/unit' -class TestMethod < Test::Unit::TestCase +class TestMethodInlineCache < Test::Unit::TestCase def test_alias m0 = Module.new do def foo; :M0 end -- cgit v1.2.3