aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/test/py/lib
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2023-07-07 22:13:00 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2023-07-07 22:49:27 +0200
commit9ba12e5496c49f48f40ad52e816641dfdbb0474e (patch)
tree47c04ea350c077219eb5dca461e182551e26d954 /test/py/lib
parentsupport code coverage report generation (diff)
downloadcimple-9ba12e5496c49f48f40ad52e816641dfdbb0474e.tar.gz
cimple-9ba12e5496c49f48f40ad52e816641dfdbb0474e.zip
test: add some basic command-line usage tests
Diffstat (limited to '')
-rw-r--r--test/py/lib/process.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/py/lib/process.py b/test/py/lib/process.py
index 3436280..d478c32 100644
--- a/test/py/lib/process.py
+++ b/test/py/lib/process.py
@@ -89,6 +89,9 @@ class CmdLine:
def run(self, *argv):
return Process.run(*self.argv, *argv)
+ def try_run(self, *argv):
+ return Process.try_run(*self.argv, *argv)
+
@contextmanager
def run_async(self, *argv):
with Process(self, *argv) as process:
@@ -146,6 +149,13 @@ class Process(subprocess.Popen):
Process._log_process_end(argv, ec, output)
raise
+ @staticmethod
+ def try_run(*args, **kwargs):
+ try:
+ return 0, Process.run(*args, **kwargs)
+ except subprocess.CalledProcessError as e:
+ return e.returncode, e.stdout
+
def __init__(self, cmd_line, *args):
self.cmd_line = cmd_line