Skip to content

Commit b081086

Browse files
authored
[rebaseline_tests] Handle .size files in reporting. NFC (#24514)
1 parent f43543b commit b081086

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

tools/maint/rebaseline_tests.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,23 +39,22 @@ def run(cmd, **args):
3939

4040

4141
def process_changed_file(filename):
42-
if os.path.splitext(filename)[1] != '.json':
43-
return f'{filename} updated\n'
4442
content = open(filename).read()
4543
old_content = run(['git', 'show', f'HEAD:{filename}'])
4644
print(f'processing {filename}')
47-
if len(content.splitlines()) == 1:
45+
46+
ext = os.path.splitext(filename)[1]
47+
if ext == '.size':
4848
size = int(content.strip())
4949
old_size = int(old_content.strip())
50-
else:
51-
try:
52-
current_json = json.loads(content)
53-
old_json = json.loads(old_content)
54-
except Exception:
55-
print(f'{filename}: Unable to parse json content')
56-
sys.exit(1)
50+
elif ext == '.json':
51+
current_json = json.loads(content)
52+
old_json = json.loads(old_content)
5753
size = current_json['total']
5854
old_size = old_json['total']
55+
else:
56+
# Unhandled file type
57+
return f'{filename} updated\n'
5958

6059
filename = utils.removeprefix(filename, 'test/')
6160
delta = size - old_size

0 commit comments

Comments
 (0)