All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] test-runner: fix matching with --verbose
@ 2022-06-21 18:25 James Prestwood
  2022-06-22 23:40 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: James Prestwood @ 2022-06-21 18:25 UTC (permalink / raw)
  To: iwd; +Cc: James Prestwood

The new regex match update was actually matching way more than it should
have due to how python's 'match' API works. 'match' will return successfully
if zero or more characters match from the beginning of the string. In this
case we actually need the entire regex to match otherwise we start matching
all prefixes, for example:

"--verbose iwd" will match iwd, iwd-dhcp, iwd-acd, iwd-genl and iwd-tls.

Instead use re.fullmatch which requires the entire string to match the
regex.
---
 tools/utils.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/utils.py b/tools/utils.py
index 3cee9a22..04f6d910 100644
--- a/tools/utils.py
+++ b/tools/utils.py
@@ -8,7 +8,7 @@ import dbus
 
 from gi.repository import GLib
 from weakref import WeakValueDictionary
-from re import match
+from re import fullmatch
 
 from runner import RunnerCoreArgParse
 
@@ -98,7 +98,7 @@ class Process(subprocess.Popen):
 		# Handle any regex matches
 		for item in Process.testargs.verbose:
 			try:
-				if match(item, process):
+				if fullmatch(item, process):
 					return True
 			except Exception as e:
 				print("%s is not a valid regex" % item)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] test-runner: fix matching with --verbose
  2022-06-21 18:25 [PATCH] test-runner: fix matching with --verbose James Prestwood
@ 2022-06-22 23:40 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2022-06-22 23:40 UTC (permalink / raw)
  To: James Prestwood, iwd

Hi James,

On 6/21/22 13:25, James Prestwood wrote:
> The new regex match update was actually matching way more than it should
> have due to how python's 'match' API works. 'match' will return successfully
> if zero or more characters match from the beginning of the string. In this
> case we actually need the entire regex to match otherwise we start matching
> all prefixes, for example:
> 
> "--verbose iwd" will match iwd, iwd-dhcp, iwd-acd, iwd-genl and iwd-tls.
> 
> Instead use re.fullmatch which requires the entire string to match the
> regex.
> ---
>   tools/utils.py | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 

Applied, thanks.

Regards,
-Denis


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-22 23:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-21 18:25 [PATCH] test-runner: fix matching with --verbose James Prestwood
2022-06-22 23:40 ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.