mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-27 03:48:52 -06:00
fix: a full drive is an event, not stderr text
This commit is contained in:
1 parent
0b0bf29089
commit
8fc294ef97
15 files changed
+457
-491
No files matched your search
@@ -454,6 +454,20 @@ class TestFreeSpaceGuard(unittest.TestCase):
|
||||
self.assertIn("Free", out)
|
||||
self.assertIn("--dest", out)
|
||||
|
||||
def test_short_of_space_is_an_event_with_both_numbers(self):
|
||||
"""A --events reader got only end code 2, like any other stop."""
|
||||
install.shutil.disk_usage = lambda _p: SimpleNamespace(free=1_000)
|
||||
events = io.StringIO()
|
||||
with unittest.mock.patch.object(install.EVENTS, "stream", events), \
|
||||
contextlib.redirect_stderr(io.StringIO()), self.assertRaises(SystemExit):
|
||||
install._check_free_space(self.root, 5_000, "batocera")
|
||||
said = [json.loads(line) for line in events.getvalue().splitlines()]
|
||||
self.assertEqual(said[0], {"event": "no_space", "platform": "batocera",
|
||||
"folder": str(self.root), "bytes_needed": 5_000,
|
||||
"bytes_free": 1_000})
|
||||
self.assertEqual((said[1]["event"], said[1]["stage"], said[1]["reason"]),
|
||||
("error", "space", "drive_full"))
|
||||
|
||||
def test_probe_climbs_to_an_existing_ancestor(self):
|
||||
missing = self.root / "not" / "created" / "yet"
|
||||
out, code = self._run(free=1, needed=2, path=missing)
|
||||
|
||||
@@ -2998,6 +2998,10 @@ class CardsSpaceAndConfirm(unittest.TestCase):
|
||||
state.dest, state.log = root / "MUOS" / "bios", "/tmp/retrobios-tui-x/install.log"
|
||||
state.stack.append("result")
|
||||
state.code, state.tail = 2, list(self.FULL_TAIL)
|
||||
install._take_event(state, {"event": "no_space", "platform": "retroarch",
|
||||
"folder": str(state.dest),
|
||||
"bytes_needed": 1200 * 1024 * 1024,
|
||||
"bytes_free": 300 * 1024 * 1024})
|
||||
with mock.patch.object(install, "_mounted_cards", return_value=[root]):
|
||||
state.full_drive = install.full_drive_words(state)
|
||||
title, lines = install.tui_outcome(state)
|
||||
@@ -3009,6 +3013,21 @@ class CardsSpaceAndConfirm(unittest.TestCase):
|
||||
self.assertNotIn(raw, text)
|
||||
self.assertFalse(install.tui_keeps_log(state))
|
||||
|
||||
def test_a_reworded_space_line_leaves_the_stop_unchanged(self):
|
||||
"""The result read "Needed: X. Free: Y." from the run's stderr: the
|
||||
numbers come from the no_space event, whatever the line says."""
|
||||
state = checked_state()
|
||||
state.dest = self.card({}) / "bios"
|
||||
install._take_event(state, {"event": "no_space", "platform": "retroarch",
|
||||
"folder": str(state.dest), "bytes_needed": 90010,
|
||||
"bytes_free": 36 * 1024})
|
||||
state.tail = ["Not enough room."]
|
||||
with mock.patch.object(install, "_mounted_cards", return_value=[]):
|
||||
words = install.full_drive_words(state)
|
||||
self.assertEqual(words, "The drive is full: 87.9 KB needed, 36.0 KB free.")
|
||||
state.no_space, state.tail = None, list(self.FULL_TAIL)
|
||||
self.assertEqual(install.full_drive_words(state), "")
|
||||
|
||||
def test_advice_never_names_the_interface_list(self):
|
||||
if hasattr(os, "geteuid") and os.geteuid() == 0:
|
||||
self.skipTest("root writes to a read-only folder")
|
||||
@@ -9649,7 +9668,7 @@ class PacksWordingAndDocs(unittest.TestCase):
|
||||
press(state, "enter")
|
||||
view = " ".join(install.tui_view(state, 120, 40))
|
||||
state.stack = ["result"]
|
||||
state.tail = ["Needed: 87.9 KB. Free: 36.0 KB."]
|
||||
state.no_space = (90010, 36 * 1024)
|
||||
state.full_drive = install.full_drive_words(state)
|
||||
_title, lines = install.tui_outcome(state)
|
||||
self.assertEqual(state.card_bound, ("Onion", "BIOS"))
|
||||
|
||||
Reference in new issue
Block a user