summaryrefslogtreecommitdiff
path: root/tool/lib/test/unit.rb
diff options
context:
space:
mode:
authorVít Ondruch <vondruch@redhat.com>2021-10-21 13:02:38 +0200
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-10-27 19:56:19 +0900
commit5086c25f6015558877f85c3f1c014780b08fd3ce (patch)
tree8b5c6637a951cbd40ffcabccfe45034a82c57772 /tool/lib/test/unit.rb
parent9fc2f5375d2ff4defc7581caf6f65f48f5ee83f5 (diff)
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].
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/5026
Diffstat (limited to 'tool/lib/test/unit.rb')
-rw-r--r--tool/lib/test/unit.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/tool/lib/test/unit.rb b/tool/lib/test/unit.rb
index c58a609bfa..0482c8073f 100644
--- a/tool/lib/test/unit.rb
+++ b/tool/lib/test/unit.rb
@@ -1497,9 +1497,15 @@ module Test
all_test_methods = suite.send "#{type}_methods"
if filter
- all_test_methods.select! {|method|
- filter === method || filter === "#{suite}##{method}"
- }
+ if Regexp === filter
+ all_test_methods.select! {|method|
+ filter === "#{suite}##{method}"
+ }
+ else
+ all_test_methods.select! {|method|
+ filter === method || filter === "#{suite}##{method}"
+ }
+ end
end
all_test_methods = @order.sort_by_name(all_test_methods)