Skip to content

Commit

Permalink
Improve diagnostics (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst authored Sep 21, 2024
1 parent 6be4a1f commit 0ce02a5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
11 changes: 6 additions & 5 deletions src/python/replay_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ def merge_replay(
stderr=subprocess.PIPE,
)
if len(process.stderr.decode("utf-8")) == 0:
conflict_files = process.stdout.decode("utf-8")
is_conflict = len(conflict_files) > 0
git_conflict_files = process.stdout.decode("utf-8")
is_conflict = len(git_conflict_files) > 0
assert (
is_conflict == (merge_result == MERGE_STATE.Merge_failed)
), f"merge_replay: tool{merge_tool} merge_result {merge_result} does not match conflict_files {conflict_files} at path {repo.local_repo_path}"
), f"merge_replay: tool merge result is inconsistent with `git diff --diff-filter=U`: tool={merge_tool} merge_result={merge_result} git_conflict_files={git_conflict_files} path={repo.local_repo_path}"

result_df.loc[
merge_tool.name,
Expand Down Expand Up @@ -308,10 +308,11 @@ def merge_replay(
store_artifacts(result_df)
if delete_workdir:
delete_workdirs(result_df)
print("=====================================\n")
print("fingerprints differ; details follow.")
print(f"=================== start of {log_path}:")
with open(log_path, "r", encoding="utf-8") as f:
print(f.read())
print("=====================================\n")
print(f"=================== end of {log_path}.")
raise Exception(
f"fingerprints differ: after merge of {workdir} with {merge_tool}, found"
+ f" {merge_fingerprint} but expected "
Expand Down
15 changes: 12 additions & 3 deletions src/python/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,20 @@ def stdout_and_stderr(
source: Union[subprocess.TimeoutExpired, subprocess.CompletedProcess],
) -> str:
"""Produces the standard output and standard error of a timedout process."""
explanation = "Run Command: " + " ".join(command) + "\nTimed out"
explanation = "Here is the output from: " + " ".join(command)
if source.stdout:
explanation += "\nstdout:\n" + source.stdout.decode("utf-8", "replace")
explanation += (
"\nstdout:\n"
+ source.stdout.decode("utf-8", "replace")
+ "\nEnd of stdout."
)
if source.stderr:
explanation += "\nstderr:\n" + source.stderr.decode("utf-8", "replace")
explanation += (
"\nstderr:\n"
+ source.stderr.decode("utf-8", "replace")
+ "\nEnd of stderr."
)
explanation += "\nEnd of output from: " + " ".join(command)
return explanation


Expand Down

0 comments on commit 0ce02a5

Please sign in to comment.