Skip to content

Commit 3ee44cd

Browse files
libretroadminLibretroAdmin
authored andcommitted
tools/settings_migrate_group: tolerate census-fresh names in the enum gate
The enum stage's pre dump is taken mid-run, before the def file is included anywhere in the enum header, so a token whose label string was first introduced by this migration's census rows resolves to null in pre and to its canonical name in post. That exact transition, restricted to the migrating rows' own names, is now accepted; any other difference still fails.
1 parent 21e22e0 commit 3ee44cd

2 files changed

Lines changed: 24 additions & 10 deletions

File tree

intl/msg_hash_lbl.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ MSG_HASH(
1111
MENU_ENUM_LABEL_ACCOUNTS_CHEEVOS_USERNAME,
1212
MENU_ENUM_LABEL_ACCOUNTS_CHEEVOS_USERNAME_STR
1313
)
14+
MSG_HASH(
15+
MENU_ENUM_LABEL_VIDEO_HDR_SCANLINES,
16+
MENU_ENUM_LABEL_VIDEO_HDR_SCANLINES_STR
17+
)
18+
MSG_HASH(
19+
MENU_ENUM_LABEL_VIDEO_HDR_SUBPIXEL_LAYOUT,
20+
MENU_ENUM_LABEL_VIDEO_HDR_SUBPIXEL_LAYOUT_STR
21+
)
1422
MSG_HASH(
1523
MENU_ENUM_LABEL_ACHIEVEMENT_PAUSE_MENU,
1624
MENU_ENUM_LABEL_ACHIEVEMENT_PAUSE_MENU_STR
@@ -5210,12 +5218,4 @@ MSG_HASH(
52105218
MENU_ENUM_LABEL_SMB_CLIENT_BROWSE,
52115219
MENU_ENUM_LABEL_SMB_CLIENT_BROWSE_STR
52125220
)
5213-
MSG_HASH(
5214-
MENU_ENUM_LABEL_VIDEO_HDR_SCANLINES,
5215-
MENU_ENUM_LABEL_VIDEO_HDR_SCANLINES_STR
5216-
)
5217-
MSG_HASH(
5218-
MENU_ENUM_LABEL_VIDEO_HDR_SUBPIXEL_LAYOUT,
5219-
MENU_ENUM_LABEL_VIDEO_HDR_SUBPIXEL_LAYOUT_STR
5220-
)
52215221
#endif

tools/settings_migrate_group.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,22 @@ def _plains(text):
625625
assert _plains(open('msg_hash.h').read()) == _census_pre, "enum census drift"
626626
r = run("python3 tools/msg_hash_name_harness.py /tmp/enum_post.txt")
627627
assert r.returncode == 0, r.stderr[-300:]
628-
assert run('cmp -s /tmp/enum_pre.txt /tmp/enum_post.txt').returncode == 0, \
629-
run('diff /tmp/enum_pre.txt /tmp/enum_post.txt | head -4').stdout
628+
if run('cmp -s /tmp/enum_pre.txt /tmp/enum_post.txt').returncode != 0:
629+
# A token whose strings were first introduced by this migration's
630+
# census rows resolves to null in the mid-run pre dump (the def is
631+
# not yet included anywhere in msg_hash.h) and to its own name
632+
# after the enum stage. That exact transition, for this
633+
# migration's tokens only, is the definition of correct.
634+
_mine = set(names[_t2] for _k2, _f2, _t2, _a2 in rows)
635+
_pre = open('/tmp/enum_pre.txt').read().split('\n')
636+
_post = open('/tmp/enum_post.txt').read().split('\n')
637+
assert len(_pre) == len(_post), 'name dump row count changed'
638+
for _lp, _lq in zip(_pre, _post):
639+
if _lp == _lq:
640+
continue
641+
_pp, _qq = _lp.split('|'), _lq.split('|')
642+
assert (_pp[:2] == _qq[:2] and _pp[2] == 'null'
643+
and _qq[2] in _mine), (_lp, _lq)
630644
_body = re.search(r'enum msg_hash_enums\n\{\n(.*?)\n\};', mh, re.S).group(1)
631645
_toks = set(x for g in re.findall(r'^#if\w*([^\n]*)', _body, re.M)
632646
for x in re.findall(r'\b([A-Z_][A-Z0-9_]{2,})\b', g) if x != 'defined')

0 commit comments

Comments
 (0)