mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-18 23:57:55 -06:00
chore: merge origin/main
This commit is contained in:
commit
8100d671f9
22 files changed
+2648
-29
No files matched your search
@@ -0,0 +1,266 @@
|
||||
"""EmuELEC's images differ by device, and only its metapackage says how.
|
||||
|
||||
packages/sx05re/emuelec/package.mk (v4.8) builds the S922X cores, Dolphin
|
||||
and the MAME core only on Amlogic-ng, Amlogic-no, RK356x and OdroidM1, and
|
||||
takes DuckStation out on the two handhelds with a sed that replaces the
|
||||
first match only. With no target list, an OdroidGoAdvance pack carried the
|
||||
firmware of cores its image never had.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||
|
||||
from scraper.targets import emuelec_targets_scraper as scraper # noqa: E402
|
||||
|
||||
# packages/sx05re/emuelec/package.mk:8-77 at v4.8, PKG_EMUS and
|
||||
# PKG_EXPERIMENTAL shortened.
|
||||
PACKAGE_MK = """PKG_DEPENDS_TARGET="toolchain ${OPENGLES} emuelec-emulationstation retroarch"
|
||||
PKG_EXPERIMENTAL="nestopiaCV quasi88 yabasanshiroSA_1_11 yabasanshiroSA_1_5 fbneoSA"
|
||||
PKG_EMUS="${LIBRETRO_CORES} advancemame duckstation pcsx_rearmed flycastsa"
|
||||
PKG_DEPENDS_TARGET+=" emuelec-tools ${PKG_EMUS} ${PKG_EXPERIMENTAL}"
|
||||
|
||||
if [ "${DEVICE}" == "Amlogic-ng" ] || [ "${DEVICE}" == "Amlogic-no" ] || [ "${DEVICE}" == "RK356x" ] || [ "${DEVICE}" == "OdroidM1" ]; then
|
||||
\tPKG_DEPENDS_TARGET+=" ${LIBRETRO_S922X_CORES}"
|
||||
fi
|
||||
|
||||
if [ "${DEVICE}" == "OdroidGoAdvance" ] || [ "${DEVICE}" == "GameForce" ]; then
|
||||
\tPKG_DEPENDS_TARGET+=" kmscon odroidgoa-utils"
|
||||
\tfor discore in duckstation mesen-s virtualjaguar quicknes MC; do
|
||||
\t\tPKG_DEPENDS_TARGET=$(echo ${PKG_DEPENDS_TARGET} | sed "s|${discore} | |")
|
||||
\tdone
|
||||
\tPKG_DEPENDS_TARGET+=" yabasanshiro"
|
||||
else
|
||||
\tPKG_DEPENDS_TARGET+=" fbterm"
|
||||
fi
|
||||
|
||||
if [ "${ARCH}" == "aarch64" ]; then
|
||||
for discore in quicknes parallel-n64 pcsx_rearmed; do
|
||||
\t\tPKG_DEPENDS_TARGET=$(echo ${PKG_DEPENDS_TARGET} | sed "s|${discore}| |")
|
||||
\tdone
|
||||
|
||||
PKG_DEPENDS_TARGET+=" swanstation \\
|
||||
lib32-essential \\
|
||||
lib32-pcsx_rearmed \\
|
||||
lib32-parallel-n64
|
||||
lib32-libusb"
|
||||
|
||||
if [ "${DEVICE}" == "Amlogic-ng" ] || [ "${DEVICE}" == "Amlogic-no" ] || [ "${DEVICE}" == "RK356x" ] || [ "${DEVICE}" == "OdroidM1" ]; then
|
||||
PKG_DEPENDS_TARGET+=" dolphinSA"
|
||||
fi
|
||||
|
||||
if [ "${DEVICE}" == "Amlogic-old" ]; then
|
||||
for discore in yabasanshiroSA_1_11 yabasanshiroSA_1_5 yabasanshiro same_cdi duckstation; do
|
||||
PKG_DEPENDS_TARGET=$(echo ${PKG_DEPENDS_TARGET} | sed "s|${discore} | |")
|
||||
done
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${DEVICE}" == "Amlogic-ng" ] || [ "${DEVICE}" == "Amlogic-no" ] || [ "${DEVICE}" == "RK356x" ] || [ "${DEVICE}" == "OdroidM1" ]; then
|
||||
\tPKG_DEPENDS_TARGET+=" mame"
|
||||
fi
|
||||
|
||||
if [ "${DEVICE}" == "RK356x" ] || [ "${DEVICE}" == "OdroidM1" ]; then
|
||||
for discore in flycast-dojo; do
|
||||
\t\tPKG_DEPENDS_TARGET=$(echo ${PKG_DEPENDS_TARGET} | sed "s|${discore}| |")
|
||||
\tdone
|
||||
fi
|
||||
"""
|
||||
|
||||
# distributions/EmuELEC/options:274-373 at v4.8, shortened.
|
||||
OPTIONS = """LIBRETRO_CORES="mgba \\
|
||||
parallel-n64 \\
|
||||
pcsx_rearmed \\
|
||||
flycast"
|
||||
|
||||
LIBRETRO_S922X_CORES="beetle-saturn \\
|
||||
mesen \\
|
||||
quicknes \\
|
||||
virtualjaguar"
|
||||
"""
|
||||
|
||||
# packages/sx05re/emuelec-emulationstation/package.mk:114-143 at v4.8.
|
||||
ES_MK = """CORESFILE="${INSTALL}/usr/config/emulationstation/es_systems.cfg"
|
||||
|
||||
if [[ "${DEVICE}" != "Amlogic-ng" || "${DEVICE}" != "Amlogic-ne" || "${DEVICE}" != "Amlogic-no" ]]; then
|
||||
if [[ ${DEVICE} == "OdroidGoAdvance" || "${DEVICE}" == "GameForce" ]]; then
|
||||
remove_cores="mesen-s quicknes mame2016 mesen"
|
||||
elif [ "${DEVICE}" == "Amlogic-old" ]; then
|
||||
remove_cores="mesen-s quicknes mame2016 mesen yabasanshiroSA yabasanshiro"
|
||||
xmlstarlet ed -L -P -d "/systemList/system[name='saturn']" ${CORESFILE}
|
||||
xmlstarlet ed -L -P -d "/systemList/system[name='phillips-cdi']" ${CORESFILE}
|
||||
xmlstarlet ed -L -P -d "/systemList/system/emulators/emulator[@name='Duckstation']" ${CORESFILE}
|
||||
fi
|
||||
for discore in ${remove_cores}; do
|
||||
sed -i "s|<core>${discore}</core>||g" ${CORESFILE}
|
||||
sed -i '/^[[:space:]]*$/d' ${CORESFILE}
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ ${DEVICE} != "OdroidGoAdvance" ]] && [[ "${DEVICE}" != "GameForce" ]]; then
|
||||
\txmlstarlet ed -L -P -d "/systemList/system/emulators/emulator[@name='retrorun']" ${CORESFILE}
|
||||
else
|
||||
\txmlstarlet ed -L -P -d "/systemList/system/emulators/emulator[@name='Duckstation']" ${CORESFILE}
|
||||
fi
|
||||
"""
|
||||
|
||||
|
||||
def _system(name: str, *emulators: tuple[str, list[dict]]) -> dict:
|
||||
return {"name": name, "emulators": [{"name": e, "cores": c} for e, c in emulators]}
|
||||
|
||||
|
||||
ES_JSON = json.dumps({"systems": [
|
||||
_system("nes", ("libretro", [{"name": "mesen", "default": True}])),
|
||||
_system("snes", ("libretro", [{"name": "snes9x", "default": True}, {"name": "mesen-s"}])),
|
||||
_system("psx",
|
||||
("libretro", [{"name": "pcsx_rearmed", "default": True},
|
||||
{"name": "pcsx_rearmed_32b"}, {"name": "swanstation"}]),
|
||||
("Duckstation", [{"name": "Duckstation"}]),
|
||||
("retrorun", [{"name": "pcsx_rearmed_32b"}])),
|
||||
_system("n64", ("libretro", [{"name": "parallel_n64_32b"}])),
|
||||
]})
|
||||
|
||||
ARCHS = {"mesen": "", "duckstation": "aarch64", "pcsx_rearmed": "any",
|
||||
"lib32-pcsx_rearmed": "aarch64", "swanstation": "any",
|
||||
"lib32-parallel-n64": "aarch64"}
|
||||
|
||||
ASSETS = [
|
||||
"EmuELEC-Amlogic-ng.aarch64-4.8-Generic.img.gz",
|
||||
"EmuELEC-Amlogic-ng.aarch64-4.8.tar",
|
||||
"EmuELEC-GameForce.aarch64-4.8-chi.img.gz.sha256",
|
||||
"EmuELEC-OdroidGoAdvance.aarch64-4.8-odroidgo2.tar",
|
||||
"EmuELEC-OdroidM1.aarch64-4.8.img.gz",
|
||||
]
|
||||
|
||||
|
||||
class TheMetapackageDecidesEachDevice(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.meta = scraper.read_metapackage(PACKAGE_MK, OPTIONS)
|
||||
|
||||
def test_devices_are_the_images_the_release_publishes(self):
|
||||
self.assertEqual(scraper.release_devices(ASSETS), {
|
||||
"Amlogic-ng": "aarch64", "GameForce": "aarch64",
|
||||
"OdroidGoAdvance": "aarch64", "OdroidM1": "aarch64",
|
||||
})
|
||||
|
||||
def test_the_lists_the_rules_work_on(self):
|
||||
self.assertEqual(self.meta.emus, ["mgba", "parallel-n64", "pcsx_rearmed", "flycast",
|
||||
"advancemame", "duckstation", "pcsx_rearmed",
|
||||
"flycastsa"])
|
||||
self.assertEqual(self.meta.lib32, ["swanstation", "lib32-essential",
|
||||
"lib32-pcsx_rearmed", "lib32-parallel-n64",
|
||||
"lib32-libusb"])
|
||||
|
||||
def test_the_big_devices_build_the_s922x_cores_dolphin_and_mame(self):
|
||||
packages = scraper.device_packages(self.meta, "Amlogic-ng", "aarch64")
|
||||
for package in ("beetle-saturn", "mesen", "virtualjaguar", "dolphinSA", "mame",
|
||||
"duckstation", "fbterm"):
|
||||
self.assertIn(package, packages)
|
||||
# quicknes is added, then the aarch64 loop takes it out.
|
||||
self.assertNotIn("quicknes", packages)
|
||||
|
||||
def test_the_handhelds_lose_duckstation_and_gain_their_tools(self):
|
||||
packages = scraper.device_packages(self.meta, "OdroidGoAdvance", "aarch64")
|
||||
for package in ("duckstation", "mesen", "beetle-saturn", "dolphinSA", "mame", "fbterm"):
|
||||
self.assertNotIn(package, packages)
|
||||
self.assertEqual(packages[-1:], ["lib32-libusb"])
|
||||
self.assertIn("kmscon", packages)
|
||||
self.assertIn("yabasanshiro", packages)
|
||||
|
||||
def test_sed_takes_out_the_first_match_only(self):
|
||||
# pcsx_rearmed is written twice, in LIBRETRO_CORES and in PKG_EMUS:
|
||||
# the aarch64 loop removes the first and the 64-bit core is built.
|
||||
for device in ("Amlogic-ng", "OdroidGoAdvance"):
|
||||
packages = scraper.device_packages(self.meta, device, "aarch64")
|
||||
self.assertEqual(packages.count("pcsx_rearmed"), 1, device)
|
||||
self.assertNotIn("parallel-n64", packages, device)
|
||||
|
||||
def test_a_pattern_with_a_trailing_space_misses_the_last_word(self):
|
||||
self.assertEqual(scraper._sed_first("a duckstation", "duckstation "), "a duckstation")
|
||||
self.assertEqual(scraper._sed_first("a duckstation b", "duckstation "), "a b")
|
||||
# Without the space, the pattern takes a word's tail too.
|
||||
self.assertEqual(scraper._sed_first("lib32-pcsx_rearmed", "pcsx_rearmed"), "lib32- ")
|
||||
|
||||
def test_a_changed_rule_stops_the_scrape(self):
|
||||
changed = PACKAGE_MK.replace("duckstation mesen-s virtualjaguar quicknes MC",
|
||||
"duckstation mesen-s")
|
||||
with self.assertRaises(RuntimeError):
|
||||
scraper.read_metapackage(changed, OPTIONS)
|
||||
|
||||
|
||||
class EachPackageBuildsWhereItsArchAllows(unittest.TestCase):
|
||||
def test_pkg_arch(self):
|
||||
self.assertTrue(scraper.arch_builds("", "aarch64"))
|
||||
self.assertTrue(scraper.arch_builds("any", "aarch64"))
|
||||
self.assertTrue(scraper.arch_builds("aarch64 arm", "aarch64"))
|
||||
# mupen64plus and uae4arm say PKG_ARCH="arm": skipped on aarch64.
|
||||
self.assertFalse(scraper.arch_builds("arm", "aarch64"))
|
||||
self.assertFalse(scraper.arch_builds("any !aarch64", "aarch64"))
|
||||
|
||||
def test_every_cited_install_line_is_read(self):
|
||||
install = scraper.PROVIDERS["mgba"][0]
|
||||
text = f'PKG_ARCH="any"\nmakeinstall_target() {{\n {install.line}\n}}\n'
|
||||
with self.assertRaises(RuntimeError):
|
||||
scraper._require(text.replace("mgba_libretro", "mgba2_libretro"),
|
||||
(install.line,), install.path)
|
||||
scraper._require(text, (install.line,), install.path)
|
||||
|
||||
|
||||
class TheFrontendOffersWhatTheDeviceKeeps(unittest.TestCase):
|
||||
def test_handhelds_drop_bare_cores_and_duckstation(self):
|
||||
systems = scraper.es_systems_for(ES_JSON, ES_MK, "GameForce")
|
||||
# mesen is the nes default: written with an attribute, sed misses it.
|
||||
self.assertEqual(systems["nes"], [("libretro", ["mesen"])])
|
||||
self.assertEqual(systems["snes"], [("libretro", ["snes9x"])])
|
||||
self.assertEqual([e for e, _ in systems["psx"]], ["libretro", "retrorun"])
|
||||
|
||||
def test_other_devices_drop_retrorun(self):
|
||||
systems = scraper.es_systems_for(ES_JSON, ES_MK, "Amlogic-ng")
|
||||
self.assertEqual([e for e, _ in systems["psx"]], ["libretro", "Duckstation"])
|
||||
self.assertEqual(systems["snes"], [("libretro", ["snes9x", "mesen-s"])])
|
||||
|
||||
def test_a_device_keeps_what_it_builds_and_offers(self):
|
||||
meta = scraper.read_metapackage(PACKAGE_MK, OPTIONS)
|
||||
archs = {**dict.fromkeys(scraper.PROVIDERS, "any"), **ARCHS}
|
||||
cores = {}
|
||||
for device in ("Amlogic-ng", "OdroidGoAdvance"):
|
||||
packages = [p for p in scraper.device_packages(meta, device, "aarch64")
|
||||
if p in scraper.PROVIDERS or p in scraper.NO_ES_CORE]
|
||||
systems = scraper.es_systems_for(ES_JSON, ES_MK, device)
|
||||
cores[device] = scraper.device_cores(packages, "aarch64", archs, systems)
|
||||
self.assertEqual(cores["Amlogic-ng"], ["Duckstation", "mesen", "parallel_n64_32b",
|
||||
"pcsx_rearmed", "pcsx_rearmed_32b",
|
||||
"swanstation"])
|
||||
self.assertEqual(cores["OdroidGoAdvance"], ["parallel_n64_32b", "pcsx_rearmed",
|
||||
"pcsx_rearmed_32b", "swanstation"])
|
||||
|
||||
def test_a_package_never_read_stops_the_scrape(self):
|
||||
archs = dict.fromkeys(scraper.PROVIDERS, "any")
|
||||
with self.assertRaises(RuntimeError):
|
||||
scraper.device_cores(["mgba", "newcore"], "aarch64", archs, {})
|
||||
|
||||
|
||||
class TheCommittedListFollowsTheRules(unittest.TestCase):
|
||||
def test_the_handhelds_list_no_core_they_do_not_build(self):
|
||||
import yaml # noqa: PLC0415
|
||||
|
||||
targets = yaml.safe_load((REPO_ROOT / "platforms" / "targets" / "emuelec.yml")
|
||||
.read_text(encoding="utf-8"))["targets"]
|
||||
self.assertEqual(set(targets), {"amlogic-ng", "gameforce", "odroidgoadvance", "odroidm1"})
|
||||
big = set(targets["amlogic-ng"]["cores"])
|
||||
for device in ("gameforce", "odroidgoadvance"):
|
||||
self.assertEqual(big - set(targets[device]["cores"]), {
|
||||
"Duckstation", "dolphin", "mame", "mednafen_saturn", "mesen", "mesen-s",
|
||||
"virtualjaguar",
|
||||
})
|
||||
self.assertEqual(targets["odroidm1"]["cores"], targets["amlogic-ng"]["cores"])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
+18
-6
@@ -3552,7 +3552,7 @@ class ACardPreparedOnAComputerGetsItsBoard(unittest.TestCase):
|
||||
class APlatformWithoutTargetsSaysSoOffline(unittest.TestCase):
|
||||
"""Offline, --target on AmberELEC asked for install/targets/amberelec.json,
|
||||
which existed nowhere: online the same run said it had no targets.
|
||||
EmuELEC has none still."""
|
||||
MiSTer FPGA has none still."""
|
||||
|
||||
def test_the_list_matches_the_published_targets(self):
|
||||
published = {path.stem for path in (REPO_ROOT / "install" / "targets").glob("*.json")}
|
||||
@@ -3560,16 +3560,16 @@ class APlatformWithoutTargetsSaysSoOffline(unittest.TestCase):
|
||||
|
||||
def test_offline_says_there_are_no_targets(self):
|
||||
dest = Path(_tempdir(self))
|
||||
for extra in ([], ["--manifest", str(REPO_ROOT / "install" / "emuelec.json")]):
|
||||
for extra in ([], ["--manifest", str(REPO_ROOT / "install" / "misterfpga.json")]):
|
||||
with self.subTest(manifest=bool(extra)):
|
||||
proc = subprocess.run(
|
||||
[sys.executable, str(REPO_ROOT / "install.py"), "--platform", "emuelec",
|
||||
"--dest", str(dest), "--target", "rk3326", "--offline", "--no-input",
|
||||
[sys.executable, str(REPO_ROOT / "install.py"), "--platform", "misterfpga",
|
||||
"--dest", str(dest), "--target", "de10-nano", "--offline", "--no-input",
|
||||
"--dry-run", *extra],
|
||||
capture_output=True, text=True, timeout=120, stdin=subprocess.DEVNULL)
|
||||
self.assertEqual(proc.returncode, 2, proc.stderr)
|
||||
self.assertIn("EmuELEC has no hardware targets", proc.stderr)
|
||||
self.assertNotIn("targets/emuelec.json", proc.stderr)
|
||||
self.assertIn("MiSTer FPGA has no hardware targets", proc.stderr)
|
||||
self.assertNotIn("targets/misterfpga.json", proc.stderr)
|
||||
|
||||
|
||||
class TheBoardTheSystemNamesIsTheTarget(unittest.TestCase):
|
||||
@@ -3635,6 +3635,18 @@ class TheBoardTheSystemNamesIsTheTarget(unittest.TestCase):
|
||||
.read_text(encoding="utf-8"))
|
||||
self.assertIn("rg351p", targets)
|
||||
|
||||
def test_emuelec_names_its_device(self):
|
||||
# An OdroidGoAdvance image carries no DuckStation, Dolphin or MAME
|
||||
# core, and the full list was installed: EmuELEC had no target list.
|
||||
with unittest.mock.patch.object(
|
||||
install, "_parse_os_release", return_value={"COREELEC_DEVICE": "OdroidGoAdvance"}
|
||||
):
|
||||
self.assertEqual(install.detect_board("emuelec"), "odroidgoadvance")
|
||||
targets = json.loads((REPO_ROOT / "install" / "targets" / "emuelec.json")
|
||||
.read_text(encoding="utf-8"))
|
||||
self.assertIn("odroidgoadvance", targets)
|
||||
self.assertNotIn("Duckstation", targets["odroidgoadvance"])
|
||||
|
||||
def test_lakka_names_its_device_or_its_project(self):
|
||||
# An RPi4 Lakka installed 5.7 GB of every board's files: its board
|
||||
# was in os-release and never read.
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
"""The readings of scripts/site_insights.py, on synthetic figures."""
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime as dt
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts"))
|
||||
|
||||
import site_insights as si # noqa: E402
|
||||
|
||||
PAGE = "https://abdess.github.io/retrobios/emulators/mgba/"
|
||||
|
||||
|
||||
class FileNamesInSearches(unittest.TestCase):
|
||||
def test_each_name_carries_what_the_project_knows(self) -> None:
|
||||
queries = [si.Query("gba_bios.bin download", PAGE, 1, 300, 8.0),
|
||||
si.Query("where to put GBA_BIOS.BIN", PAGE, 0, 50, 9.0),
|
||||
si.Query("dsp1b.rom snes", PAGE, 0, 40, 9.0),
|
||||
si.Query("mystery.pup", PAGE, 0, 10, 30.0),
|
||||
si.Query("gba bios", PAGE, 5, 900, 7.0)]
|
||||
rows = si.searched_files(queries, held={"gba_bios.bin"}, declared={"gba_bios.bin", "dsp1b.rom"})
|
||||
self.assertEqual(rows, [("gba_bios.bin", 350, "held"), ("dsp1b.rom", 40, "declared, not held"),
|
||||
("mystery.pup", 10, "unknown")])
|
||||
|
||||
|
||||
class SearchGaps(unittest.TestCase):
|
||||
def test_first_page_rarely_clicked(self) -> None:
|
||||
low = si.Query("swanstation", PAGE, 3, 540, 5.6)
|
||||
fine = si.Query("nethersx2 bios", PAGE, 54, 484, 4.6)
|
||||
far = si.Query("xbox bios", PAGE, 0, 900, 10.7)
|
||||
self.assertEqual(si.missed_clicks([low, fine, far]), [low])
|
||||
self.assertEqual(si.near_first_page([low, fine, far]), [far])
|
||||
|
||||
|
||||
class SiteActions(unittest.TestCase):
|
||||
def test_events_are_grouped_by_kind_and_pages_apart(self) -> None:
|
||||
hits = [("/emulators/mgba/", 40), ("search-none/kenji nx", 3), ("search-none/dsp1b.rom", 7),
|
||||
("helpful/no", 2), ("/old/link/ [404]", 5), ("download/Batocera_43.1_BIOS_Pack.zip", 9)]
|
||||
actions = si.site_actions(hits)
|
||||
self.assertEqual(actions["search-none"], [("dsp1b.rom", 7), ("kenji nx", 3)])
|
||||
self.assertEqual(actions["404"], [("/old/link/", 5)])
|
||||
self.assertEqual(actions["pages"], [("/emulators/mgba/", 40)])
|
||||
self.assertEqual(actions["helpful"], [("no", 2)])
|
||||
|
||||
|
||||
class TheReport(unittest.TestCase):
|
||||
def test_a_skipped_source_leaves_no_section(self) -> None:
|
||||
text = si.report(dt.date(2026, 10, 1), dt.date(2026, 10, 28),
|
||||
[si.Query("gba_bios.bin", PAGE, 1, 300, 8.0)], None, None,
|
||||
held={"gba_bios.bin"}, declared=set())
|
||||
self.assertIn("## Google searches", text)
|
||||
self.assertIn("| gba_bios.bin | /emulators/mgba/ | 300 | 0.3% | 8.0 |", text)
|
||||
self.assertNotIn("## On the site", text)
|
||||
self.assertNotIn("## GitHub", text)
|
||||
|
||||
def test_names_come_from_profiles_and_the_collection(self) -> None:
|
||||
db = {"indexes": {"by_name": {"SCPH5501.BIN": ["x"]}}}
|
||||
profiles = {"p": {"files": [{"name": "bios/dsp1b.rom", "aliases": ["DSP1B.bin"]}, "str"]}}
|
||||
held, declared = si.collection_names(db, profiles)
|
||||
self.assertEqual(held, {"scph5501.bin"})
|
||||
self.assertEqual(declared, {"dsp1b.rom", "dsp1b.bin"})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -427,7 +427,7 @@ START_HERE = [
|
||||
"/retrobios/", "/retrobios/wiki/what-are-bios-files/", "/retrobios/which-pack/",
|
||||
"/retrobios/wiki/first-install/", "/retrobios/wiki/troubleshooting/",
|
||||
"/retrobios/wiki/faq/", "/retrobios/wiki/legal/", "/retrobios/wiki/glossary/",
|
||||
"/retrobios/platforms/",
|
||||
"/retrobios/wiki/privacy/", "/retrobios/platforms/",
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
"""What the site counts stays what wiki/privacy.md says it counts.
|
||||
|
||||
The counter is website/src/scripts/count.ts. These checks read its source:
|
||||
the guarantees are in a few lines that a later edit could drop without any
|
||||
page looking different.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
COUNTER = REPO_ROOT / "website" / "src" / "scripts" / "count.ts"
|
||||
FOOTER = REPO_ROOT / "website" / "src" / "components" / "Footer.astro"
|
||||
PRIVACY = REPO_ROOT / "wiki" / "privacy.md"
|
||||
|
||||
|
||||
class TheCounterAsksNothingOfTheDevice(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.source = COUNTER.read_text(encoding="utf-8")
|
||||
# Comments state the rules: only the code must keep them.
|
||||
self.code = re.sub(r"^\s*//.*$", "", self.source, flags=re.M)
|
||||
|
||||
def test_no_storage_on_the_device(self) -> None:
|
||||
for api in ("document.cookie", "localStorage", "sessionStorage", "indexedDB"):
|
||||
with self.subTest(api=api):
|
||||
self.assertNotIn(api, self.code)
|
||||
|
||||
def test_a_declined_browser_sends_nothing(self) -> None:
|
||||
self.assertIn("doNotTrack === '1'", self.code)
|
||||
self.assertIn("globalPrivacyControl === true", self.code)
|
||||
self.assertRegex(self.code, r"const send = .*\n\tif \(!enabled\) return;")
|
||||
|
||||
def test_only_the_published_site_counts(self) -> None:
|
||||
self.assertIn("location.hostname === HOST", self.code)
|
||||
|
||||
def test_no_query_anchor_or_device_detail_is_read(self) -> None:
|
||||
for read in ("location.search", "location.hash", "location.href,", "screen.", "navigator.language"):
|
||||
with self.subTest(read=read):
|
||||
self.assertNotIn(read, self.code)
|
||||
|
||||
def test_the_referrer_is_reduced_to_its_domain(self) -> None:
|
||||
self.assertIn("from.origin", self.code)
|
||||
self.assertNotIn("from.pathname", self.code)
|
||||
|
||||
def test_a_search_with_personal_details_is_not_sent(self) -> None:
|
||||
self.assertIn("!query.includes('@')", self.code)
|
||||
self.assertIn("\\d{7,}", self.code)
|
||||
self.assertIn("message.startsWith('No results for')", self.code)
|
||||
|
||||
def test_one_endpoint(self) -> None:
|
||||
self.assertEqual(set(re.findall(r"https://[\w.-]+", self.code)),
|
||||
{"https://retrobios.goatcounter.com"})
|
||||
|
||||
|
||||
class ThePageSaysWhatIsCounted(unittest.TestCase):
|
||||
def test_every_page_loads_the_counter_and_links_the_page(self) -> None:
|
||||
footer = FOOTER.read_text(encoding="utf-8")
|
||||
self.assertIn("import '../scripts/count.ts';", footer)
|
||||
self.assertIn("wiki/privacy/", footer)
|
||||
# Hidden until the script shows it: a declined browser is not asked.
|
||||
self.assertRegex(footer, r"data-rb-helpful-box hidden")
|
||||
|
||||
def test_the_page_names_each_thing_sent(self) -> None:
|
||||
page = PRIVACY.read_text(encoding="utf-8")
|
||||
for said in ("No cookies", "Do Not Track", "Global Privacy Control",
|
||||
"copy button", "found nothing", "Did this page help?",
|
||||
"The installer sends nothing back", "retrobios.goatcounter.com"):
|
||||
with self.subTest(said=said):
|
||||
self.assertIn(said, page)
|
||||
|
||||
def test_the_installer_has_no_counter(self) -> None:
|
||||
installer = (REPO_ROOT / "install.py").read_text(encoding="utf-8")
|
||||
self.assertNotIn("goatcounter", installer.lower())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user