chore: Finish refactor and fix tests, b=no-bug, c=tests, scripts, glance

This commit is contained in:
Mr. M
2025-10-05 03:11:42 +02:00
parent bdf015fd99
commit 1694f81637
4 changed files with 988 additions and 387 deletions

View File

@@ -15,6 +15,15 @@ IGNORE_PREFS_FILE_OUT = os.path.join(
)
class JSONWithCommentsDecoder(json.JSONDecoder):
def __init__(self, **kw):
super().__init__(**kw)
def decode(self, s: str) -> any:
s = '\n'.join(l for l in s.split('\n') if not l.lstrip(' ').startswith('//'))
return super().decode(s)
def copy_ignore_prefs():
print("Copying ignorePrefs.json from src/zen/tests to engine/testing/mochitest...")
# if there are prefs that dont exist on output file, copy them from input file
@@ -22,7 +31,7 @@ def copy_ignore_prefs():
with open(IGNORE_PREFS_FILE_OUT, 'r') as f:
all_prefs = json.load(f)
with open(IGNORE_PREFS_FILE_IN, 'r') as f_in:
new_prefs = json.load(f_in)
new_prefs = json.load(f_in, cls=JSONWithCommentsDecoder)
all_prefs.extend(p for p in new_prefs if p not in all_prefs)
with open(IGNORE_PREFS_FILE_OUT, 'w') as f_out:
json.dump(all_prefs, f_out, indent=2)