|
|
9a8c02 |
From 96684439e96aa92e10376b5be45f006772028295 Mon Sep 17 00:00:00 2001
|
|
|
9a8c02 |
From: =?UTF-8?q?V=C3=ADt=20Ondruch?= <vondruch@redhat.com>
|
|
|
9a8c02 |
Date: Thu, 21 Oct 2021 13:02:38 +0200
|
|
|
9a8c02 |
Subject: [PATCH] Properly exclude test cases.
|
|
|
9a8c02 |
|
|
|
9a8c02 |
Lets consider the following scenario:
|
|
|
9a8c02 |
|
|
|
9a8c02 |
~~~
|
|
|
9a8c02 |
irb(#<Test::Unit::AutoRunner::Runner:0x0000560f68afc3c8>):001:0> p suite
|
|
|
9a8c02 |
OpenSSL::TestEC
|
|
|
9a8c02 |
=> OpenSSL::TestEC
|
|
|
9a8c02 |
|
|
|
9a8c02 |
irb(#<Test::Unit::AutoRunner::Runner:0x0000560f68afc3c8>):002:0> p all_test_methods
|
|
|
9a8c02 |
["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"]
|
|
|
9a8c02 |
=>
|
|
|
9a8c02 |
["test_ECPrivateKey",
|
|
|
9a8c02 |
"test_ECPrivateKey_encrypted",
|
|
|
9a8c02 |
"test_PUBKEY",
|
|
|
9a8c02 |
"test_check_key",
|
|
|
9a8c02 |
"test_derive_key",
|
|
|
9a8c02 |
"test_dh_compute_key",
|
|
|
9a8c02 |
"test_dsa_sign_asn1_FIPS186_3",
|
|
|
9a8c02 |
"test_ec_group",
|
|
|
9a8c02 |
"test_ec_key",
|
|
|
9a8c02 |
"test_ec_point",
|
|
|
9a8c02 |
"test_ec_point_add",
|
|
|
9a8c02 |
"test_ec_point_mul",
|
|
|
9a8c02 |
"test_generate",
|
|
|
9a8c02 |
"test_marshal",
|
|
|
9a8c02 |
"test_sign_verify",
|
|
|
9a8c02 |
"test_sign_verify_raw"]
|
|
|
9a8c02 |
|
|
|
9a8c02 |
irb(#<Test::Unit::AutoRunner::Runner:0x0000560f68afc3c8>):003:0> p filter
|
|
|
9a8c02 |
/\A(?=.*)(?!.*(?-mix:(?-mix:memory_leak)|(?-mix:OpenSSL::TestEC.test_check_key)))/
|
|
|
9a8c02 |
=> /\A(?=.*)(?!.*(?-mix:(?-mix:memory_leak)|(?-mix:OpenSSL::TestEC.test_check_key)))/
|
|
|
9a8c02 |
|
|
|
9a8c02 |
irb(#<Test::Unit::AutoRunner::Runner:0x0000560f68afc3c8>):004:0> method = "test_check_key"
|
|
|
9a8c02 |
=> "test_check_key"
|
|
|
9a8c02 |
~~~
|
|
|
9a8c02 |
|
|
|
9a8c02 |
The intention here is to exclude the `test_check_key` test case.
|
|
|
9a8c02 |
Unfortunately this does not work as expected, because the negative filter
|
|
|
9a8c02 |
is never checked:
|
|
|
9a8c02 |
|
|
|
9a8c02 |
~~~
|
|
|
9a8c02 |
|
|
|
9a8c02 |
irb(#<Test::Unit::AutoRunner::Runner:0x0000560f68afc3c8>):005:0> filter === method
|
|
|
9a8c02 |
=> true
|
|
|
9a8c02 |
|
|
|
9a8c02 |
irb(#<Test::Unit::AutoRunner::Runner:0x0000560f68afc3c8>):006:0> filter === "#{suite}##{method}"
|
|
|
9a8c02 |
=> false
|
|
|
9a8c02 |
|
|
|
9a8c02 |
irb(#<Test::Unit::AutoRunner::Runner:0x0000560f68afc3c8>):007:0> filter === method || filter === "#{suite}##{method}"
|
|
|
9a8c02 |
=> true
|
|
|
9a8c02 |
~~~
|
|
|
9a8c02 |
|
|
|
9a8c02 |
Therefore always filter against the fully qualified method name
|
|
|
9a8c02 |
`#{suite}##{method}`, which should provide the expected result.
|
|
|
9a8c02 |
|
|
|
9a8c02 |
However, if plain string filter is used, keep checking also only the
|
|
|
9a8c02 |
method name.
|
|
|
9a8c02 |
|
|
|
9a8c02 |
This resolves [Bug #16936].
|
|
|
9a8c02 |
---
|
|
|
9a8c02 |
tool/lib/minitest/unit.rb | 12 +++++++++---
|
|
|
9a8c02 |
1 file changed, 9 insertions(+), 3 deletions(-)
|
|
|
9a8c02 |
|
|
|
9a8c02 |
diff --git a/tool/lib/minitest/unit.rb b/tool/lib/minitest/unit.rb
|
|
|
9a8c02 |
index c58a609bfa..d5af6cb906 100644
|
|
|
9a8c02 |
--- a/tool/lib/minitest/unit.rb
|
|
|
9a8c02 |
+++ b/tool/lib/minitest/unit.rb
|
|
|
9a8c02 |
@@ -956,9 +956,15 @@ def _run_suite suite, type
|
|
|
9a8c02 |
|
|
|
9a8c02 |
all_test_methods = suite.send "#{type}_methods"
|
|
|
9a8c02 |
|
|
|
9a8c02 |
- filtered_test_methods = all_test_methods.find_all { |m|
|
|
|
9a8c02 |
- filter === m || filter === "#{suite}##{m}"
|
|
|
9a8c02 |
- }
|
|
|
9a8c02 |
+ filtered_test_methods = if Regexp === filter
|
|
|
9a8c02 |
+ all_test_methods.find_all { |m|
|
|
|
9a8c02 |
+ filter === "#{suite}##{m}"
|
|
|
9a8c02 |
+ }
|
|
|
9a8c02 |
+ else
|
|
|
9a8c02 |
+ all_test_methods.find_all {|m|
|
|
|
9a8c02 |
+ filter === m || filter === "#{suite}##{m}"
|
|
|
9a8c02 |
+ }
|
|
|
9a8c02 |
+ end
|
|
|
9a8c02 |
|
|
|
9a8c02 |
leakchecker = LeakChecker.new
|
|
|
9a8c02 |
|
|
|
9a8c02 |
--
|
|
|
9a8c02 |
2.32.0
|
|
|
9a8c02 |
|