From 21258a267aa578ef5c9768cf565823d42110c1c2 Mon Sep 17 00:00:00 2001 From: cliffmccarthy <16453869+cliffmccarthy@users.noreply.github.com> Date: Mon, 13 Oct 2025 10:11:28 -0500 Subject: [PATCH] test: Handle Git errors in test_deployed_state() - This is a counterpart to pull request #607. Revised test_deployed_state() to perform the same error-handling on Git commands that cmdeploy does. If 'git rev-parse' returns an error, the value "unknown" is used. If 'git diff' returns an error, the null string is used. - This fixes failures in environments where Git is not installed or where the .git subdirectory is not present (as long as the server was deployed in the same way). --- cmdeploy/src/cmdeploy/tests/online/test_1_basic.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py b/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py index 822b71f9..28a4a519 100644 --- a/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py +++ b/cmdeploy/src/cmdeploy/tests/online/test_1_basic.py @@ -223,8 +223,14 @@ def test_expunged(remote, chatmail_config): def test_deployed_state(remote): - git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode() - git_diff = subprocess.check_output(["git", "diff"]).decode() + try: + git_hash = subprocess.check_output(["git", "rev-parse", "HEAD"]).decode() + except Exception: + git_hash = "unknown\n" + try: + git_diff = subprocess.check_output(["git", "diff"]).decode() + except Exception: + git_diff = "" git_status = [git_hash.strip()] for line in git_diff.splitlines(): git_status.append(line.strip().lower())