eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

commit db3d6a365262bdfca4a62c0b50a0c9d0cc4aefb3
parent 2ad5e4831428463af933c643965c20801850910b
Author: James Prestwood <prestwoj@gmail.com>
Date:   Fri,  3 Jun 2022 16:12:01 -0700

test-runner: allow regex for verbose option

The glob match was completely broken for --verbose because globs
are actually path matches, not generally for strings. Instead
match based on regular expressions.

First the verbose option was fixed to store it as an array as well
as write any list arguments into the kernel command line properly
(str() would include []). This has worked up until now because the
'in' keyword in python will work on strings just as well
as lists, for example:

>>> 'test' in 'this,is,a,test'
True

Then, the glob match was replaced with a regex match. Any exceptions
are caught and somewhat ignored (printed, but only seen with --debug).
This only guards against fatal exceptions from a user passing an
invalid expression.

Diffstat:
Mtools/runner.py | 7+++++--
Mtools/utils.py | 11+++++++----
2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/tools/runner.py b/tools/runner.py @@ -72,7 +72,10 @@ class RunnerNamespace(Namespace): if v in [None, False, [], '']: continue - ret += '%s=%s ' % (k, str(v)) + if type(v) is list: + ret += '%s=%s ' % (k, ','.join(v)) + else: + ret += '%s=%s ' % (k, str(v)) return ret.strip() @@ -89,7 +92,7 @@ class RunnerCoreArgParse(ArgumentParser): default=None, type=os.path.abspath) self.add_argument('--verbose', '-v', metavar='<list>', - type=str, + type=lambda x: x.split(','), help='Comma separated list of applications', dest='verbose', default=[]) diff --git a/tools/utils.py b/tools/utils.py @@ -8,7 +8,7 @@ import dbus from gi.repository import GLib from weakref import WeakValueDictionary -from glob import glob +from re import match from runner import RunnerCoreArgParse @@ -95,10 +95,13 @@ class Process(subprocess.Popen): if process == 'valgrind' and 'iwd' in Process.testargs.verbose: return True - # Handle any glob matches + # Handle any regex matches for item in Process.testargs.verbose: - if process in glob(item): - return True + try: + if match(item, process): + return True + except Exception as e: + print("%s is not a valid regex" % item) return False