@@ -149,22 +149,35 @@ def _setup(tmp_path: pathlib.Path, monkeypatch: pytest.MonkeyPatch) -> pathlib.P
149149 return repo
150150
151151
152- @pytest .mark .parametrize ("free" , [90 , 100 , 110 ])
152+ @pytest .mark .parametrize (
153+ ("total" , "free" , "free_note" ),
154+ [
155+ (1000 , 90 , "0 MiB free (9.0%)" ),
156+ (1000 , 100 , None ),
157+ (1000 , 110 , None ),
158+ (82_000_000_000 , 5_492_600_832 , "5.1 GiB free (6.7%)" ),
159+ (20 * 1024 ** 3 , 1024 ** 3 , "1.0 GiB free (5.0%)" ),
160+ (20 * 1024 ** 3 , 1024 ** 3 - 1 , "1024 MiB free (5.0%)" ),
161+ (20 * 1024 ** 3 , 550_000_000 , "525 MiB free (2.6%)" ),
162+ ],
163+ )
153164def test_launch_reports_low_state_disk_space_without_refusing (
154165 tmp_path : pathlib .Path ,
155166 monkeypatch : pytest .MonkeyPatch ,
156167 capsys : pytest .CaptureFixture [str ],
168+ total : int ,
157169 free : int ,
170+ free_note : str | None ,
158171) -> None :
159- """Fresh and resumed executions warn strictly below ten percent, without refusing work."""
172+ """Fresh and resumed executions report low space in GiB or MiB without refusing work."""
160173 repo = _setup (tmp_path , monkeypatch )
161174 state = paths .state_dir (repo )
162175 usage = shutil .disk_usage (repo )
163176 seen : list [pathlib .Path ] = []
164177
165178 def disk_usage (path : Any ) -> Any :
166179 seen .append (pathlib .Path (path ))
167- return usage ._replace (total = 1000 , used = 1000 - free , free = free )
180+ return usage ._replace (total = total , used = total - free , free = free )
168181
169182 monkeypatch .setattr (shutil , "disk_usage" , disk_usage )
170183 monkeypatch .setattr (role_providers , "build_role_provider" , _use (_Scripted ([_finish ()])))
@@ -175,9 +188,8 @@ def disk_usage(path: Any) -> Any:
175188 assert cli_main (command ) == 0
176189 notice = capsys .readouterr ().err
177190 assert state in seen
178- assert ("low disk space" in notice ) == (free < 100 )
179- if free < 100 :
180- assert f"{ free } bytes" in notice and "9.0%" in notice and str (state ) in notice
191+ expected = [] if free_note is None else [f"[agent6] low disk space: { free_note } at { state } " ]
192+ assert [line for line in notice .splitlines () if "low disk space" in line ] == expected
181193 seen .clear ()
182194
183195
0 commit comments