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]
This commit is contained in:
Jeremy Evans 2022-04-22 13:01:43 -07:00
parent c2d38a0d2d
commit ab3cb29bd9
Notes: git 2022-04-23 07:00:43 +09:00
47 changed files with 1282 additions and 1358 deletions

View File

@ -2,8 +2,7 @@
require 'test/unit'
require "-test-/bignum"
class Test_Bignum < Test::Unit::TestCase
class TestBig2str < Test::Unit::TestCase
class TestBignum_Big2str < Test::Unit::TestCase
SIZEOF_BDIGIT = Bug::Bignum::SIZEOF_BDIGIT
BITSPERDIG = Bug::Bignum::BITSPERDIG
@ -27,4 +26,3 @@ class Test_Bignum < Test::Unit::TestCase
end
end
end

View File

@ -2,8 +2,7 @@
require 'test/unit'
require "-test-/bignum"
class Test_Bignum < Test::Unit::TestCase
class TestBigZero < Test::Unit::TestCase
class TestBignum_BigZero < Test::Unit::TestCase
def test_equal_0
bug8204 = '[ruby-core:53893] [Bug #8204]'
(0..10).each do |i|
@ -17,4 +16,3 @@ class Test_Bignum < Test::Unit::TestCase
end
end
end
end

View File

@ -2,8 +2,7 @@
require 'test/unit'
require "-test-/bignum"
class Test_Bignum < Test::Unit::TestCase
class TestDiv < Test::Unit::TestCase
class TestBignum_Div < Test::Unit::TestCase
SIZEOF_BDIGIT = Bug::Bignum::SIZEOF_BDIGIT
BITSPERDIG = Bug::Bignum::BITSPERDIG
@ -26,4 +25,3 @@ class Test_Bignum < Test::Unit::TestCase
rescue NotImplementedError
end
end
end

View File

@ -2,8 +2,7 @@
require 'test/unit'
require "-test-/bignum"
class Test_Bignum < Test::Unit::TestCase
class TestMul < Test::Unit::TestCase
class TestBignum_Mul < Test::Unit::TestCase
SIZEOF_BDIGIT = Bug::Bignum::SIZEOF_BDIGIT
BITSPERDIG = Bug::Bignum::BITSPERDIG
@ -135,4 +134,3 @@ class Test_Bignum < Test::Unit::TestCase
end
end
end

View File

@ -4,8 +4,7 @@
require 'test/unit'
require "-test-/bignum"
class Test_Bignum < Test::Unit::TestCase
class TestPack < Test::Unit::TestCase
class TestBignum_Pack < Test::Unit::TestCase
MSWORD_FIRST = Bug::Bignum::INTEGER_PACK_MSWORD_FIRST
LSWORD_FIRST = Bug::Bignum::INTEGER_PACK_LSWORD_FIRST
@ -346,7 +345,6 @@ class Test_Bignum < Test::Unit::TestCase
"Bug::Bignum.test_unpack(#{str.dump}, #{n}, 1, 0, #{'%#x' % flags})")
}
end
end
def test_numbits_2comp
assert_equal(4, Bug::Bignum.test_numbits_2comp_without_sign(-9))
@ -395,5 +393,4 @@ class Test_Bignum < Test::Unit::TestCase
assert_equal(5, Bug::Bignum.test_numbytes_2comp_with_sign(0x7fffffffff))
assert_equal(6, Bug::Bignum.test_numbytes_2comp_with_sign(0x8000000000))
end
end

View File

@ -2,8 +2,7 @@
require 'test/unit'
require "-test-/bignum"
class Test_Bignum < Test::Unit::TestCase
class TestStr2big < Test::Unit::TestCase
class TestBignum_Str2big < Test::Unit::TestCase
SIZEOF_BDIGIT = Bug::Bignum::SIZEOF_BDIGIT
BITSPERDIG = Bug::Bignum::BITSPERDIG
@ -35,4 +34,3 @@ class Test_Bignum < Test::Unit::TestCase
end
end
end

View File

@ -1,11 +0,0 @@
# frozen_string_literal: true
require 'test/unit'
class TestFuncall < Test::Unit::TestCase
require '-test-/funcall'
def test_funcall_extra_args
assert_equal 'TestFuncall', TestFuncall.extra_args_name,
'[ruby-core:85266] [Bug #14425]'
end
end

View File

@ -9,6 +9,11 @@ class TestFuncall < Test::Unit::TestCase
end
require '-test-/funcall'
def test_funcall_extra_args
assert_equal 'TestFuncall', TestFuncall.extra_args_name,
'[ruby-core:85266] [Bug #14425]'
end
def test_with_funcall2
ok = nil
Relay.with_funcall2("feature#4504") {|arg| ok = arg || true}

View File

@ -2,7 +2,7 @@
require 'test/unit'
require 'date'
class TestDateParse < Test::Unit::TestCase
class TestDateParseRactor < Test::Unit::TestCase
def code(klass = Date, share: false)
<<~RUBY.gsub('Date', klass.name)
share = #{share}

View File

@ -4,10 +4,7 @@ require 'test/unit'
require 'tmpdir'
require_relative 'fileasserts'
class TestFileUtils < Test::Unit::TestCase
end
module TestFileUtils::Clobber
module TestFileUtilsClobber
include Test::Unit::FileAssertions
def my_rm_rf(path)

View File

@ -8,7 +8,7 @@ require_relative 'visibility_tests'
class TestFileUtilsDryRun < Test::Unit::TestCase
include FileUtils::DryRun
include TestFileUtilsInc::Visibility
include TestFileUtilsIncVisibility
def setup
super

View File

@ -8,7 +8,7 @@ require_relative 'visibility_tests'
class TestFileUtilsNoWrite < Test::Unit::TestCase
include FileUtils::NoWrite
include TestFileUtilsInc::Visibility
include TestFileUtilsIncVisibility
def setup
super

View File

@ -8,7 +8,7 @@ require_relative 'visibility_tests'
class TestFileUtilsVerbose < Test::Unit::TestCase
include FileUtils::Verbose
include TestFileUtilsInc::Visibility
include TestFileUtilsIncVisibility
def setup
super

View File

@ -2,14 +2,11 @@
require 'test/unit'
require 'fileutils'
class TestFileUtilsInc < Test::Unit::TestCase
end
##
# These tests are reused in the FileUtils::Verbose, FileUtils::NoWrite and
# FileUtils::DryRun tests
module TestFileUtilsInc::Visibility
module TestFileUtilsIncVisibility
FileUtils::METHODS.each do |m|
define_method "test_singleton_visibility_#{m}" do

View File

@ -20,9 +20,7 @@ $INCFLAGS << " -I."
$extout_prefix = "$(extout)$(target_prefix)/"
class TestMkmf < Test::Unit::TestCase
end
module TestMkmf::Base
module Base
MKMFLOG = proc {File.read("mkmf.log") rescue ""}
class Capture
@ -146,8 +144,7 @@ module TestMkmf::Base
end
end
class TestMkmf
include TestMkmf::Base
include Base
def assert_separately(args, src, *rest, **options)
super(args + ["-r#{__FILE__}"], "extend TestMkmf::Base; setup\nEND{teardown}\n#{src}", *rest, **options)

View File

@ -4,8 +4,7 @@ $extmk = true
require 'test/unit'
require 'mkmf'
class TestMkmf < Test::Unit::TestCase
class TestConfig < Test::Unit::TestCase
class TestMkmfConfig < Test::Unit::TestCase
def test_dir_config
bug8074 = '[Bug #8074]'
lib = RbConfig.expand(RbConfig::MAKEFILE_CONFIG["libdir"], "exec_prefix"=>"")
@ -14,4 +13,3 @@ class TestMkmf < Test::Unit::TestCase
}
end
end
end

View File

@ -1,8 +1,7 @@
# frozen_string_literal: false
require_relative 'base'
class TestMkmf
class TestTryConstant < TestMkmf
class TestMkmfTryConstant < TestMkmf
def test_simple
assert_equal( 0, mkmf {try_constant("0")}, MKMFLOG)
assert_equal( 1, mkmf {try_constant("1")}, MKMFLOG)
@ -35,4 +34,3 @@ class TestMkmf
assert_operator(mkmf {try_constant("1U<<(CHAR_BIT*sizeof(int)-1)")}, :>, 0, MKMFLOG)
end
end
end

View File

@ -1,8 +1,7 @@
# frozen_string_literal: false
require_relative 'base'
class TestMkmf
class TestConvertible < TestMkmf
class TestMkmfConvertible < TestMkmf
def test_typeof_builtin
["", ["signed ", ""], "unsigned "].each do |signed, prefix|
%w[short int long].each do |type|
@ -32,4 +31,3 @@ class TestMkmf
File.unlink("confdefs.h")
end
end
end

View File

@ -2,8 +2,7 @@
require_relative 'base'
require 'tempfile'
class TestMkmf
class TestEgrepCpp < TestMkmf
class TestMkmfEgrepCpp < TestMkmf
def test_egrep_cpp
assert_equal(true, egrep_cpp(/ruby_init/, ""), MKMFLOG)
end
@ -12,4 +11,3 @@ class TestMkmf
assert_equal(false, egrep_cpp(/never match/, ""), MKMFLOG)
end
end
end

View File

@ -1,8 +1,7 @@
# frozen_string_literal: false
require_relative 'base'
class TestMkmf
class TestFindExecutable < TestMkmf
class TestMkmfFindExecutable < TestMkmf
def setup
super
@path, ENV["PATH"] = ENV["PATH"], @tmpdir
@ -55,4 +54,3 @@ class TestMkmf
end
end
end
end

View File

@ -1,8 +1,7 @@
# frozen_string_literal: false
require_relative 'base'
class TestMkmf
class TestFlags < TestMkmf
class TestMkmfFlags < TestMkmf
def test_valid_warnflags
val = $extmk
warnflags = $warnflags
@ -54,4 +53,3 @@ class TestMkmf
end;
end
end
end

View File

@ -1,8 +1,7 @@
# frozen_string_literal: false
require_relative 'base'
class TestMkmf
class TestHaveFramework < TestMkmf
class TestMkmfHaveFramework < TestMkmf
def create_framework(fw, hdrname = "#{fw}.h")
Dir.mktmpdir("frameworks") do |dir|
fwdir = "#{dir}/#{fw}.framework"
@ -45,5 +44,4 @@ class TestMkmf
assert(have_framework([fw, hdrname]), MKMFLOG)
end
end
end
end if /darwin/ =~ RUBY_PLATFORM

View File

@ -2,8 +2,7 @@
require_relative 'base'
require 'tempfile'
class TestMkmf
class TestHaveFunc < TestMkmf
class TestMkmfHaveFunc < TestMkmf
def test_have_func
assert_equal(true, have_func("ruby_init"), MKMFLOG)
assert_include($defs, '-DHAVE_RUBY_INIT')
@ -14,4 +13,3 @@ class TestMkmf
assert_not_include($defs, '-DHAVE_RUBY_INIT')
end
end
end

View File

@ -2,8 +2,7 @@
require_relative 'base'
require 'tempfile'
class TestMkmf
class TestHaveLibrary < TestMkmf
class TestMkmfHaveLibrary < TestMkmf
LIBRARY_NAME = 'mkmftest'
HEADER_NAME = "#{LIBRARY_NAME}.h"
FUNC_NAME = 'ruby_mkmftest_foo'
@ -53,4 +52,3 @@ class TestMkmf
assert_not_have_library("#{FUNC_NAME}_fake", HEADER_NAME)
end
end
end

View File

@ -2,8 +2,7 @@
require_relative 'base'
require 'tempfile'
class TestMkmf
class TestHaveMacro < TestMkmf
class TestMkmfHaveMacro < TestMkmf
MACRO_NAME = "RUBY_MKMFTEST_FOOBAR"
def test_have_macro_opt
@ -33,4 +32,3 @@ class TestMkmf
end
end
end
end

View File

@ -1,8 +1,7 @@
# frozen_string_literal: false
require_relative 'base'
class TestMkmf
class TestInstall < TestMkmf
class TestMkmfInstall < TestMkmf
def test_install_dirs
Dir.mktmpdir do |dir|
File.write(dir+"/extconf.rb", "require 'mkmf'; create_makefile('test')")
@ -27,4 +26,3 @@ class TestMkmf
end
end
end
end

View File

@ -1,8 +1,7 @@
# frozen_string_literal: false
require_relative 'base'
class TestMkmf
class TestLibs < TestMkmf
class TestMkmfLibs < TestMkmf
def test_split_libs
assert_equal(%w[-lfoo -lbar], split_libs("-lfoo -lbar"))
end
@ -90,5 +89,4 @@ class TestMkmf
assert_in_order(array, "d", "c", bug7467)
assert_in_order(array, "c", "e", bug7467)
end
end
end if RUBY_ENGINE == "ruby"

View File

@ -2,8 +2,7 @@
require 'test/unit'
require 'mkmf'
class TestMkmf < Test::Unit::TestCase
class TestGlobal < TestMkmf
class TestMkmfGlobal < Test::Unit::TestCase
main = TOPLEVEL_BINDING.receiver
MakeMakefile.public_instance_methods(false).each do |m|
define_method(:"test_global_#{m}") do
@ -12,4 +11,3 @@ class TestMkmf < Test::Unit::TestCase
end
end
end
end

View File

@ -2,8 +2,7 @@
require_relative 'base'
require 'shellwords'
class TestMkmf
class TestPkgConfig < TestMkmf
class TestMkmfPkgConfig < TestMkmf
PKG_CONFIG = find_executable0("pkg-config")
def setup
@ -65,4 +64,3 @@ class TestMkmf
assert_equal(expected, actual, MKMFLOG)
end
end
end

View File

@ -1,8 +1,7 @@
# frozen_string_literal: false
require_relative 'base'
class TestMkmf
class TestSignedness < TestMkmf
class TestMkmfSignedness < TestMkmf
def test_typeof_builtin
bug4144 = '[ruby-dev:42731]'
[["", "-1"], ["signed ", "-1"], ["unsigned ", "+1"]].each do |signed, expect|
@ -27,4 +26,3 @@ class TestMkmf
File.unlink("confdefs.h")
end
end
end

View File

@ -1,8 +1,7 @@
# frozen_string_literal: false
require_relative 'base'
class TestMkmf
class TestSizeof < TestMkmf
class TestMkmfSizeof < TestMkmf
def setup
super
@sizeof_short = config_value("SIZEOF_SHORT").to_i
@ -45,4 +44,3 @@ class TestMkmf
File.unlink("confdefs.h")
end
end
end

View File

@ -1,7 +1,7 @@
# frozen_string_literal: false
require_relative 'test_optparse'
class TestOptionParser::Acceptable < TestOptionParser
class TestOptionParserAcceptable < TestOptionParser
def setup
super

View File

@ -2,9 +2,7 @@
require 'test/unit'
require 'optparse/ac'
class TestOptionParser < Test::Unit::TestCase; end
class TestOptionParser::AutoConf < Test::Unit::TestCase
class TestOptionParserAutoConf < Test::Unit::TestCase
def setup
@opt = OptionParser::AC.new
@foo = @bar = self.class

View File

@ -2,9 +2,7 @@
require 'test/unit'
require 'optparse'
class TestOptionParser < Test::Unit::TestCase
end
class TestOptionParser::BashCompletion < Test::Unit::TestCase
class TestOptionParserBashCompletion < Test::Unit::TestCase
def setup
@opt = OptionParser.new
@opt.define("-z", "zzz") {}

View File

@ -1,7 +1,7 @@
# frozen_string_literal: false
require_relative 'test_optparse'
class TestOptionParser::CClass < TestOptionParser
class TestOptionParserCClass < TestOptionParser
def test_no_argument
flags = []
@opt.def_option("-[a-z]") {|x| flags << x}

View File

@ -6,7 +6,7 @@ rescue LoadError
return
end
class TestOptionParser::DidYouMean < TestOptionParser
class TestOptionParserDidYouMean < TestOptionParser
def setup
super
@opt.def_option("--foo", Integer) { |v| @foo = v }

View File

@ -2,9 +2,7 @@
require 'test/unit'
require 'optparse'
class TestOptionParser < Test::Unit::TestCase
end
class TestOptionParser::Getopts < Test::Unit::TestCase
class TestOptionParserGetopts < Test::Unit::TestCase
def setup
@opt = OptionParser.new
end

View File

@ -3,9 +3,7 @@ require 'test/unit'
require 'optparse'
require 'optparse/kwargs'
class TestOptionParser < Test::Unit::TestCase
end
class TestOptionParser::KwArg < Test::Unit::TestCase
class TestOptionParserKwArg < Test::Unit::TestCase
class K
def initialize(host:, port: 8080)
@host = host

View File

@ -1,7 +1,7 @@
# frozen_string_literal: false
require_relative 'test_optparse'
module TestOptionParser::NoArg
module TestOptionParserNoArg
def setup
super
@opt.def_option "--with_underscore" do |x| @flag = x end
@ -9,7 +9,7 @@ module TestOptionParser::NoArg
end
class Def1 < TestOptionParser
include NoArg
include TestOptionParserNoArg
def setup
super
@opt.def_option("-x") {|x| @flag = x}
@ -17,7 +17,7 @@ module TestOptionParser::NoArg
end
end
class Def2 < TestOptionParser
include NoArg
include TestOptionParserNoArg
def setup
super
@opt.def_option("-x", "--option") {|x| @flag = x}

View File

@ -1,7 +1,7 @@
# frozen_string_literal: false
require_relative 'test_optparse'
class TestOptionParser::OptArg < TestOptionParser
class TestOptionParserOptArg < TestOptionParser
def setup
super
@opt.def_option("-x[VAL]") {|x| @flag = x}

View File

@ -1,7 +1,7 @@
# frozen_string_literal: false
require_relative 'test_optparse'
class TestOptionParser::PlaceArg < TestOptionParser
class TestOptionParserPlaceArg < TestOptionParser
def setup
super
@opt.def_option("-x [VAL]") {|x| @flag = x}

View File

@ -1,7 +1,7 @@
# frozen_string_literal: false
require_relative 'test_optparse'
module TestOptionParser::ReqArg
module TestOptionParserReqArg
def setup
super
@opt.def_option "--with_underscore=VAL" do |x| @flag = x end
@ -9,7 +9,7 @@ module TestOptionParser::ReqArg
end
class Def1 < TestOptionParser
include ReqArg
include TestOptionParserReqArg
def setup
super
@opt.def_option("-xVAL") {|x| @flag = x}
@ -19,21 +19,21 @@ module TestOptionParser::ReqArg
end
end
class Def2 < TestOptionParser
include ReqArg
include TestOptionParserReqArg
def setup
super
@opt.def_option("-x", "--option=VAL") {|x| @flag = x}
end
end
class Def3 < TestOptionParser
include ReqArg
include TestOptionParserReqArg
def setup
super
@opt.def_option("--option=VAL", "-x") {|x| @flag = x}
end
end
class Def4 < TestOptionParser
include ReqArg
include TestOptionParserReqArg
def setup
super
@opt.def_option("-xVAL", "--option=VAL") {|x| @flag = x}

View File

@ -1,7 +1,7 @@
# frozen_string_literal: false
require_relative 'test_optparse'
class TestOptionParser::SummaryTest < TestOptionParser
class TestOptionParserSummaryTest < TestOptionParser
def test_short_clash
r = nil
o = OptionParser.new do |opts|

View File

@ -2,9 +2,7 @@
require 'test/unit'
require 'optparse'
class TestOptionParser < Test::Unit::TestCase
end
class TestOptionParser::ZshCompletion < Test::Unit::TestCase
class TestOptionParserZshCompletion < Test::Unit::TestCase
def setup
@opt = OptionParser.new
@opt.define("-z", "zzz") {}

View File

@ -4,9 +4,7 @@
require "test/unit"
class TestEmojiBreaks < Test::Unit::TestCase
end
class TestEmojiBreaks::BreakTest
class BreakTest
attr_reader :string, :comment, :filename, :line_number, :type, :shortname
def initialize(filename, line_number, data, comment='')
@ -31,7 +29,7 @@ class TestEmojiBreaks::BreakTest
end
end
class TestEmojiBreaks::BreakFile
class BreakFile
attr_reader :basename, :fullname, :version
FILES = []
@ -47,7 +45,6 @@ class TestEmojiBreaks::BreakFile
end
end
class TestEmojiBreaks < Test::Unit::TestCase
UNICODE_VERSION = RbConfig::CONFIG['UNICODE_VERSION']
UNICODE_DATA_PATH = File.expand_path("../../../enc/unicode/data/#{UNICODE_VERSION}/ucd/emoji", __dir__)
EMOJI_VERSION = RbConfig::CONFIG['UNICODE_EMOJI_VERSION']
@ -71,9 +68,8 @@ class TestEmojiBreaks < Test::Unit::TestCase
omit "Emoji data files not available in #{EMOJI_DATA_PATH}."
end
end
end
TestEmojiBreaks.data_files_available? and class TestEmojiBreaks
if data_files_available?
def read_data
tests = []
EMOJI_DATA_FILES.each do |file|
@ -155,3 +151,4 @@ TestEmojiBreaks.data_files_available? and class TestEmojiBreaks
end
end
end
end

View File

@ -4,9 +4,7 @@
require "test/unit"
class TestGraphemeBreaksFromFile < Test::Unit::TestCase
end
class TestGraphemeBreaksFromFile::BreakTest
class BreakTest
attr_reader :clusters, :string, :comment, :line_number
def initialize(line_number, data, comment)
@ -28,7 +26,6 @@ class TestGraphemeBreaksFromFile::BreakTest
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,9 +40,8 @@ class TestGraphemeBreaksFromFile < Test::Unit::TestCase
omit "Unicode data file GraphemeBreakTest not available in #{UNICODE_DATA_PATH}."
end
end
end
TestGraphemeBreaksFromFile.file_available? and class TestGraphemeBreaksFromFile
if file_available?
def read_data
tests = []
IO.foreach(GRAPHEME_BREAK_TEST_FILE, encoding: Encoding::UTF_8) do |line|
@ -93,3 +89,4 @@ TestGraphemeBreaksFromFile.file_available? and class TestGraphemeBreaksFromFile
end
end
end
end

View File

@ -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