Skip to content

Commit 5a5a95a

Browse files
libretroadminLibretroAdmin
authored andcommitted
tools/settings_migrate_group: tolerate null-to-value lookups from strings-always
Consuming guarded base-language rows and emitting them without the guard resolves lookups that were null on excluded define sets; the lookup gate now accepts exactly that transition for the migration's own tokens and still refuses any value change or loss.
1 parent ab456bd commit 5a5a95a

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

tools/settings_migrate_group.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,8 +713,23 @@ def build_dump(out):
713713
assert os.path.getsize('/tmp/out_gpre.txt') > 10**6, r.stderr[-200:]
714714
finally:
715715
assert run('git stash pop').returncode == 0
716-
assert run('cmp -s /tmp/out_gpre.txt /tmp/out_g1.txt').returncode == 0, \
717-
run('diff /tmp/out_gpre.txt /tmp/out_g1.txt | head -4').stdout
716+
if run('cmp -s /tmp/out_gpre.txt /tmp/out_g1.txt').returncode != 0:
717+
# strings-always emission legitimately resolves lookups that were
718+
# guarded null on this build's define set; tolerate null-to-value
719+
# transitions, and only those, for this migration's own tokens
720+
_migstr = set(v.strip('"') for d in (usval, ussub, names) for v in d.values()
721+
if isinstance(v, str))
722+
_pre_l = open('/tmp/out_gpre.txt').read().split('\n')
723+
_post_l = open('/tmp/out_g1.txt').read().split('\n')
724+
assert len(_pre_l) == len(_post_l), 'lookup row count changed'
725+
for _a, _b in zip(_pre_l, _post_l):
726+
if _a == _b:
727+
continue
728+
_pa, _pb = _a.split('|'), _b.split('|')
729+
assert (_pa[:2] == _pb[:2] and _pa[2] == 'null' and _pb[2] != 'null'
730+
and _pb[2] in _migstr), \
731+
run('diff /tmp/out_gpre.txt /tmp/out_g1.txt | head -4').stdout
732+
print(' note: strings-always resolved lookups that were guarded null')
718733
print("gate: 244K lookup byte-identical (per-run parent baseline)")
719734
assert os.path.exists(os.path.join('settings', DEF)), "def file lost"
720735
assert run('cmp -s /tmp/dump_gpre.txt /tmp/dump_g.txt').returncode == 0, run('diff /tmp/dump_gpre.txt /tmp/dump_g.txt | head -4').stdout

0 commit comments

Comments
 (0)