feat: serve the one-line installer from the site

The site serves install.sh at /retrobios/i and install.ps1 at
/retrobios/i.ps1. generate_site.py writes both copies with the
installer address set to install.py at the commit the site is built
from (GITHUB_SHA in CI, HEAD locally), so the pinned SHA-256 and the
downloaded installer always come from one commit, including while a
deploy is still running.

Every command a user copies names the short address. The raw form
stays on the installer page as the fallback. Deploy Site now runs on
changes to install.sh and install.ps1. The install box weight keeps
the address length its ratio was fitted on, so no console page moves.
This commit is contained in:
Abdessamad Derraz committed 2026-10-28 05:47:38 +01:00
1 parent 7c3e6ced09
commit 9e6af0aa6b
37 files changed
+486 -110

No files matched your search

+19 -7
View File
@@ -59,14 +59,22 @@ class ReadmeRegressions(unittest.TestCase):
)[0]
def test_advertised_bootstrap_urls_are_the_shipped_ones(self):
import sitebootstrap
from siteguides import INSTALL_BASE
quick_install = self._quick_install()
for script in ("install.sh", "install.ps1"):
url = f"https://raw.githubusercontent.com/Abdess/retrobios/main/{script}"
self.assertIn(url, quick_install, f"{script} bootstrap URL missing")
for name in sitebootstrap.SOURCES:
url = f"{INSTALL_BASE}/{name}"
self.assertIn(f"{url} |", quick_install, f"{name} bootstrap URL missing")
# The site serves each bootstrap with install.py read from the
# commit it was built from, the raw form from main.
commit = "0" * 40
for name in sitebootstrap.SOURCES:
self.assertIn(sitebootstrap.installer_url(commit),
sitebootstrap.served_text(name, ROOT, commit))
self.assertIn(
"https://raw.githubusercontent.com/Abdess/retrobios/main/install.py",
(ROOT / "install.sh").read_text(encoding="utf-8"),
"install.sh must fetch install.py from the ref the README advertises",
)
def test_advertised_installer_flags_exist(self):
@@ -690,9 +698,11 @@ class PackReadmesSayWhatTheInstallerDoes(unittest.TestCase):
return text[text.index("INSTALLATION"):text.index("TROUBLESHOOTING")]
def test_retroarch_offers_the_windows_installer(self):
from siteguides import INSTALL_PS1, INSTALL_SH
guide = self._guide("retroarch")
self.assertIn("install.sh | sh", guide)
self.assertIn("install.ps1 | iex", guide)
self.assertIn(f"{INSTALL_SH} | sh", guide)
self.assertIn(f"{INSTALL_PS1} | iex", guide)
def test_emudeck_keys_match_the_registry_and_the_flag(self):
import re
@@ -715,8 +725,10 @@ class PackReadmesSayWhatTheInstallerDoes(unittest.TestCase):
def test_retropie_never_sends_a_pc_to_the_linux_partition(self):
guide = self._guide("retropie")
from siteguides import INSTALL_SH
self.assertNotIn("Put the SD card in your PC", guide)
self.assertIn("install.sh | sh", guide)
self.assertIn(f"{INSTALL_SH} | sh", guide)
class AutoFetchReadsListsAndPlacesWithoutClobbering(unittest.TestCase):
+4 -2
View File
@@ -663,12 +663,14 @@ class ReadmeInstallerOptions(unittest.TestCase):
import generate_readme
source = inspect.getsource(generate_readme.generate_readme)
self.assertIn("&([scriptblock]::Create((irm https://raw.githubusercontent.com/Abdess/retrobios/main/install.ps1)))", source)
self.assertIn('install_command("powershell", "--check")', source)
self.assertIn("wiki/installer/#passing-options", source)
self.assertIn("## Passing options", _page("installer.md"))
readme = (ROOT / "README.md").read_text(encoding="utf-8")
quick = _section(readme, "Quick install")
self.assertIn("[scriptblock]::Create", quick)
from siteguides import INSTALL_PS1
self.assertIn(f"&([scriptblock]::Create((irm {INSTALL_PS1}))) --check", quick)
self.assertIn("wiki/installer/#passing-options", quick)
self.assertNotRegex(readme, r"(?m)^irm \S+ \| iex \S")
+1 -1
View File
@@ -267,7 +267,7 @@ class EndUsersCheckTheirOwnFolder(unittest.TestCase):
def test_the_download_page_gives_the_one_liner_check(self):
page = _which_pack()
self.assertNotIn("from a checkout", page)
self.assertIn("install.sh | sh -s -- --check", page)
self.assertIn("/i | sh -s -- --check", page)
def test_the_readme_does_not_call_verify_a_check_of_your_bios(self):
self.assertNotIn("Verify your BIOS collection", _read("README.md"))
+4 -4
View File
@@ -1911,7 +1911,7 @@ class TestManualPlatformPrompt(unittest.TestCase):
with unittest.mock.patch.dict(os.environ, {"RETROBIOS_BOOTSTRAP": "ps1"}):
hint = "\n".join(install._manual_usage_hint("windows"))
self.assertIn("--platform retroarch --dest", hint)
self.assertIn("install.ps1", hint)
self.assertIn("/i.ps1", hint)
class TestSteamRetroarchDetection(unittest.TestCase):
@@ -3983,7 +3983,7 @@ class HintsGiveTheUsersOwnCommandBack(unittest.TestCase):
def test_the_shell_one_liner_is_rebuilt(self):
with unittest.mock.patch.dict(os.environ, {"RETROBIOS_BOOTSTRAP": "sh"}):
hint = "\n".join(install._manual_usage_hint("linux"))
self.assertIn("install.sh | sh -s -- --platform retroarch", hint)
self.assertIn("/i | sh -s -- --platform retroarch", hint)
self.assertNotIn("python3 install.py", hint)
self.assertIn(install.INSTALLER_PAGE, hint)
@@ -4028,7 +4028,7 @@ class HintsGiveTheUsersOwnCommandBack(unittest.TestCase):
False, "retroarch")
self.assertNotIn("sudo", advice)
self.assertIn("administrator", advice)
self.assertIn("install.ps1", advice)
self.assertIn("/i.ps1", advice)
self.assertIn("--system atari-lynx", advice)
def test_a_full_drive_keeps_the_platform(self):
@@ -4070,7 +4070,7 @@ class HintsGiveTheUsersOwnCommandBack(unittest.TestCase):
proc = _install_run(env, "--help")
self.assertEqual(proc.returncode, 0)
self.assertIn("examples:", proc.stdout)
self.assertIn("install.sh | sh -s -- --platform batocera --dest", proc.stdout)
self.assertIn("/i | sh -s -- --platform batocera --dest", proc.stdout)
self.assertIn(install.INSTALLER_PAGE, proc.stdout)
+3 -5
View File
@@ -9930,14 +9930,12 @@ class TheAndroidResultReadsWhole(unittest.TestCase):
self.assertIn("--restore", words)
self.assertTrue(all(not word.endswith("/") for word in words), words)
state = _installed_state(Path("/sdcard/RetroArch/system"))
command = install._styled("curl -fsSL https://raw.githubusercontent.com/Abdess/"
"retrobios/main/install.sh | sh -s -- --restore "
command = install._styled(f"curl -fsSL {install.BOOTSTRAP_URL} | sh -s -- --restore "
"'/storage/emulated/0/a b/20261027-223524'", "command")
state.stack.append("result")
pieces = install._text_lines([command], 38, whole=True)
joined = [str(piece).strip() for piece in pieces if piece.style != "cont"]
self.assertIn("https://raw.githubusercontent.com/Abdess/retrobios/main/install.sh",
joined)
self.assertIn(install.BOOTSTRAP_URL, joined)
self.assertIn("'/storage/emulated/0/a b/20261027-223524'", joined)
def test_a_long_line_folds_in_the_terminal(self):
@@ -10770,7 +10768,7 @@ class AuditNineteenAndTwelve(_CardFixtures, unittest.TestCase):
lines = drawn(state, cols, 30)
self.assertFalse(install.tui_wants_mouse(state, lines))
if bootstrap:
url = "https://raw.githubusercontent.com/Abdess/retrobios/main/install.sh"
url = install.BOOTSTRAP_URL
words = [word for line in lines for word in str(line).split()]
self.assertIn(url, words)
+7 -5
View File
@@ -75,8 +75,8 @@ class TheOneLinerFollowsTheRegistry(unittest.TestCase):
continue
text = _guide(name)
with self.subTest(platform=name):
self.assertEqual("install.sh | sh" in text, bool(systems - {"windows"}))
self.assertEqual("install.ps1 | iex" in text, "windows" in systems)
self.assertEqual("/i | sh" in text, bool(systems - {"windows"}))
self.assertEqual("/i.ps1 | iex" in text, "windows" in systems)
def test_rocknix_and_mister_run_it_on_the_device(self):
for name in ("rocknix", "misterfpga"):
@@ -87,7 +87,7 @@ class TheOneLinerFollowsTheRegistry(unittest.TestCase):
text = _guide("emudeck")
self.assertNotIn("Steam Deck / Linux", text)
self.assertNotIn("Konsole", text)
self.assertIn("install.ps1 | iex", text)
self.assertIn("/i.ps1 | iex", text)
self.assertIn("C:\\Emulation\\bios", text)
self.assertIn("--standalone-copies", text)
@@ -101,12 +101,14 @@ class TheOneLinerFollowsTheRegistry(unittest.TestCase):
"""The address comes from install_base in platforms/_guides.yml, the
one the site's commands use."""
import packreadme
import sitebootstrap
from siteguides import INSTALL_BASE
source = (REPO_ROOT / "scripts" / "packreadme.py").read_text(encoding="utf-8")
self.assertNotIn("raw.githubusercontent.com", source)
self.assertEqual(packreadme.INSTALL_SH, f"{INSTALL_BASE}/install.sh")
self.assertEqual(packreadme.INSTALL_PS1, f"{INSTALL_BASE}/install.ps1")
self.assertNotIn("abdess.github.io", source)
self.assertEqual(packreadme.INSTALL_SH, f"{INSTALL_BASE}/{sitebootstrap.SH_NAME}")
self.assertEqual(packreadme.INSTALL_PS1, f"{INSTALL_BASE}/{sitebootstrap.PS1_NAME}")
if __name__ == "__main__":
+1 -1
View File
@@ -321,7 +321,7 @@ class EveryPlatformHasAPermanentPage(unittest.TestCase):
f"/releases/download/{record['tag']}/{asset}", page)
elif name not in RELEASED:
self.assertNotIn("_BIOS_Pack", page)
self.assertIn(f"install.sh | sh -s -- --platform {name}", page)
self.assertIn(f"/i | sh -s -- --platform {name}", page)
self.assertIn("No ZIP for ", page)
def test_the_generator_writes_and_sweeps_them(self):
+232
View File
@@ -0,0 +1,232 @@
"""The one-line commands the site serves.
`curl -fsSL https://abdess.github.io/retrobios/i | sh` and the PowerShell
`i.ps1` replaced a raw.githubusercontent.com address of 70 characters. The
site deploys some eleven minutes after a push: a copy that pinned one
commit's installer and downloaded another's would refuse every install for
that long, so each copy reads install.py from the commit it was built from.
"""
from __future__ import annotations
import hashlib
import json
import os
import re
import subprocess
import sys
import tempfile
import unittest
from pathlib import Path
from unittest import mock
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT))
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import install # noqa: E402
import sitebootstrap # noqa: E402
from siteguides import INSTALL_BASE, INSTALL_PS1, INSTALL_SH, install_command # noqa: E402
WEBSITE = REPO_ROOT / "website"
DOCS = WEBSITE / "src" / "content" / "docs"
OLD_SH = "raw.githubusercontent.com/Abdess/retrobios/main/install.sh"
OLD_PS1 = "raw.githubusercontent.com/Abdess/retrobios/main/install.ps1"
def _head() -> str:
return subprocess.run(["git", "rev-parse", "HEAD"], cwd=REPO_ROOT, check=True,
capture_output=True, text=True).stdout.strip()
def _pin(text: str) -> str:
match = re.search(r'(?:DEFAULT_INSTALL_SHA256="|\$defaultInstallSha256 = ")([0-9a-f]{64})"',
text)
assert match, "no installer pin"
return match.group(1)
class ServedCopies(unittest.TestCase):
def setUp(self):
self.commit = _head()
def test_each_copy_is_its_bootstrap_but_for_the_installer_address(self):
for name, (source, _line) in sitebootstrap.SOURCES.items():
with self.subTest(name=name):
original = (REPO_ROOT / source).read_text(encoding="utf-8").splitlines()
served = sitebootstrap.served_text(name, REPO_ROOT, self.commit).splitlines()
self.assertEqual(len(original), len(served))
changed = [(a, b) for a, b in zip(original, served) if a != b]
self.assertEqual(len(changed), 1, changed)
before, after = changed[0]
self.assertIn("https://raw.githubusercontent.com/Abdess/retrobios/main/install.py",
before)
self.assertEqual(after, before.replace(
"https://raw.githubusercontent.com/Abdess/retrobios/main/install.py",
sitebootstrap.installer_url(self.commit)))
def test_the_address_names_the_commit_whose_installer_the_pin_holds(self):
installer = hashlib.sha256((REPO_ROOT / "install.py").read_bytes()).hexdigest()
url = f"https://raw.githubusercontent.com/Abdess/retrobios/{self.commit}/install.py"
for name in sitebootstrap.SOURCES:
with self.subTest(name=name):
text = sitebootstrap.served_text(name, REPO_ROOT, self.commit)
self.assertIn(f'"{url}"', text)
self.assertEqual(_pin(text), installer)
def test_ci_builds_from_the_pushed_commit(self):
pushed = "a" * 40
with mock.patch.dict(os.environ, {"GITHUB_SHA": pushed}):
self.assertEqual(sitebootstrap.build_commit(REPO_ROOT), pushed)
with mock.patch.dict(os.environ, {"GITHUB_SHA": "main"}), \
self.assertRaises(ValueError):
sitebootstrap.build_commit(REPO_ROOT)
with mock.patch.dict(os.environ, {"GITHUB_SHA": ""}):
self.assertEqual(sitebootstrap.build_commit(REPO_ROOT), self.commit)
def test_the_copies_land_at_the_root_of_the_public_folder(self):
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp" if (REPO_ROOT / "tmp").is_dir()
else None) as scratch:
public = Path(scratch) / "public"
written = sitebootstrap.write_bootstraps(public, REPO_ROOT, self.commit)
self.assertEqual(sorted(p.name for p in written), ["i", "i.ps1"])
for path in written:
self.assertEqual(path.read_text(encoding="utf-8"),
sitebootstrap.served_text(path.name, REPO_ROOT, self.commit))
def test_a_bootstrap_without_its_address_line_stops_the_build(self):
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp" if (REPO_ROOT / "tmp").is_dir()
else None) as scratch:
root = Path(scratch)
(root / "install.sh").write_text("#!/bin/sh\n", encoding="utf-8")
with self.assertRaises(ValueError):
sitebootstrap.served_text("i", root, self.commit)
class DocumentedCommands(unittest.TestCase):
def test_the_addresses_are_the_served_paths(self):
config = (WEBSITE / "astro.config.mjs").read_text(encoding="utf-8")
site = re.search(r"const SITE = '([^']+)'", config).group(1)
base = re.search(r"const BASE = '([^']+)'", config).group(1)
self.assertEqual(f"{INSTALL_BASE}/", site + base)
self.assertEqual(INSTALL_SH, f"{site}{base}{sitebootstrap.SH_NAME}")
self.assertEqual(INSTALL_PS1, f"{site}{base}{sitebootstrap.PS1_NAME}")
self.assertEqual(install.BOOTSTRAP_URL, INSTALL_SH)
self.assertEqual(f"{install.BOOTSTRAP_URL}.ps1", INSTALL_PS1)
def test_the_installer_hints_give_the_short_command(self):
with mock.patch.dict(os.environ, {"RETROBIOS_BOOTSTRAP": "sh"}):
self.assertEqual(install.Invocation().launcher(), f"curl -fsSL {INSTALL_SH} | sh -s --")
with mock.patch.dict(os.environ, {"RETROBIOS_BOOTSTRAP": "ps1"}):
self.assertEqual(install.Invocation().launcher(),
f"&([scriptblock]::Create((irm {INSTALL_PS1})))")
def test_every_page_a_user_copies_from_gives_the_short_command(self):
sources = {
"wiki/installer.md": [install_command("sh"), install_command("powershell")],
"wiki/first-install.md": [install_command("sh"), install_command("powershell")],
"wiki/faq.md": [f"curl -fsSL {INSTALL_SH} | sh -s -- --dry-run"],
"wiki/troubleshooting.md": [install_command("sh", "--check")],
"wiki/tools.md": [install_command("sh"), install_command("powershell")],
"website/src/components/FilePicker.astro": [f"'curl -fsSL {INSTALL_SH} | sh -s --'"],
"scripts/download.sh": [f"curl -fsSL {INSTALL_SH} | sh -s -- --platform <name>"],
"scripts/download.py": [f"curl -fsSL {INSTALL_SH} | sh -s -- --platform <name>"],
}
for rel, commands in sources.items():
text = (REPO_ROOT / rel).read_text(encoding="utf-8")
for command in commands:
with self.subTest(file=rel, command=command):
self.assertIn(command, text)
def test_the_raw_form_is_written_once_as_the_fallback(self):
"""The long address stays on the installer page only, for the day
the site is down."""
surfaces = [*sorted((REPO_ROOT / "wiki").glob("*.md")), REPO_ROOT / "README.md",
REPO_ROOT / "CONTRIBUTING.md", REPO_ROOT / "install.py",
*sorted((REPO_ROOT / "scripts").rglob("*.py")),
REPO_ROOT / "scripts" / "download.sh",
*sorted((WEBSITE / "src" / "components").glob("*.astro"))]
found = {
str(path.relative_to(REPO_ROOT)): text.count(OLD_SH) + text.count(OLD_PS1)
for path in surfaces
for text in [path.read_text(encoding="utf-8")]
if OLD_SH in text or OLD_PS1 in text
}
self.assertEqual(found, {"wiki/installer.md": 2})
def test_typed_by_hand_without_the_scheme(self):
page = (REPO_ROOT / "wiki" / "installer.md").read_text(encoding="utf-8")
bare = INSTALL_BASE.removeprefix("https://")
self.assertIn(f"curl -fL {bare}/{sitebootstrap.SH_NAME} | sh", page)
self.assertIn(f"irm {bare}/{sitebootstrap.PS1_NAME} | iex", page)
class NothingElseAtTheseAddresses(unittest.TestCase):
"""A page or a folder named i would take the address, or turn it into a
redirect to i/ that `curl | sh` reads as HTML."""
NAMES = tuple(sitebootstrap.SOURCES)
def test_no_source_page_takes_the_names(self):
for folder in (REPO_ROOT / "wiki", WEBSITE / "src" / "pages"):
taken = sorted(str(path.relative_to(REPO_ROOT)) for path in folder.glob("i*")
if path.name == "i" or path.name.split(".", 1)[0] == "i")
with self.subTest(folder=str(folder.relative_to(REPO_ROOT))):
self.assertEqual(taken, [])
@unittest.skipUnless(DOCS.is_dir(), "site not generated")
def test_no_generated_page_or_redirect_takes_the_names(self):
for name in self.NAMES:
stem = name.split(".", 1)[0]
with self.subTest(name=name):
self.assertFalse((DOCS / stem).exists())
self.assertEqual(sorted(DOCS.glob(f"{stem}.md*")), [])
redirects = WEBSITE / "src" / "generated" / "redirects.json"
if redirects.is_file():
sources = {key.strip("/").removeprefix("retrobios/")
for key in json.loads(redirects.read_text(encoding="utf-8"))}
self.assertEqual(sources & set(self.NAMES), set())
@unittest.skipUnless((WEBSITE / "dist" / "index.html").is_file(), "site not built")
def test_the_built_site_serves_files_at_the_addresses(self):
for name in self.NAMES:
path = WEBSITE / "dist" / name
with self.subTest(name=name):
self.assertTrue(path.is_file())
text = path.read_text(encoding="utf-8")
self.assertRegex(text, r"raw\.githubusercontent\.com/Abdess/retrobios/[0-9a-f]{40}/"
r"install\.py")
class GeneratedSurfaces(unittest.TestCase):
def test_a_shorter_address_moves_no_section(self):
"""The install boxes weigh in the split of a manufacturer's page,
fitted on the 66-character raw address: weighed at their new length,
Nintendo DS fell back onto the Nintendo summary and lost its page."""
import generate_site
tail = " | sh -s -- --check"
self.assertEqual(generate_site._install_box_weight([f"curl -fsSL {INSTALL_SH}{tail}"]),
len("curl -fsSL ") + 66 + len(tail) + 1)
line = f"&([scriptblock]::Create((irm {INSTALL_PS1}))) --check"
self.assertEqual(generate_site._install_box_weight([line]),
len(line) - len(INSTALL_PS1) + 67 + 1)
def test_the_readme_shows_the_short_form(self):
readme = (REPO_ROOT / "README.md").read_text(encoding="utf-8")
quick = readme.split("## Quick install", 1)[1].split("\n## ", 1)[0]
self.assertIn(f"\n{install_command('sh')}\n", quick)
self.assertIn(f"\n{install_command('powershell')}\n", quick)
self.assertNotIn("raw.githubusercontent.com", quick)
@unittest.skipUnless(DOCS.is_dir(), "site not generated")
def test_the_site_shows_the_short_form(self):
pages = {path: path.read_text(encoding="utf-8") for path in DOCS.rglob("*.md*")}
self.assertTrue(any(INSTALL_SH in text for text in pages.values()))
long_form = sorted(str(path.relative_to(DOCS)) for path, text in pages.items()
if OLD_SH in text or OLD_PS1 in text)
self.assertEqual(long_form, ["wiki/installer.md"])
if __name__ == "__main__":
unittest.main()
+4 -4
View File
@@ -207,10 +207,10 @@ class AnInstallBoxShowsOneCommand(unittest.TestCase):
listed = self.text[self.text.index('<details class="rb-install-all" open>'):]
for platform, _system in PAIRS:
self.assertEqual(listed.count(f"--platform {platform} --system"), 2, platform)
self.assertIn("install.sh | sh -s -- --platform retrobat --system 'Neo Geo'</code>", listed)
self.assertIn("install.ps1))) --platform retrobat --system 'Neo Geo'</code>", listed)
self.assertIn("/i | sh -s -- --platform retrobat --system 'Neo Geo'</code>", listed)
self.assertIn("/i.ps1))) --platform retrobat --system 'Neo Geo'</code>", listed)
# The URL is no link inside the command, and the break adds nothing.
self.assertIn("https://<wbr>raw.githubusercontent.com", listed)
self.assertIn("https://<wbr>abdess.github.io", listed)
def test_one_setup_keeps_its_two_blocks(self) -> None:
text = "\n".join(gs._console_install_block("PlayStation Portable", PAIRS[:1]))
@@ -225,7 +225,7 @@ class AnInstallBoxShowsOneCommand(unittest.TestCase):
text = "\n".join(gs._console_install_block("PlayStation Portable", PAIRS))
self.assertNotIn("<select", text)
self.assertEqual(text.count("# RetroBat"), 2)
self.assertEqual(text.count("install.sh | sh"), 3)
self.assertEqual(text.count("/i | sh"), 3)
class TheSetupListLooksLikeAList(unittest.TestCase):
+6 -6
View File
@@ -902,8 +902,8 @@ class AnEmulatorPageOffersItsInstall(unittest.TestCase):
profile = yaml.safe_load((ROOT / "emulators" / "pcem.yml").read_text(encoding="utf-8"))
text = "\n".join(_install_block("pcem", profile))
self.assertIn("install.sh | sh -s -- --emulator pcem", text)
self.assertIn("install.ps1))) --emulator pcem", text)
self.assertIn("/i | sh -s -- --emulator pcem", text)
self.assertIn("/i.ps1))) --emulator pcem", text)
self.assertEqual(_install_block("x", {"type": "alias"}), [])
def test_the_installer_takes_the_option(self):
@@ -969,7 +969,7 @@ class TheOneLinerIsWhereUsersLand(unittest.TestCase):
page = generate_site.generate_which_pack()
self.assertIn("Android (Termux", page)
self.assertIn("install.ps1))) --check", page)
self.assertIn("/i.ps1))) --check", page)
self.assertIn("--platform retroarch --dest", page)
def test_platform_and_system_pages(self):
@@ -979,14 +979,14 @@ class TheOneLinerIsWhereUsersLand(unittest.TestCase):
cov = {"platform": "Batocera", "mode": "md5", "present": 0, "total": 0,
"verified": 0, "missing": 0, "details": [], "config": {"systems": {}}}
page = generate_site.generate_platform_page("batocera", cov)
self.assertIn("install.sh | sh -s -- --platform batocera", page)
self.assertIn("/i | sh -s -- --platform batocera", page)
# Batocera runs the command on the device itself, so its page opens on
# the computer route. A platform detected on Windows gets the
# PowerShell form, and its command comes before the ZIP.
cov = dict(cov, platform="RetroArch", mode="existence")
page = generate_site.generate_platform_page("retroarch", cov)
self.assertIn("install.ps1))) --platform retroarch", page)
self.assertIn("install.sh | sh -s -- --platform retroarch", page)
self.assertIn("/i.ps1))) --platform retroarch", page)
self.assertIn("/i | sh -s -- --platform retroarch", page)
self.assertLess(page.index("--platform retroarch"), page.index("rb-button"))
entry = {"name": "a.bin", "sha1": "a" * 40, "md5": "b" * 32, "size": 3,
+5 -5
View File
@@ -279,23 +279,23 @@ class CommandBlocks(unittest.TestCase):
def test_shell_lines_have_a_powershell_form(self):
text = _page("which-pack.md")
groups = re.findall(r"<Tabs.*?</Tabs>|<details.*?</details>", text, re.S)
commands = [group for group in groups if "install.sh | sh" in group]
commands = [group for group in groups if "/i | sh" in group]
self.assertGreaterEqual(len(commands), 3)
for group in commands:
self.assertIn("install.ps1", group)
self.assertIn("/i.ps1", group)
block = "\n".join(generate_site._console_install_block(
"PlayStation", [("batocera", "psx"), ("recalbox", "psx")]))
# Every setup's options in both forms: the list of every command,
# and the one command under the OS tabs.
sh_args = re.findall(r"install\.sh \| sh -s -- ([^<\n]+)", block)
ps_args = re.findall(r"install\.ps1\)\)\) ([^<\n]+)", block)
sh_args = re.findall(r"/i \| sh -s -- ([^<\n]+)", block)
ps_args = re.findall(r"/i\.ps1\)\)\) ([^<\n]+)", block)
self.assertEqual(sorted(set(sh_args)), sorted(set(ps_args)))
self.assertEqual(len(set(sh_args)), 2)
self.assertIn('```powershell title="PowerShell"', block)
for key, guide in siteguides.GUIDES.items():
if "windows" in guide.run:
with self.subTest(platform=key):
self.assertIn("install.ps1", _guide_part(_page(f"platforms/{key}.md")))
self.assertIn("/i.ps1", _guide_part(_page(f"platforms/{key}.md")))
class ContributingOpensOnTheAction(unittest.TestCase):
+2 -2
View File
@@ -22,7 +22,7 @@ sys.path.insert(0, str(REPO_ROOT / "scripts"))
sys.path.insert(0, str(REPO_ROOT))
import sitediagrams # noqa: E402
from siteguides import INSTALL_BASE # noqa: E402
from siteguides import INSTALL_SH # noqa: E402
from tests import sitepages # noqa: E402
@@ -108,7 +108,7 @@ class InstallCommandsHaveEveryForm(unittest.TestCase):
def test_a_windows_path_replaces_the_unix_one(self):
page = (
"<!-- os-tabs windows: --platform retroarch --dest E:\\x -->\n```sh\n"
f"curl -fsSL {INSTALL_BASE}/install.sh \\\n | sh -s -- --platform retroarch --dest /a/b\n```\n"
f"curl -fsSL {INSTALL_SH} \\\n | sh -s -- --platform retroarch --dest /a/b\n```\n"
)
text = sitediagrams.expand_commands(page)
windows, rest = text.split('<TabItem label="macOS">', 1)
+2 -2
View File
@@ -22,7 +22,7 @@ sys.path.insert(0, str(REPO_ROOT))
sys.path.insert(0, str(REPO_ROOT / "scripts"))
import sitediagrams # noqa: E402
from siteguides import INSTALL_BASE # noqa: E402
from siteguides import INSTALL_SH # noqa: E402
from tests import sitepages # noqa: E402
WIKI = REPO_ROOT / "wiki"
@@ -113,7 +113,7 @@ class OsTabsTakeOptionsPerSystem(unittest.TestCase):
"""The marker gives any tab its own options, and refuses words it cannot read."""
PAGE = ("<!-- os-tabs windows: --dest E:\\x macos: --dest /m steamdeck: --dest /d -->\n"
f"```sh\ncurl -fsSL {INSTALL_BASE}/install.sh | sh -s -- --dest /l\n```\n")
f"```sh\ncurl -fsSL {INSTALL_SH} | sh -s -- --dest /l\n```\n")
def test_each_named_tab_uses_its_own(self):
parts = re.split(r'<TabItem label="([^"]+)">', sitediagrams.expand_commands(self.PAGE))