fix(terminal): log disk warning check failures at debug level (salvage #2372) (#2394)

* fix(terminal): log disk warning check failures at debug level

* fix(terminal): guard _check_disk_usage_warning by moving scratch_dir into try

---------

Co-authored-by: aydnOktay <xaydinoktay@gmail.com>
This commit is contained in:
Teknium 2026-03-21 17:10:17 -07:00 committed by GitHub
parent 1d28b4699b
commit 0ea7d0ec80
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 3 deletions

View file

@ -11,7 +11,7 @@ import pytest
import sys
import tools.terminal_tool # noqa: F401 -- ensure module is loaded
_tt_mod = sys.modules["tools.terminal_tool"]
from tools.terminal_tool import get_active_environments_info
from tools.terminal_tool import get_active_environments_info, _check_disk_usage_warning
# 1 MiB of data so the rounded MB value is clearly distinguishable
_1MB = b"x" * (1024 * 1024)
@ -62,3 +62,12 @@ class TestDiskUsageGlob:
# Should be ~2.0 MB total (1 MB per task).
# With the bug, each task globs everything -> ~4.0 MB.
assert info["total_disk_usage_mb"] == pytest.approx(2.0, abs=0.1)
class TestDiskUsageWarningHardening:
def test_check_disk_usage_warning_logs_debug_on_unexpected_error(self):
with patch.object(_tt_mod, "_get_scratch_dir", side_effect=RuntimeError("boom")), patch.object(_tt_mod.logger, "debug") as debug_mock:
result = _check_disk_usage_warning()
assert result is False
debug_mock.assert_called()