mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-05 17:43:54 -06:00
fix: refuse a --dest this user cannot reach
Path.exists() raised PermissionError from _missing_dest in line mode and from _choose in the interface. The run now names the folder and exits 1 (error event stage dest), and the interface asks for another folder.
This commit is contained in:
1 parent
e61d1e22c0
commit
5c02196b27
4 files changed
+160
-4
No files matched your search
@@ -565,6 +565,35 @@ class AFolderThisUserCannotEnter(unittest.TestCase):
|
||||
os.chmod(locked, 0o755)
|
||||
self.assertEqual(state, "wrong_hash")
|
||||
|
||||
@unittest.skipIf(os.name == "nt" or os.geteuid() == 0,
|
||||
"a folder without search permission is POSIX")
|
||||
def test_a_bios_folder_under_it_is_refused_in_words(self):
|
||||
"""--dest /root/.config/retroarch/system without sudo: _missing_dest
|
||||
ended --check and the install on a PermissionError traceback."""
|
||||
with FakeRepository() as repo:
|
||||
lock = repo.root / "lock"
|
||||
lock.mkdir()
|
||||
repo.dest = lock / "system"
|
||||
os.chmod(lock, 0o000)
|
||||
try:
|
||||
runs = {"check": repo.run("--check"), "install": repo.run(),
|
||||
"events": repo.run("--events")}
|
||||
finally:
|
||||
os.chmod(lock, 0o755)
|
||||
self.assertFalse(repo.dest.exists())
|
||||
for name, proc in runs.items():
|
||||
with self.subTest(run=name):
|
||||
self.assertNotIn("Traceback", proc.stderr)
|
||||
self.assertEqual(proc.returncode, 1, proc.stdout + proc.stderr)
|
||||
self.assertIn(f"this user cannot open {lock} (Permission denied)",
|
||||
proc.stderr)
|
||||
self.assertIn("choose another folder", proc.stderr)
|
||||
events = [json.loads(line) for line in runs["events"].stdout.splitlines()]
|
||||
errors = [e for e in events if e["event"] == "error"]
|
||||
self.assertEqual([(e["stage"], e["reason"]) for e in errors],
|
||||
[("dest", "unreadable")])
|
||||
self.assertIn(str(lock), errors[0]["message"])
|
||||
|
||||
|
||||
class OutputToAFileAsksNothing(unittest.TestCase):
|
||||
"""`install.py > log.txt` at a terminal: the menu went into the file
|
||||
|
||||
Reference in new issue
Block a user