fix: set the raw error flag in one place

The test called main and left --offline and the WSL probe behind for the tests after it. say_raw_errors holds the rule, and the test calls it alone.
This commit is contained in:
Abdessamad Derraz committed 2026-11-10 09:10:34 +01:00
1 parent 482260f599
commit 498fa5cb11
5 files changed
+23 -25

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 = "97cd447f646ffe259805b98bfbdc98b2d5c63acccd823480dadfe331005208f5"
$defaultInstallSha256 = "456a32e79668e125f2ebe573b549247210c59fed6389e78dc1482b57d3a36712"
# The pin above refuses any changed byte: this cap only stops a body that
# cannot be the installer (a sign-in portal's page) before it is hashed.
$maximumInstallerBytes = 8MB
+10 -6
View File
@@ -14245,17 +14245,21 @@ def build_parser() -> argparse.ArgumentParser:
return parser
def say_raw_errors(verbose: bool) -> None:
"""Each run says errors from its own options: a run with --verbose before
it in the same process left every later message with its raw cause."""
if verbose:
_RAW_ERRORS.set()
else:
_RAW_ERRORS.clear()
def main() -> None:
"""Entry point."""
_INVOCATION.os_type = detect_os()
parser = build_parser()
args = parser.parse_args()
# Each run says it from its own options: a run with --verbose before it
# in the same process left every later message with its raw cause.
if args.verbose:
_RAW_ERRORS.set()
else:
_RAW_ERRORS.clear()
say_raw_errors(args.verbose)
if args.cores_dir:
args.installed_cores = True
if args.yes:
+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="97cd447f646ffe259805b98bfbdc98b2d5c63acccd823480dadfe331005208f5"
DEFAULT_INSTALL_SHA256="456a32e79668e125f2ebe573b549247210c59fed6389e78dc1482b57d3a36712"
# The pin above refuses any changed byte: this cap only stops a body that
# cannot be the installer (a sign-in portal's page) before it is hashed.
MAX_INSTALLER_BYTES=8388608
+8 -8
View File
@@ -27,8 +27,8 @@
{
"dest": "roms/ports/retrobios/install.py",
"repo_path": "install.py",
"size": 1162373,
"sha256": "97cd447f646ffe259805b98bfbdc98b2d5c63acccd823480dadfe331005208f5",
"size": 1162452,
"sha256": "456a32e79668e125f2ebe573b549247210c59fed6389e78dc1482b57d3a36712",
"executable": false
},
{
@@ -71,8 +71,8 @@
"muos": {
"archive": {
"dest": "ARCHIVE/RetroBIOS.muxapp",
"size": 1215998,
"sha256": "996a6e24cc5e2d067d86f8f368313e8afd1ba17391b3c595cb8f72e73b208433"
"size": 1216077,
"sha256": "b9e623839a8cf71d929a860b53a6c4c82cbfde551151912e1aba0347532be965"
},
"members": [
{
@@ -92,8 +92,8 @@
{
"name": "RetroBIOS/install.py",
"repo_path": "install.py",
"size": 1162373,
"sha256": "97cd447f646ffe259805b98bfbdc98b2d5c63acccd823480dadfe331005208f5",
"size": 1162452,
"sha256": "456a32e79668e125f2ebe573b549247210c59fed6389e78dc1482b57d3a36712",
"executable": false
},
{
@@ -166,8 +166,8 @@
{
"dest": ".config/modules/retrobios/install.py",
"repo_path": "install.py",
"size": 1162373,
"sha256": "97cd447f646ffe259805b98bfbdc98b2d5c63acccd823480dadfe331005208f5",
"size": 1162452,
"sha256": "456a32e79668e125f2ebe573b549247210c59fed6389e78dc1482b57d3a36712",
"executable": false
},
{
+3 -9
View File
@@ -7839,16 +7839,10 @@ class EachRunSaysErrorsFromItsOwnOptions(unittest.TestCase):
in the same process ended its clock message with the raw SSL text."""
def test_a_run_without_verbose_clears_it(self):
install._RAW_ERRORS.set()
self.addCleanup(install._RAW_ERRORS.clear)
with unittest.mock.patch.object(sys, "argv",
["install.py", "--list-platforms", "--offline"]), \
contextlib.redirect_stdout(io.StringIO()), \
contextlib.redirect_stderr(io.StringIO()):
try:
install.main()
except SystemExit:
pass
install.say_raw_errors(True)
self.assertTrue(install._RAW_ERRORS.is_set())
install.say_raw_errors(False)
self.assertFalse(install._RAW_ERRORS.is_set())