Skip to content

Commit

Permalink
Fix diagnostics on windows, add e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
olsen232 committed Dec 17, 2024
1 parent dff5a30 commit 5fb1800
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion kart/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def print_diagnostics():
other_info = {
"now": str(datetime.now()),
"ppid": os.getppid(),
"sid": os.getsid(0),
"sid": os.getsid(0) if hasattr(os, "getsid") else None,
"kart_helper_pid": os.environ.get("KART_HELPER_PID"),
"pid": os.getpid(),
}
Expand Down
12 changes: 12 additions & 0 deletions tests/scripts/e2e-1.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,16 @@ finally {
Remove-Item -Force -Recurse "$TMP_PATH"
}

try {
$env:KART_DIAGNOSTICS = "1"
$output = Exec { kart --version } 2>&1
}
finally {
Remove-Item Env:\KART_DIAGNOSTICS
}
if ($output -notcontains "DIAGNOSTICS") {
throw "Expected some diagnostics output"
}


Write-Output ">>> E2E Success"
6 changes: 6 additions & 0 deletions tests/scripts/e2e-1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,10 @@ if kart ext-run "$HERE/ext-run-test.py" throw; then
exit 1
fi

# Kart diagnostics
if [ -z "$(KART_DIAGNOSTICS=1 kart --version 2>&1 | grep DIAGNOSTICS)" ]; then
echo "Expected some diagnostics output"
exit 1
fi

{ echo -e "\n✅ E2E: Success"; } 2>/dev/null
10 changes: 10 additions & 0 deletions tests/test_diagnostics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from io import StringIO
import sys

from kart.diagnostics import print_diagnostics

def test_print_diagnostics(monkeypatch):
stderr = StringIO()
monkeypatch.setattr(sys, "stderr", stderr)
print_diagnostics()
assert "DIAGNOSTICS" in stderr.getvalue()

0 comments on commit 5fb1800

Please sign in to comment.