mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-19 09:53:10 -05:00
docs: document every option the scripts accept
Fifty options appeared in no page. fileless_audit also gains --all, so its example sweeps instead of naming three settled profiles, and it and download.py --info now fail on an unknown name or an unreachable source.
This commit is contained in:
1 parent
23ed3e92ab
commit
3116a57617
6 files changed
+183
-7
No files matched your search
@@ -4300,5 +4300,32 @@ class WikiProseHasNoTornSentence(unittest.TestCase):
|
||||
self.fail(f"{page.name}:{number} ends mid-sentence: {line.strip()!r}")
|
||||
|
||||
|
||||
|
||||
class EveryOptionIsDocumented(unittest.TestCase):
|
||||
"""profile_sync's --system, --stale-before and --ref, auto_fetch
|
||||
--create-issues, download.py --info and forty more were in no page: a
|
||||
maintainer ran --all and spent the API quota that --system would have
|
||||
saved. --help lists a flag; only a page says when to reach for it."""
|
||||
|
||||
def test_every_long_option_of_a_tracked_script_is_in_the_docs(self):
|
||||
tracked = subprocess.run(
|
||||
["git", "ls-files", "scripts"], capture_output=True, text=True,
|
||||
cwd=str(ROOT), check=True,
|
||||
).stdout.split()
|
||||
docs = "\n".join(
|
||||
path.read_text(encoding="utf-8")
|
||||
for path in [*sorted((ROOT / "wiki").glob("*.md")),
|
||||
ROOT / "README.md", ROOT / "CONTRIBUTING.md"]
|
||||
)
|
||||
option = re.compile(r'add_argument\(\s*(?:"-\w",\s*)?"(--[\w-]+)"')
|
||||
undocumented = sorted(
|
||||
f"{name}: {flag}"
|
||||
for name in tracked if name.endswith(".py")
|
||||
for flag in set(option.findall((ROOT / name).read_text(encoding="utf-8")))
|
||||
if not re.search(re.escape(flag) + r"(?![\w-])", docs)
|
||||
)
|
||||
self.assertEqual(undocumented, [])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -9,10 +9,12 @@ checksum of each layout and the staging location.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
import functools
|
||||
import hashlib
|
||||
import http.server
|
||||
import importlib.util
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
@@ -94,6 +96,15 @@ def _release(names, base="https://example.invalid", size=10):
|
||||
|
||||
|
||||
class TestPackGrouping(unittest.TestCase):
|
||||
def test_info_on_an_unknown_platform_fails(self):
|
||||
"""--info printed "not found" and exited 0."""
|
||||
release = _release(["EmuDeck_2.3.8_BIOS_Pack.zip"])
|
||||
with contextlib.redirect_stdout(io.StringIO()) as out:
|
||||
with self.assertRaises(SystemExit) as caught:
|
||||
download.show_info("emudek", release)
|
||||
self.assertEqual(caught.exception.code, 1)
|
||||
self.assertIn("EmuDeck", out.getvalue())
|
||||
|
||||
def test_whole_pack_has_one_part(self):
|
||||
packs = download.group_packs(_release(["EmuDeck_2.3.8_BIOS_Pack.zip"]))
|
||||
self.assertEqual([p.name for p in packs], ["EmuDeck_2.3.8_BIOS_Pack.zip"])
|
||||
|
||||
@@ -99,6 +99,53 @@ class TestFilelessAudit(unittest.TestCase):
|
||||
self.assertEqual(len(self._run()), 1)
|
||||
|
||||
|
||||
class TestCommandLine(unittest.TestCase):
|
||||
"""Named profiles were the only mode, so the documented example printed
|
||||
nothing; a misspelt name ended in a traceback and an unreachable source
|
||||
left the run green."""
|
||||
|
||||
def setUp(self):
|
||||
self.tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self.tmp.cleanup)
|
||||
Path(self.tmp.name, "open.yml").write_text(BASE, encoding="utf-8")
|
||||
Path(self.tmp.name, "done.yml").write_text(
|
||||
"emulator: D\nfiles:\n - name: a.bin\n", encoding="utf-8"
|
||||
)
|
||||
|
||||
def _main(self, *argv, audit=None):
|
||||
read = []
|
||||
|
||||
def fake(name, *args):
|
||||
read.append(name)
|
||||
if audit:
|
||||
return audit(name)
|
||||
return []
|
||||
|
||||
with mock.patch.object(sys, "argv", ["fileless_audit.py", *argv,
|
||||
"--emulators-dir", self.tmp.name]), \
|
||||
mock.patch.object(fileless_audit, "audit", side_effect=fake), \
|
||||
mock.patch("sys.stderr"), mock.patch("sys.stdout"):
|
||||
with self.assertRaises(SystemExit) as caught:
|
||||
fileless_audit.main()
|
||||
return caught.exception.code, read
|
||||
|
||||
def test_all_reads_only_the_profiles_nobody_answered(self):
|
||||
code, read = self._main("--all")
|
||||
self.assertEqual((code, read), (0, ["open"]))
|
||||
|
||||
def test_a_misspelt_profile_is_named(self):
|
||||
code, read = self._main("opne")
|
||||
self.assertIn("open", str(code))
|
||||
self.assertEqual(read, [])
|
||||
|
||||
def test_an_unreachable_source_fails_the_run(self):
|
||||
def unreachable(name):
|
||||
raise fileless_audit.upstream.UpstreamError("HTTP 403")
|
||||
|
||||
code, _ = self._main("open", audit=unreachable)
|
||||
self.assertEqual(code, 1)
|
||||
|
||||
|
||||
class TestCorpusIsAnswered(unittest.TestCase):
|
||||
"""Every fileless profile is covered, answered, or flagged.
|
||||
|
||||
|
||||
Reference in new issue
Block a user