mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-29 23:27:19 -05:00
fix: say why detection cannot look, then go on
HOME kept across su without - made every detection probe raise PermissionError, and the run and the interface ended on a traceback. Detection now finds nothing there, says which folder this user cannot open and how to go on, on the first screen too.
This commit is contained in:
1 parent
670f9a614e
commit
bd1c58b6f0
7 files changed
+90
-5
No files matched your search
@@ -1218,7 +1218,9 @@ class ThePortMasterPort(unittest.TestCase):
|
||||
"""The launcher keyed on the words without install.py's prefix, and
|
||||
its fake printed them the same way: the test passed, the device
|
||||
still waited 300 s."""
|
||||
line = f"RetroBIOS: {install.TUI_IDLE_WORDS}"
|
||||
state = install.TuiState(os_type="linux", home=Path.home())
|
||||
state.idle_closed = True
|
||||
line = install._farewell_lines(state)[0]
|
||||
tui = (REPO_ROOT / "ports" / "shared" / "tui.txt").read_text(encoding="utf-8")
|
||||
self.assertIn(f'= "{line}" ]', tui)
|
||||
self.assertIn(f'print("{line}", file=sys.stderr)', FAKE_INSTALL)
|
||||
|
||||
@@ -633,6 +633,39 @@ class ADetectedFolderUnderAClosedOne(unittest.TestCase):
|
||||
self.assertEqual(len(kinds), 2)
|
||||
|
||||
|
||||
class AHomeThisUserCannotOpen(unittest.TestCase):
|
||||
"""HOME kept across `su` without `-`: detection stat'ed files under it
|
||||
and ended the run on a PermissionError traceback before any line."""
|
||||
|
||||
@unittest.skipIf(os.name == "nt" or os.geteuid() == 0,
|
||||
"a folder without search permission is POSIX")
|
||||
def test_detection_says_so_and_the_run_goes_on(self):
|
||||
with FakeRepository() as repo:
|
||||
home = repo.root / "home"
|
||||
home.mkdir()
|
||||
env = {**repo.env(), "HOME": str(home), "RETROBIOS_OS": "linux"}
|
||||
runs = {}
|
||||
os.chmod(home, 0o000)
|
||||
try:
|
||||
for name, extra in (("named", ["--platform", "retroarch", "--dest",
|
||||
str(repo.dest)]),
|
||||
("detected", [])):
|
||||
runs[name] = subprocess.run(
|
||||
[sys.executable, str(REPO_ROOT / "install.py"), "--check",
|
||||
"--no-input", *extra],
|
||||
env=env, capture_output=True, text=True, timeout=60,
|
||||
stdin=subprocess.DEVNULL)
|
||||
finally:
|
||||
os.chmod(home, 0o755)
|
||||
for name, proc in runs.items():
|
||||
with self.subTest(run=name):
|
||||
self.assertNotIn("Traceback", proc.stderr)
|
||||
# A named folder needs no detection and is checked.
|
||||
self.assertIn("0/5 present", runs["named"].stdout)
|
||||
self.assertIn(f"Could not look for setups: this user cannot open {home}",
|
||||
runs["detected"].stderr)
|
||||
|
||||
|
||||
class OutputToAFileAsksNothing(unittest.TestCase):
|
||||
"""`install.py > log.txt` at a terminal: the menu went into the file
|
||||
and the run waited on an answer to a prompt nobody could see."""
|
||||
|
||||
@@ -2930,6 +2930,20 @@ class AFolderThisUserCannotOpen(unittest.TestCase):
|
||||
self.assertIn(f"This user cannot open {install._short_path(self.lock, state.home)} "
|
||||
"(Permission denied)", self.said(state))
|
||||
|
||||
def test_a_home_it_cannot_open_is_said_on_the_first_screen(self):
|
||||
"""HOME kept across su without -: detection raised PermissionError
|
||||
before the first screen."""
|
||||
home = self.lock.parent / "home"
|
||||
home.mkdir()
|
||||
os.chmod(home, 0o000)
|
||||
self.addCleanup(os.chmod, home, 0o755)
|
||||
install._DETECTION_REFUSED.clear()
|
||||
self.addCleanup(install._DETECTION_REFUSED.clear)
|
||||
with mock.patch.dict(os.environ, {"HOME": str(home)}), \
|
||||
mock.patch.object(install, "_mounted_cards", return_value=[]):
|
||||
state, _effects = install.tui_start(_args(), "linux")
|
||||
self.assertIn("Could not look for setups: this user cannot open", self.said(state))
|
||||
|
||||
def test_the_nearest_folder_stops_above_it(self):
|
||||
self.assertEqual(install._nearest_folder(self.dest / "deeper"), self.lock)
|
||||
|
||||
|
||||
Reference in new issue
Block a user