mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-23 20:29:06 -05:00
feat: check the profiles a branch adds or edits
profile_sync gains --changed (added or edited profiles, uncommitted ones included) and --added, both against the merge base of --base (origin/main by default). CONTRIBUTING runs --changed --strict instead of one --emulator call per new profile, and the CI job runs --added in place of its own diff loop.
This commit is contained in:
1 parent
1b3763e58f
commit
57ac252482
8 files changed
+141
-17
No files matched your search
@@ -4261,8 +4261,9 @@ class TestSelectionNamesWhatMatchedNothing(unittest.TestCase):
|
||||
}
|
||||
|
||||
def _args(self, **values):
|
||||
base = {"emulator": None, "system": None, "type_": None,
|
||||
"stale_before": None, "limit": None}
|
||||
base = {"emulator": None, "changed": False, "added": False,
|
||||
"system": None, "type_": None, "stale_before": None,
|
||||
"limit": None}
|
||||
return argparse.Namespace(**{**base, **values})
|
||||
|
||||
def test_a_misspelt_system_stops_and_suggests(self):
|
||||
@@ -4610,5 +4611,72 @@ class TheTriageCountsWhatBlocksThePin(unittest.TestCase):
|
||||
self.assertEqual(len(err.getvalue().splitlines()), 1, err.getvalue())
|
||||
|
||||
|
||||
class TestBranchProfiles(unittest.TestCase):
|
||||
"""--changed and --added name the profiles a branch brings, not by hand."""
|
||||
|
||||
def setUp(self):
|
||||
self._tmp = tempfile.TemporaryDirectory()
|
||||
self.addCleanup(self._tmp.cleanup)
|
||||
self.root = Path(self._tmp.name)
|
||||
self._cwd = os.getcwd()
|
||||
self.addCleanup(os.chdir, self._cwd)
|
||||
os.chdir(self.root)
|
||||
env = {**os.environ, "GIT_AUTHOR_NAME": "t", "GIT_AUTHOR_EMAIL": "t@t",
|
||||
"GIT_COMMITTER_NAME": "t", "GIT_COMMITTER_EMAIL": "t@t"}
|
||||
self.env = env
|
||||
self._git("init", "-q", "-b", "main")
|
||||
(self.root / "emulators").mkdir()
|
||||
(self.root / "emulators" / "kept.yml").write_text("a: 1\n")
|
||||
(self.root / "emulators" / "edited.yml").write_text("a: 1\n")
|
||||
self._git("add", "emulators")
|
||||
self._git("commit", "-q", "--no-verify", "-m", "base")
|
||||
self._git("checkout", "-q", "-b", "topic")
|
||||
(self.root / "emulators" / "edited.yml").write_text("a: 2\n")
|
||||
(self.root / "emulators" / "new.yml").write_text("a: 1\n")
|
||||
self._git("add", "emulators")
|
||||
self._git("commit", "-q", "--no-verify", "-m", "topic")
|
||||
(self.root / "emulators" / "draft.yml").write_text("a: 1\n")
|
||||
(self.root / "emulators" / "notes.txt").write_text("x\n")
|
||||
|
||||
def _git(self, *args):
|
||||
subprocess.run(["git", *args], cwd=self.root, env=self.env, check=True)
|
||||
|
||||
def test_changed_takes_added_edited_and_uncommitted(self):
|
||||
self.assertEqual(
|
||||
profile_sync.branch_profiles("emulators", "main", added_only=False),
|
||||
["draft", "edited", "new"],
|
||||
)
|
||||
|
||||
def test_added_leaves_edited_profiles_out(self):
|
||||
self.assertEqual(
|
||||
profile_sync.branch_profiles("emulators", "main", added_only=True),
|
||||
["draft", "new"],
|
||||
)
|
||||
|
||||
def test_the_flag_selects_those_profiles(self):
|
||||
args = profile_sync.build_parser().parse_args(["--changed", "--base", "main"])
|
||||
profiles = {"kept": {}, "edited": {}, "new": {}, "draft": {}}
|
||||
self.assertEqual(
|
||||
list(profile_sync.select_profiles(profiles, args)),
|
||||
["draft", "edited", "new"],
|
||||
)
|
||||
|
||||
|
||||
class TestBranchCheckIsWired(unittest.TestCase):
|
||||
"""CONTRIBUTING and CI name the branch's profiles through the flag."""
|
||||
|
||||
def test_contributing_and_ci_use_the_flags(self):
|
||||
root = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(root / "scripts"))
|
||||
import generate_readme # noqa: PLC0415
|
||||
|
||||
text = generate_readme.generate_contributing()
|
||||
self.assertIn("profile_sync.py --changed --strict", text)
|
||||
self.assertNotIn("--emulator NAME --strict", text)
|
||||
workflow = (root / ".github" / "workflows" / "validate.yml").read_text()
|
||||
self.assertIn("profile_sync.py --added --base", workflow)
|
||||
self.assertNotIn('--emulator "$name"', workflow)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user