From 032aea93d28f72431b45c57f38199d1d3cc412aa Mon Sep 17 00:00:00 2001 From: Christoph Martin Date: Tue, 8 Jul 2025 22:49:54 +0200 Subject: [PATCH] testprogramrunner: enable setting cwd Add a mechanism to change the current working directory the program under test is being run from. --- tests/lib/testprogramrunner.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/lib/testprogramrunner.py b/tests/lib/testprogramrunner.py index 3d24a96a1..295179a25 100644 --- a/tests/lib/testprogramrunner.py +++ b/tests/lib/testprogramrunner.py @@ -104,6 +104,7 @@ class TestProgramRunner(unittest.TestCase): timeout_seconds=10, wrapper_args=[], environment={}, + cwd=None, ) -> Result: argv = [self.__program] @@ -123,6 +124,9 @@ class TestProgramRunner(unittest.TestCase): print("Running:", argv) + if cwd is not None: + print("Working Directory:", cwd) + # We want to ensure consistent line endings... info = subprocess.run( argv, @@ -134,6 +138,7 @@ class TestProgramRunner(unittest.TestCase): text=True, encoding="utf-8", check=False, + cwd=cwd, ) result = Result(