testprogramrunner: enable setting cwd

Add a mechanism to change the current working directory the program
under test is being run from.
This commit is contained in:
Christoph Martin
2025-07-08 22:49:54 +02:00
parent 25a176869d
commit 032aea93d2

View File

@@ -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(