From 4751c4ed4100a6ed60d3ed9efc4b5c4900ac7d7a Mon Sep 17 00:00:00 2001 From: Alex Tercete Date: Tue, 29 Apr 2025 10:48:42 +0100 Subject: [PATCH 1/2] refactor(runner): reuse method --- bazel/labgrid/runner/runner.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bazel/labgrid/runner/runner.py b/bazel/labgrid/runner/runner.py index 8dc1145..ea8ed9a 100644 --- a/bazel/labgrid/runner/runner.py +++ b/bazel/labgrid/runner/runner.py @@ -113,7 +113,7 @@ class Runner: def run(self, cmd: str, env: Mapping[str, str] = {}) -> int: """Run a command on the device with given environment variables.""" cmd = f"cd {self._exec_root} && {self._tools.env(env, cmd)}" - out, err, code = self._shell.run(cmd) + out, err, code = self._run(cmd, check=False) for line in out: stdout.write(f"{line}{linesep}") for line in err: -- GitLab From 3b45d635a07882c75ef5ec551e0b23b6b10ce61c Mon Sep 17 00:00:00 2001 From: Alex Tercete Date: Tue, 29 Apr 2025 16:16:25 +0100 Subject: [PATCH 2/2] fix(runner): respect Bazel test timeout --- bazel/labgrid/runner/runner.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bazel/labgrid/runner/runner.py b/bazel/labgrid/runner/runner.py index ea8ed9a..8905e2a 100644 --- a/bazel/labgrid/runner/runner.py +++ b/bazel/labgrid/runner/runner.py @@ -155,7 +155,9 @@ class Runner: return path def _run(self, cmd, check=True): - out, err, code = self._shell.run(cmd) + # We should let Bazel kill the process with the configured timeout if running a test + timeout = None if environ.get("BAZEL_TEST") == "1" else 30 + out, err, code = self._shell.run(cmd, timeout=timeout) if check and code: raise CalledProcessError( cmd=cmd, returncode=code, output=stdout, stderr=err -- GitLab