From 8fed7a178417e77ffee393a967cb921087402112 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Fri, 6 Nov 2026 03:28:44 +0100 Subject: [PATCH] docs: cite the kenji-nx AppPath line MainActivity.kt:294 is blank at 53d32a76. The AppPath assignment the data root rests on is line 295. --- emulators/kenji-nx.yml | 2 +- tests/test_cited_lines.py | 54 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 tests/test_cited_lines.py diff --git a/emulators/kenji-nx.yml b/emulators/kenji-nx.yml index 9cbf4c8ec..211e38656 100644 --- a/emulators/kenji-nx.yml +++ b/emulators/kenji-nx.yml @@ -22,7 +22,7 @@ mode: standalone data_root: android: path: "Android/data/org.kenjinx.android/files" - source_ref: "src/KenjinxAndroid/app/src/main/java/org/kenjinx/android/MainActivity.kt:279,294, src/LibKenjinx/LibKenjinx.cs:59-68, src/Ryujinx.Common/Configuration/AppDataManager.cs:84-95" + source_ref: "src/KenjinxAndroid/app/src/main/java/org/kenjinx/android/MainActivity.kt:279,295, src/LibKenjinx/LibKenjinx.cs:59-68, src/Ryujinx.Common/Configuration/AppDataManager.cs:84-95" windows: path: "%APPDATA%/Ryujinx" source_ref: "src/Ryujinx.Common/Configuration/AppDataManager.cs:11-12, 52-82" diff --git a/tests/test_cited_lines.py b/tests/test_cited_lines.py new file mode 100644 index 000000000..7a722ef88 --- /dev/null +++ b/tests/test_cited_lines.py @@ -0,0 +1,54 @@ +"""Citations corrected by hand land on the code they describe, at the pin. + +Each row is a citation that once named a blank line one or two lines above +its target. Read from the upstream cache, offline, and skipped where the cache +does not hold the file. +""" + +from __future__ import annotations + +import re +import sys +import unittest +from pathlib import Path + +ROOT = Path(__file__).resolve().parents[1] +sys.path.insert(0, str(ROOT / "scripts")) + +import upstream # noqa: E402 +from safeparse import yaml_load # noqa: E402 + +CACHE = ROOT / ".cache" / "upstream" + +# (profile, cited path, cited line, text the line holds) +CITATIONS = [ + ( + "kenji-nx", + "src/KenjinxAndroid/app/src/main/java/org/kenjinx/android/MainActivity.kt", + 295, + "AppPath = this.getExternalFilesDir(null)!!.absolutePath", + ), +] + + +class CitedLinesHoldTheirCode(unittest.TestCase): + def test_each_citation_is_in_the_profile_and_on_its_code(self): + for profile, path, line, text in CITATIONS: + with self.subTest(profile=profile, path=path): + raw = (ROOT / "emulators" / f"{profile}.yml").read_text(encoding="utf-8") + cited = re.escape(path.rsplit("/", 1)[-1]) + rf":(?:[\d,-]+,)?{line}\b" + self.assertRegex(raw, cited) + document = yaml_load(raw) + repo = upstream.parse_repo(str(document["source"])) + try: + lines = upstream.fetch_file( + repo, str(document["source_commit"]), path, str(CACHE), True + ) + except upstream.NotCachedError: + self.skipTest(f"{path} is not in the upstream cache") + self.assertIsNotNone(lines) + self.assertIn(text, lines[line - 1]) + + +if __name__ == "__main__": + unittest.main()