[PATCH] D47697: [llvm-mca] Make sure not to end the test files with an empty line.
Greg Bedwell via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 4 01:18:02 PDT 2018
gbedwell added a comment.
Thanks for the patch! Annoying that my git client never complained about this one to me.
================
Comment at: utils/update_mca_test_checks.py:445
+ # The file should not end with two newlines. It creates unnecessary churn.
+ while len(output_lines) > 0 and output_lines[-1] == '':
+ output_lines.pop()
----------------
can be simplified to
```while output_lines and output_lines[-1] == '':```
I think.
================
Comment at: utils/update_mca_test_checks.py:458
with open(test_path, 'wb') as f:
- for line in output_lines:
- f.write('{}\n'.format(line.rstrip()).encode())
-
+ f.writelines([l + '\n' for l in output_lines])
----------------
I've been trying to keep this file compatible with Python 2 and 3, ready for inevitably switching the default at some point hence jumping through a few weird hoops with this sort of stuff. Python 3 now produces:
```
e:\work\upstream-llvm\llvm\utils>py -3 update_mca_test_checks.py ..\test\tools\llvm-mca\*\*.s
Test: ..\test\tools\llvm-mca\ARM\simple-test-cortex-a9.s
[38 lines total]
Traceback (most recent call last):
File "update_mca_test_checks.py", line 499, in <module>
sys.exit(main())
File "update_mca_test_checks.py", line 491, in main
prefix_pad)
File "update_mca_test_checks.py", line 458, in _write_output
f.writelines([l + '\n' for l in output_lines])
TypeError: a bytes-like object is required, not 'str'
```
Repository:
rL LLVM
https://reviews.llvm.org/D47697
More information about the llvm-commits
mailing list