From 63273fc41fccf11962ce6ec4df91fee703e5ab57 Mon Sep 17 00:00:00 2001 From: Julian Lettner Date: Tue, 26 Jan 2021 10:54:16 -0800 Subject: [PATCH] [NFC][lit] Cleanup code using string interpolation LLVM now requires Python 3.6, so we can use string interpolation to make code more readable. --- llvm/utils/lit/lit/main.py | 12 +++++------- llvm/utils/lit/lit/reports.py | 15 ++++----------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/llvm/utils/lit/lit/main.py b/llvm/utils/lit/lit/main.py index 6c9885c4d4be..3d4f6701228d 100755 --- a/llvm/utils/lit/lit/main.py +++ b/llvm/utils/lit/lit/main.py @@ -179,14 +179,12 @@ def filter_by_shard(tests, run, shards, lit_config): # For clarity, generate a preview of the first few test indices in the shard # to accompany the arithmetic expression. preview_len = 3 - preview = ", ".join([str(i + 1) for i in test_ixs[:preview_len]]) + preview = ', '.join([str(i + 1) for i in test_ixs[:preview_len]]) if len(test_ixs) > preview_len: - preview += ", ..." - # TODO(python3): string interpolation - msg = 'Selecting shard {run}/{shards} = size {sel_tests}/{total_tests} = ' \ - 'tests #({shards}*k)+{run} = [{preview}]'.format( - run=run, shards=shards, sel_tests=len(selected_tests), - total_tests=len(tests), preview=preview) + preview += ', ...' + msg = f'Selecting shard {run}/{shards} = ' \ + f'size {len(selected_tests)}/{len(tests)} = ' \ + f'tests #({shards}*k)+{run} = [{preview}]' lit_config.note(msg) return selected_tests diff --git a/llvm/utils/lit/lit/reports.py b/llvm/utils/lit/lit/reports.py index 3d4aecf0c4d3..c7eed2220a4d 100755 --- a/llvm/utils/lit/lit/reports.py +++ b/llvm/utils/lit/lit/reports.py @@ -104,22 +104,17 @@ class XunitReport(object): failures = sum(1 for t in tests if t.isFailure()) name = suite.config.name.replace('.', '-') - # file.write(f'\n') - file.write('\n'.format( - name=quo(name), tests=len(tests), failures=failures, skipped=skipped)) + file.write(f'\n') for test in tests: self._write_test(file, test, name) file.write('\n') def _write_test(self, file, test, suite_name): path = '/'.join(test.path_in_suite[:-1]).replace('.', '_') - # class_name = f'{suite_name}.{path or suite_name}' - class_name = suite_name + '.' + (path or suite_name) + class_name = f'{suite_name}.{path or suite_name}' name = test.path_in_suite[-1] time = test.result.elapsed or 0.0 - # file.write(f'\n \n\n') elif test.result.code in self.skipped_codes: reason = self._get_skip_reason(test) - # file.write(f'>\n \n\n') - file.write('>\n \n\n'.format( - reason=quo(reason))) + file.write(f'>\n \n\n') else: file.write('/>\n')