All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: iwd@lists.linux.dev
Cc: James Prestwood <prestwoj@gmail.com>
Subject: [PATCH] test-runner: fix matching with --verbose
Date: Tue, 21 Jun 2022 11:25:18 -0700	[thread overview]
Message-ID: <20220621182518.1308203-1-prestwoj@gmail.com> (raw)

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


             reply	other threads:[~2022-06-21 18:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-21 18:25 James Prestwood [this message]
2022-06-22 23:40 ` [PATCH] test-runner: fix matching with --verbose Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220621182518.1308203-1-prestwoj@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=iwd@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.