mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-01 00:27:20 -05:00
fix: no unsearched event from a quiet config read
This commit is contained in:
1 parent
78de625294
commit
44093ba20a
2 files changed
+41
-3
No files matched your search
+11
-3
@@ -1969,7 +1969,8 @@ def _note_refused(path: Path, exc: OSError) -> None:
|
||||
retroarch.cfg was readable, and the run fell back to a folder it does
|
||||
not read.
|
||||
"""
|
||||
if not getattr(_SETUP_SEARCH, "active", False) or not isinstance(exc, PermissionError):
|
||||
if (not getattr(_SETUP_SEARCH, "active", False) or getattr(_SETUP_SEARCH, "quiet", False)
|
||||
or not isinstance(exc, PermissionError)):
|
||||
return
|
||||
refused = closed_folder(path) or (path, exc.strerror or str(exc))
|
||||
if refused in _DETECTION_REFUSED:
|
||||
@@ -4082,8 +4083,15 @@ def _retroarch_config_for(bios_path: Path) -> tuple[Path, Path] | None:
|
||||
if found is not None or _CONFIGS_READ:
|
||||
return found
|
||||
_CONFIGS_READ.append(True)
|
||||
with contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr(io.StringIO()):
|
||||
detect_platforms(_INVOCATION.os_type or detect_os())
|
||||
# Silent, the unsearched event too: this run searched for no setup, and
|
||||
# the event came after detect, the line it stands for never shown.
|
||||
_SETUP_SEARCH.quiet = True
|
||||
try:
|
||||
with contextlib.redirect_stdout(io.StringIO()), \
|
||||
contextlib.redirect_stderr(io.StringIO()):
|
||||
detect_platforms(_INVOCATION.os_type or detect_os())
|
||||
finally:
|
||||
_SETUP_SEARCH.quiet = False
|
||||
return _retroarch_config_at(bios_path)
|
||||
|
||||
|
||||
|
||||
@@ -1019,5 +1019,35 @@ class AClosedFolderBehindALink(unittest.TestCase):
|
||||
self.assertEqual(why, os.strerror(errno.ELOOP))
|
||||
|
||||
|
||||
@unittest.skipIf(os.name == "nt" or os.geteuid() == 0,
|
||||
"a folder without search permission is POSIX")
|
||||
class TheQuietConfigReadSaysNothing(unittest.TestCase):
|
||||
"""With --dest the run searches for no setup, and the configs read for
|
||||
the save directory wrote an unsearched event after detect, for a line
|
||||
the human output never showed."""
|
||||
|
||||
def test_no_event_and_no_line(self):
|
||||
base = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
|
||||
self.addCleanup(shutil.rmtree, base, True)
|
||||
closed = base / "home" / ".config" / "EmuDeck"
|
||||
closed.mkdir(parents=True)
|
||||
os.chmod(closed, 0o000)
|
||||
self.addCleanup(os.chmod, closed, 0o755)
|
||||
emitted = []
|
||||
install._DETECTION_REFUSED.clear()
|
||||
self.addCleanup(install._DETECTION_REFUSED.clear)
|
||||
with mock.patch.dict(os.environ, {"HOME": str(base / "home"),
|
||||
"XDG_CONFIG_HOME": str(base / "home" / ".config")}), \
|
||||
mock.patch.object(install, "_CONFIGS_READ", []), \
|
||||
mock.patch.object(install, "_RETROARCH_CONFIGS", {}), \
|
||||
mock.patch.object(install.EVENTS, "emit",
|
||||
lambda kind, **fields: emitted.append(kind)), \
|
||||
contextlib.redirect_stderr(io.StringIO()) as err:
|
||||
install._retroarch_config_for(base / "bios")
|
||||
self.assertNotIn("unsearched", emitted)
|
||||
self.assertEqual(err.getvalue(), "")
|
||||
self.assertEqual(install._DETECTION_REFUSED, [])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user