MCPcopy Index your code
hub / github.com/nodejs/node / clean_json_output

Function clean_json_output

deps/v8/tools/testrunner/utils/test_utils.py:83–115  ·  view source on GitHub ↗
(json_path, basedir)

Source from the content-addressed store, hash-verified

81 return basedir / 'out.json'
82
83def clean_json_output(json_path, basedir):
84 # Extract relevant properties of the json output.
85 if not json_path:
86 return None
87 if not json_path.exists():
88 return '--file-does-not-exists--'
89 with open(json_path) as f:
90 json_output = json.load(f)
91
92 # Replace duration in actual output as it's non-deterministic. Also
93 # replace the python executable prefix as it has a different absolute
94 # path dependent on where this runs.
95 def replace_variable_data(data):
96 data['duration'] = 1
97 data['max_rss'] = 1
98 data['max_vms'] = 1
99 data['command'] = ' '.join(
100 ['/usr/bin/python'] + data['command'].split()[1:])
101 data['command'] = data['command'].replace(f'{basedir}/', '')
102 for container in [
103 'max_rss_tests', 'max_vms_tests','slowest_tests', 'results']:
104 for data in json_output[container]:
105 replace_variable_data(data)
106 json_output['duration_mean'] = 1
107 # We need lexicographic sorting here to avoid non-deterministic behaviour
108 # The original sorting key is duration or memory, but in our fake test we
109 # have non-deterministic values before we reset them to 1.
110 def sort_key(x):
111 return str(sorted(x.items()))
112 for container in [
113 'max_rss_tests', 'max_vms_tests','slowest_tests']:
114 json_output[container].sort(key=sort_key)
115 return json_output
116
117
118def test_schedule_log(json_path):

Callers 1

run_testsMethod · 0.85

Calls 5

replace_variable_dataFunction · 0.85
sortMethod · 0.80
openFunction · 0.50
existsMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…