fix: say a settings file detection cannot read

This commit is contained in:
Abdessamad Derraz committed 2026-11-05 19:11:08 +01:00
1 parent 494e390de8
commit 59c8217280
5 files changed
+44 -14

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@
# and Invoke-WebRequest throws on a cut transfer before the hash is read:
# the site's build rewrites this line there (scripts/sitebootstrap.py).
$mismatchAdvice = "The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that."
$defaultInstallSha256 = "144f419239eaf12447b68b293d1c1d15294e45bca2344dea4a9da66fba7582cd"
$defaultInstallSha256 = "bb1da18416aec7c77a6d23c8bf2718cccf5c756ce0cbdbcbf54a6299a03a484f"
$maximumInstallerBytes = 2MB
$installerExit = 0
$installer = if ($PSScriptRoot) { Join-Path $PSScriptRoot "install.py" } else { $null }
+5 -4
View File
@@ -1439,8 +1439,9 @@ def _parse_bash_var(path: Path, key: str) -> str | None:
if line.startswith(f"{key}="):
_, _, value = line.partition("=")
return _shell_unquote(value)
except OSError:
pass
except OSError as exc:
# A settings.sh a sudo EmuDeck run left to root hid the setup.
_note_refused(path, exc)
return None
@@ -1551,8 +1552,8 @@ def _parse_ps1_var(path: Path, key: str) -> str | None:
if check.startswith(f"{normalized}="):
_, _, value = check.partition("=")
return value.strip('"').strip("'")
except OSError:
pass
except OSError as exc:
_note_refused(path, exc)
return None
+1 -1
View File
@@ -23,7 +23,7 @@ DEFAULT_INSTALL_URL="https://raw.githubusercontent.com/Abdess/retrobios/main/ins
# curl or wget stop on a cut transfer before the hash is read: the site's
# build rewrites this line there (scripts/sitebootstrap.py).
MISMATCH_ADVICE="The download was most likely cut short: try again. Within minutes of an update of this project the two files can come from caches of different ages. Waiting five minutes settles that."
DEFAULT_INSTALL_SHA256="144f419239eaf12447b68b293d1c1d15294e45bca2344dea4a9da66fba7582cd"
DEFAULT_INSTALL_SHA256="bb1da18416aec7c77a6d23c8bf2718cccf5c756ce0cbdbcbf54a6299a03a484f"
MAX_INSTALLER_BYTES=2097152
cleanup() {
+8 -8
View File
@@ -27,8 +27,8 @@
{
"dest": "roms/ports/retrobios/install.py",
"repo_path": "install.py",
"size": 1089708,
"sha256": "144f419239eaf12447b68b293d1c1d15294e45bca2344dea4a9da66fba7582cd",
"size": 1089833,
"sha256": "bb1da18416aec7c77a6d23c8bf2718cccf5c756ce0cbdbcbf54a6299a03a484f",
"executable": false
},
{
@@ -71,8 +71,8 @@
"muos": {
"archive": {
"dest": "ARCHIVE/RetroBIOS.muxapp",
"size": 1143335,
"sha256": "9f312c89654b2e3d07fc9f741a3d714c6a14342b27b81fe08f281b159dfeff14"
"size": 1143460,
"sha256": "8074276deabb785c034ecb1c3d5d4c2da3f7772ba17fb29f4f82241e289c7be5"
},
"members": [
{
@@ -92,8 +92,8 @@
{
"name": "RetroBIOS/install.py",
"repo_path": "install.py",
"size": 1089708,
"sha256": "144f419239eaf12447b68b293d1c1d15294e45bca2344dea4a9da66fba7582cd",
"size": 1089833,
"sha256": "bb1da18416aec7c77a6d23c8bf2718cccf5c756ce0cbdbcbf54a6299a03a484f",
"executable": false
},
{
@@ -166,8 +166,8 @@
{
"dest": ".config/modules/retrobios/install.py",
"repo_path": "install.py",
"size": 1089708,
"sha256": "144f419239eaf12447b68b293d1c1d15294e45bca2344dea4a9da66fba7582cd",
"size": 1089833,
"sha256": "bb1da18416aec7c77a6d23c8bf2718cccf5c756ce0cbdbcbf54a6299a03a484f",
"executable": false
},
{
+29
View File
@@ -708,6 +708,35 @@ class AHomeThisUserCannotOpen(unittest.TestCase):
self.assertNotIn("using default path", proc.stdout + proc.stderr)
class ASettingsFileThisUserCannotRead(unittest.TestCase):
"""A sudo EmuDeck run left settings.sh to root: its parser swallowed the
refusal and the run said "No supported platform detected" without a
word on the file, where the same refusal on retroarch.cfg is said."""
def setUp(self):
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
self.addCleanup(shutil.rmtree, self.root, True)
install._DETECTION_REFUSED.clear()
self.addCleanup(install._DETECTION_REFUSED.clear)
install._SETUP_SEARCH.active = True
self.addCleanup(setattr, install._SETUP_SEARCH, "active", False)
def test_each_settings_parser_says_the_refusal(self):
for parse, name in ((install._parse_bash_var, "settings.sh"),
(install._parse_ps1_var, "settings.ps1")):
with self.subTest(file=name):
install._DETECTION_REFUSED.clear()
path = self.root / name
path.write_text('emulationPath="/x"\n', encoding="utf-8")
refusal = PermissionError(errno.EACCES, "Permission denied", str(path))
with mock.patch.object(Path, "read_text", side_effect=refusal), \
mock.patch.object(Path, "read_bytes", side_effect=refusal), \
contextlib.redirect_stderr(io.StringIO()) as err:
self.assertIsNone(parse(path, "emulationPath"))
self.assertEqual(install._DETECTION_REFUSED, [(path, "Permission denied")])
self.assertIn(f"cannot open {path}", err.getvalue())
class TheFrontendsOwnFolderClosed(unittest.TestCase):
"""The Flatpak RetroArch's folder at 000: its retroarch.cfg names
~/Games/bios, and the run took ~/.config/retroarch/system, a folder it