[前][次][番号順一覧][スレッド一覧]

ruby-changes:70518

From: nagachika <ko1@a...>
Date: Fri, 24 Dec 2021 15:04:47 +0900 (JST)
Subject: [ruby-changes:70518] 1d29740c1b (ruby_3_0): merge revision(s) 5086c25f6015558877f85c3f1c014780b08fd3ce,3ff0a0b40c2e1fbdad2286f1dafe837f822d0e0d: [Backport #16936]

https://git.ruby-lang.org/ruby.git/commit/?id=1d29740c1b

From 1d29740c1b101db4bd8fc2d05f929a9e37471a0f Mon Sep 17 00:00:00 2001
From: nagachika <nagachika@r...>
Date: Fri, 24 Dec 2021 14:41:08 +0900
Subject: merge revision(s)
 5086c25f6015558877f85c3f1c014780b08fd3ce,3ff0a0b40c2e1fbdad2286f1dafe837f822d0e0d:
 [Backport #16936]

	Properly exclude test cases.

	Lets consider the following scenario:

	~~~
	irb(#<Test::Unit::AutoRunner::Runner:0x0000560f68afc3c8>):001:0> p suite
	OpenSSL::TestEC
	=> OpenSSL::TestEC

	irb(#<Test::Unit::AutoRunner::Runner:0x0000560f68afc3c8>):002:0> p all_test_methods
	["test_ECPrivateKey", "test_ECPrivateKey_encrypted", "test_PUBKEY", "test_check_key", "test_derive_key", "test_dh_compute_key", "test_dsa_sign_asn1_FIPS186_3", "test_ec_group", "test_ec_key", "test_ec_point", "test_ec_point_add", "test_ec_point_mul", "test_generate", "test_marshal", "test_sign_verify", "test_sign_verify_raw"]
	=>
	["test_ECPrivateKey",
	 "test_ECPrivateKey_encrypted",
	 "test_PUBKEY",
	 "test_check_key",
	 "test_derive_key",
	 "test_dh_compute_key",
	 "test_dsa_sign_asn1_FIPS186_3",
	 "test_ec_group",
	 "test_ec_key",
	 "test_ec_point",
	 "test_ec_point_add",
	 "test_ec_point_mul",
	 "test_generate",
	 "test_marshal",
	 "test_sign_verify",
	 "test_sign_verify_raw"]

	irb(#<Test::Unit::AutoRunner::Runner:0x0000560f68afc3c8>):003:0> p filter
	/\A(?=.*)(?!.*(?-mix:(?-mix:memory_leak)|(?-mix:OpenSSL::TestEC.test_check_key)))/
	=> /\A(?=.*)(?!.*(?-mix:(?-mix:memory_leak)|(?-mix:OpenSSL::TestEC.test_check_key)))/

	irb(#<Test::Unit::AutoRunner::Runner:0x0000560f68afc3c8>):004:0> method = "test_check_key"
	=> "test_check_key"
	~~~

	The intention here is to exclude the `test_check_key` test case.
	Unfortunately this does not work as expected, because the negative filter
	is never checked:

	~~~
	irb(#<Test::Unit::AutoRunner::Runner:0x0000560f68afc3c8>):005:0> filter === method
	=> true

	irb(#<Test::Unit::AutoRunner::Runner:0x0000560f68afc3c8>):006:0> filter === "#{suite}##{method}"
	=> false

	irb(#<Test::Unit::AutoRunner::Runner:0x0000560f68afc3c8>):007:0> filter === method || filter === "#{suite}##{method}"
	=> true
	~~~

	Therefore always filter against the fully qualified method name
	`#{suite}##{method}`, which should provide the expected result.

	However, if plain string filter is used, keep checking also only the
	method name.

	This resolves [Bug #16936].
	---
	 tool/lib/test/unit.rb | 12 +++++++++---
	 1 file changed, 9 insertions(+), 3 deletions(-)

	Filter method names only if filtering method name only

	If sole `filter` option doesn't seem including test case name,
	match with method name only.
	And if the filter is a Regexp or String, it never matches method
	name symbols.
	---
	 tool/lib/test/unit.rb | 15 ++++++---------
	 1 file changed, 6 insertions(+), 9 deletions(-)
---
 tool/lib/test/unit.rb | 3 +++
 version.h             | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb
index d76353cf0fb..38369a1040c 100644
--- a/tool/lib/test/unit.rb
+++ b/tool/lib/test/unit.rb
@@ -117,6 +117,9 @@ module Test https://github.com/ruby/ruby/blob/trunk/tool/lib/test/unit.rb#L117
             filter = nil
           elsif negative.empty? and positive.size == 1 and pos_pat !~ positive[0]
             filter = positive[0]
+            unless /\A[A-Z]\w*(?:::[A-Z]\w*)*#/ =~ filter
+              filter = /##{Regexp.quote(filter)}\z/
+            end
           else
             filter = Regexp.union(*positive.map! {|s| Regexp.new(s[pos_pat, 1] || "\\A#{Regexp.quote(s)}\\z")})
           end
diff --git a/version.h b/version.h
index e3c26230f6c..bc580942d0e 100644
--- a/version.h
+++ b/version.h
@@ -12,7 +12,7 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L12
 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
 #define RUBY_VERSION_TEENY 4
 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
-#define RUBY_PATCHLEVEL 162
+#define RUBY_PATCHLEVEL 163
 
 #define RUBY_RELEASE_YEAR 2021
 #define RUBY_RELEASE_MONTH 12
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]