Skip to content

Commit

Permalink
Rename compute_explanation to stdout_and_stderr (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst authored Oct 2, 2023
1 parent a8d61a2 commit 547f878
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/python/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,11 @@
)


def compute_explanation(
def stdout_and_stderr(
command: List[str],
source: Union[subprocess.TimeoutExpired, subprocess.CompletedProcess],
) -> str:
"""Produces the explanation string of a timedout process or
a completed process.
"""
"""Produces the standard output and standard error of a timedout process."""
explanation = "Run Command: " + " ".join(command) + "\nTimed out"
if source.stdout:
explanation += "\nstdout:\n" + source.stdout.decode("utf-8")
Expand Down Expand Up @@ -97,10 +95,10 @@ def repo_test(wcopy_dir: Path, timeout: int) -> Tuple[TEST_STATE, str]:
timeout=timeout,
)
except subprocess.TimeoutExpired as e:
explanation = compute_explanation(command, e)
explanation = stdout_and_stderr(command, e)
return TEST_STATE.Tests_timedout, explanation
rc = p.returncode
explanation = compute_explanation(command, p)
explanation = stdout_and_stderr(command, p)
if rc == 0: # Success
return TEST_STATE.Tests_passed, explanation
return TEST_STATE.Tests_failed, explanation
Expand Down Expand Up @@ -357,7 +355,7 @@ def merge( # pylint: disable=too-many-locals
check=False,
)
except subprocess.TimeoutExpired as e:
explanation = explanation + "\n" + compute_explanation(command, e)
explanation = explanation + "\n" + stdout_and_stderr(command, e)
sha = self.compute_tree_fingerprint()
return (
MERGE_STATE.Merge_timedout,
Expand All @@ -368,7 +366,7 @@ def merge( # pylint: disable=too-many-locals
-1,
)
run_time = time.time() - start_time
explanation = explanation + "\n" + compute_explanation(command, p)
explanation = explanation + "\n" + stdout_and_stderr(command, p)
merge_status = (
MERGE_STATE.Merge_success if p.returncode == 0 else MERGE_STATE.Merge_failed
)
Expand Down

0 comments on commit 547f878

Please sign in to comment.