Support memory report logs with interleaved non-report output, added automated tests

This commit is contained in:
Vugar Mammadli 2018-03-09 14:33:16 -05:00 committed by Josh Matthews
parent b93f153ed5
commit e6c85b97f9

View file

@ -28,7 +28,8 @@ def extract_memory_reports(lines):
elif line == 'End memory reports\n':
in_report = False
elif in_report:
report_lines[-1].append(line.strip())
if line.startswith('|'):
report_lines[-1].append(line.strip())
return (report_lines, times)
@ -72,6 +73,17 @@ def transform_report_for_test(report):
return transformed
def test_extract_memory_reports():
input = ["Begin memory reports",
"|",
" 154.56 MiB -- explicit\n",
"| 107.88 MiB -- system-heap-unclassified\n",
"End memory reports\n"]
expected = ([['|', '| 107.88 MiB -- system-heap-unclassified']], ['reports'])
assert(extract_memory_reports(input) == expected)
return 0
def test():
input = '''|
| 23.89 MiB -- explicit
@ -105,6 +117,7 @@ def test():
assert(sorted(transformed.keys()) == sorted(expected.keys()))
for k, v in transformed.items():
assert(v == expected[k])
test_extract_memory_reports()
return 0