Skip to content

Commit

Permalink
improve debugging test
Browse files Browse the repository at this point in the history
  • Loading branch information
zackees committed Aug 19, 2024
1 parent f9c48fe commit aa8803b
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions tests/test_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Tests against the problem of git not being found on the path.
"""
import os
import shutil
import subprocess
import unittest
import warnings
Expand All @@ -13,6 +14,7 @@
from isolated_environment.api import IsolatedEnvironment

HERE = Path(__file__).parent.absolute()
GIT_PATH = shutil.which("git")


class AiderChatTester(unittest.TestCase):
Expand All @@ -30,18 +32,25 @@ def test_ensure_installed(self) -> None:
# now create an inner environment without the static-ffmpeg
cp: subprocess.CompletedProcess = iso_env.run(["git", "--help"], shell=True)
if cp.returncode != 0:
warnings.warn("git had some sort of a problem, dumping out the system")
print(cp.stdout)
print(cp.stderr)
warning_message = [
"git had some sort of a problem, dumping out the system"
]
warning_message.append(f"system git path: {GIT_PATH}")
warning_message.append(f"stdout: {cp.stdout}")
warning_message.append(f"stderr: {cp.stderr}")

# print environment variables
path = activated_env["PATH"]
warnings.warn(f"dumping out the path: {path}")
warning_message.append(f"dumping out the path: {path}")
for p in path.split(os.pathsep):
warnings.warn(f"Path: {p}")
warning_message.append(f"Path: {p}")

activated_env.pop("PATH")
warnings.warn("dumping out the environment variables")
warning_message.append("dumping out the environment variables")
for k, v in activated_env.items():
warnings.warn(f"{k}: {v}")
warning_message.append(f"{k}: {v}")

warnings.warn("\n".join(warning_message))
self.fail("git test had some sort of failure")


Expand Down

0 comments on commit aa8803b

Please sign in to comment.