Skip to content

Commit 765098c

Browse files
authored
Update rebaseline_tests to handle non-json changes (#24464)
After this update I ran the script and it generated: This is an automatic change generated by tools/maint/rebaseline_tests.py. The following (1) test expectation files were updated by running the tests with `--rebaseline`: ``` test/other/codesize/test_codesize_minimal_O0.expected.js updated ```
1 parent e6ab17f commit 765098c

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

test/other/codesize/test_codesize_minimal_O0.expected.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ function _free() {
253253
*/
254254
var isFileURI = (filename) => filename.startsWith('file://');
255255

256-
// include: runtime_shared.js
256+
// include: runtime_common.js
257257
// include: runtime_stack_check.js
258258
// Initializes the stack cookie. Called at the startup of main and at the startup of each thread in pthreads mode.
259259
function writeStackCookie() {
@@ -465,7 +465,7 @@ function updateMemoryViews() {
465465

466466
// include: memoryprofiler.js
467467
// end include: memoryprofiler.js
468-
// end include: runtime_shared.js
468+
// end include: runtime_common.js
469469
assert(typeof Int32Array != 'undefined' && typeof Float64Array !== 'undefined' && Int32Array.prototype.subarray != undefined && Int32Array.prototype.set != undefined,
470470
'JS engine does not provide full typed array support');
471471

tools/maint/rebaseline_tests.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ 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'
4244
content = open(filename).read()
4345
old_content = run(['git', 'show', f'HEAD:{filename}'])
4446
print(f'processing {filename}')
@@ -50,7 +52,7 @@ def process_changed_file(filename):
5052
current_json = json.loads(content)
5153
old_json = json.loads(old_content)
5254
except Exception:
53-
print(f'{filename}: Unable to parse json content. Unsupported file format?')
55+
print(f'{filename}: Unable to parse json content')
5456
sys.exit(1)
5557
size = current_json['total']
5658
old_size = old_json['total']
@@ -114,7 +116,8 @@ def main():
114116
for file in filenames:
115117
message += process_changed_file(file)
116118

117-
message += f'\nAverage change: {statistics.mean(all_deltas):+.2f}% ({min(all_deltas):+.2f}% - {max(all_deltas):+.2f}%)\n'
119+
if all_deltas:
120+
message += f'\nAverage change: {statistics.mean(all_deltas):+.2f}% ({min(all_deltas):+.2f}% - {max(all_deltas):+.2f}%)\n'
118121

119122
message += '```\n'
120123

0 commit comments

Comments
 (0)