Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/specify_cli/_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""
from __future__ import annotations

import logging
import sys
from collections.abc import Callable

Expand All @@ -21,6 +22,8 @@
from rich.tree import Tree
from typer.core import TyperGroup

logger = logging.getLogger(__name__)

BANNER = """
███████╗██████╗ ███████╗ ██████╗██╗███████╗██╗ ██╗
██╔════╝██╔══██╗██╔════╝██╔════╝██║██╔════╝╚██╗ ██╔╝
Expand Down Expand Up @@ -85,7 +88,7 @@ def _maybe_refresh(self):
try:
self._refresh_cb()
except Exception:
pass
logger.debug("Progress tracker refresh failed", exc_info=True)

def render(self):
tree = Tree(f"[cyan]{self.title}[/cyan]", guide_style="grey50")
Expand Down
21 changes: 21 additions & 0 deletions tests/test_console_imports.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
"""Regression guard: console symbols must remain importable from specify_cli."""
import logging

from specify_cli import (
console,
StepTracker,
select_with_arrows,
)
from specify_cli._console import logger as console_logger


def test_console_symbols_importable():
Expand Down Expand Up @@ -39,3 +42,21 @@ def test_select_with_arrows_raises_on_empty_options():
import pytest
with pytest.raises(ValueError, match="at least one option"):
select_with_arrows({})


def test_step_tracker_refresh_error_is_logged(caplog):
"""Regression: _maybe_refresh must log exceptions instead of silently swallowing."""
tracker = StepTracker("test")

def failing_refresh():
raise RuntimeError("simulated refresh failure")

tracker.attach_refresh(failing_refresh)
tracker.add("step1", "Step One")

with caplog.at_level(logging.DEBUG, logger=console_logger.name):
tracker.complete("step1", "done")

assert "Progress tracker refresh failed" in caplog.text
assert "RuntimeError: simulated refresh failure" in caplog.text
assert tracker.steps[0]["status"] == "done"