diff mbox series

test-runner: fix matching with --verbose

Message ID 20220621182518.1308203-1-prestwoj@gmail.com (mailing list archive)
State Accepted, archived
Headers show
Series test-runner: fix matching with --verbose | expand

Checks

Context Check Description
prestwoj/iwd-alpine-ci-fetch success Fetch PR
prestwoj/iwd-ci-testrunner pending Autotest Runner
prestwoj/iwd-ci-gitlint success GitLint
prestwoj/iwd-ci-fetch success Fetch PR
prestwoj/iwd-alpine-ci-makedistcheck success Make Distcheck
prestwoj/iwd-alpine-ci-incremental_build success Incremental build not run PASS
prestwoj/iwd-alpine-ci-build success Build - Configure
prestwoj/iwd-ci-makedistcheck success Make Distcheck
prestwoj/iwd-ci-incremental_build success Incremental build not run PASS
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-alpine-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-alpine-ci-makecheck success Make Check
prestwoj/iwd-ci-clang success clang PASS
prestwoj/iwd-ci-makecheckvalgrind success Make Check w/Valgrind
prestwoj/iwd-ci-makecheck success Make Check
tedd_an/pre-ci_am fail error: patch failed: tools/utils.py:8 error: tools/utils.py: patch does not apply hint: Use 'git am --show-current-patch' to see the failed patch

Commit Message

James Prestwood June 21, 2022, 6:25 p.m. UTC
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(-)

Comments

Denis Kenzior June 22, 2022, 11:40 p.m. UTC | #1
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
diff mbox series

Patch

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)