From 8f8cd4c90ce12dd6dfcf12296da32c8de39c6f6d Mon Sep 17 00:00:00 2001 From: Michael Ernst Date: Sun, 22 Sep 2024 00:55:34 -0700 Subject: [PATCH 1/3] Log tool output (#371) --- src/python/replay_merge.py | 3 ++- src/python/repo.py | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/python/replay_merge.py b/src/python/replay_merge.py index 27991cbd16..d7a12b6b96 100755 --- a/src/python/replay_merge.py +++ b/src/python/replay_merge.py @@ -1,7 +1,8 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- """Replay merges and their test results. -The output appears in the .workdirs/ directory. +The output appears in the `.workdirs`/ directory. +Logs appear in the `replay_logs/merges/` directory. Command-line arguments are listed just after the line: if __name__ == "__main__": diff --git a/src/python/repo.py b/src/python/repo.py index 023a293085..e50b95c422 100755 --- a/src/python/repo.py +++ b/src/python/repo.py @@ -558,13 +558,18 @@ def merge( str(timeout), f"src/scripts/merge_tools/{tool.name}.sh {self.local_repo_path.resolve()} {LEFT_BRANCH_NAME} {RIGHT_BRANCH_NAME}", ] + logger.debug( + f"merge: Merging {self.repo_slug} {left_commit} {right_commit} with {tool.name}" + ) p = subprocess.run( command, capture_output=True, check=False, ) + std_streams = stdout_and_stderr(command, p) + logger.debug(std_streams) if p.returncode == 124: # Timeout - explanation = explanation + "\n" + stdout_and_stderr(command, p) + explanation = explanation + "\n" + std_streams if use_cache: cache_entry["merge status"] = MERGE_STATE.Merge_timedout.name cache_entry["explanation"] = explanation @@ -583,7 +588,7 @@ def merge( -1, ) run_time = time.time() - start_time - explanation = explanation + "\n" + stdout_and_stderr(command, p) + explanation = explanation + "\n" + std_streams merge_status = ( MERGE_STATE.Merge_success if p.returncode == 0 else MERGE_STATE.Merge_failed ) From 0a269f2632c0e6efbdaa1e2dfdbb6d947796aad9 Mon Sep 17 00:00:00 2001 From: Michael Ernst Date: Sun, 22 Sep 2024 00:55:47 -0700 Subject: [PATCH 2/3] Use absolute pathnames instead of depending on PATH (#370) --- src/scripts/merge_tools/git_hires_merge.sh | 6 ++++-- src/scripts/merge_tools/merge_git_then_plumelib.sh | 4 +++- src/scripts/merge_tools/merge_script_then_plumelib.sh | 4 +++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/scripts/merge_tools/git_hires_merge.sh b/src/scripts/merge_tools/git_hires_merge.sh index 83d2fad295..e15431ee96 100755 --- a/src/scripts/merge_tools/git_hires_merge.sh +++ b/src/scripts/merge_tools/git_hires_merge.sh @@ -13,8 +13,10 @@ clone_dir=$1 branch1=$2 branch2=$3 +SCRIPTDIR="$(cd "$(dirname "$0")" && pwd -P)" + # Print the current PATH -echo "PATH: $PATH" +echo "$0 PATH: $PATH" cd "$clone_dir" || { echo "$0: cannot cd to $clone_dir from $(pwd)"; exit 2; } @@ -25,7 +27,7 @@ attributes_file=".git/info/attributes" echo "* merge=git-hires-merge" >> "$attributes_file" git config --local merge.git-hires-merge.name "An interactive merge driver for resolving conflicts on individual or adjacent lines" -git config --local merge.git-hires-merge.driver "git-hires-merge %O %A %B %L %P" +git config --local merge.git-hires-merge.driver "${SCRIPTDIR}/git-hires-merge %O %A %B %L %P" git config --local merge.git-hires-merge.recursive "binary" git config --local merge.conflictstyle diff3 diff --git a/src/scripts/merge_tools/merge_git_then_plumelib.sh b/src/scripts/merge_tools/merge_git_then_plumelib.sh index 08d219d1c1..abe746fc20 100755 --- a/src/scripts/merge_tools/merge_git_then_plumelib.sh +++ b/src/scripts/merge_tools/merge_git_then_plumelib.sh @@ -19,6 +19,8 @@ branch2=$3 git_strategy=$4 #"-Xignore-space-change" plumelib_strategy=$5 #"--only-adjacent" +SCRIPTDIR="$(cd "$(dirname "$0")" && pwd -P)" + VERBOSE= ## Enable for debugging # VERBOSE=YES @@ -55,7 +57,7 @@ fi git config --local merge.tool merge-plumelib # shellcheck disable=SC2016 -git config --local mergetool.merge-plumelib.cmd 'java-merge-tool.sh '"$plumelib_strategy"' ${BASE} ${LOCAL} ${REMOTE} ${MERGED}' +git config --local mergetool.merge-plumelib.cmd "$SCRIPTDIR"/'java-merge-tool.sh '"$plumelib_strategy"' ${BASE} ${LOCAL} ${REMOTE} ${MERGED}' git config --local mergetool.merge-plumelib.trustExitCode true case "$plumelib_strategy" in diff --git a/src/scripts/merge_tools/merge_script_then_plumelib.sh b/src/scripts/merge_tools/merge_script_then_plumelib.sh index d42af44d31..b63d643fb5 100755 --- a/src/scripts/merge_tools/merge_script_then_plumelib.sh +++ b/src/scripts/merge_tools/merge_script_then_plumelib.sh @@ -20,6 +20,8 @@ branch2=$3 merge_script=$4 #"-Xignore-space-change" plumelib_strategy=$5 #"--only-adjacent" +SCRIPTDIR="$(cd "$(dirname "$0")" && pwd -P)" + VERBOSE= ## Enable for debugging # VERBOSE=YES @@ -56,7 +58,7 @@ fi git config --local merge.tool merge-plumelib # shellcheck disable=SC2016 -git config --local mergetool.merge-plumelib.cmd 'java-merge-tool.sh '"$plumelib_strategy"' ${BASE} ${LOCAL} ${REMOTE} ${MERGED}' +git config --local mergetool.merge-plumelib.cmd "$SCRIPTDIR"/'java-merge-tool.sh '"$plumelib_strategy"' ${BASE} ${LOCAL} ${REMOTE} ${MERGED}' git config --local mergetool.merge-plumelib.trustExitCode true case "$plumelib_strategy" in From cedc855cb0e12b5a164f02378b5765b0ffc31174 Mon Sep 17 00:00:00 2001 From: Michael Ernst Date: Sun, 22 Sep 2024 00:55:57 -0700 Subject: [PATCH 3/3] Clarify output, and only produce it if there is a problem (#369) --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b3ddc25880..cecedbd5e5 100644 --- a/Makefile +++ b/Makefile @@ -166,8 +166,7 @@ check-merges-reproducibility: echo "Running replay_merge for idx $$idx"; \ src/python/replay_merge.py --testing --merges_csv $(CSV_RESULTS) -skip_build -delete_workdir --idx $$idx || FAILED_IDXES="$$FAILED_IDXES $$idx"; \ done; \ - echo "$$FAILED_IDXES"; \ - test -z "$$FAILED_IDXES" + test -z "$$FAILED_IDXES" || { echo "Failed indexes = $$FAILED_IDXES"; false; } protect-repos: find repos -mindepth 1 -type d -exec chmod a-w {} +