From 0ce02a56a6977d89e48e1d4e33acc0512a804733 Mon Sep 17 00:00:00 2001 From: Michael Ernst Date: Sat, 21 Sep 2024 12:24:33 -0700 Subject: [PATCH] Improve diagnostics (#365) --- src/python/replay_merge.py | 11 ++++++----- src/python/repo.py | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/python/replay_merge.py b/src/python/replay_merge.py index 321472e87e..27991cbd16 100755 --- a/src/python/replay_merge.py +++ b/src/python/replay_merge.py @@ -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, @@ -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 " diff --git a/src/python/repo.py b/src/python/repo.py index 1289b28223..023a293085 100755 --- a/src/python/repo.py +++ b/src/python/repo.py @@ -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