1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

[NFC][lit] Cleanup code using string interpolation

LLVM now requires Python 3.6, so we can use string interpolation to make
code more readable.
This commit is contained in:
Julian Lettner 2021-01-26 10:54:16 -08:00
parent 1eb88d40b9
commit f11e7efb47
2 changed files with 9 additions and 18 deletions

View File

@ -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

View File

@ -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'<testsuite name={quo(name)} tests="{len(tests)}" failures="{failures}" skipped="{skipped}">\n')
file.write('<testsuite name={name} tests="{tests}" failures="{failures}" skipped="{skipped}">\n'.format(
name=quo(name), tests=len(tests), failures=failures, skipped=skipped))
file.write(f'<testsuite name={quo(name)} tests="{len(tests)}" failures="{failures}" skipped="{skipped}">\n')
for test in tests:
self._write_test(file, test, name)
file.write('</testsuite>\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'<testcase classname={quo(class_name)} name={quo(name)} time="{time:.2f}"')
file.write('<testcase classname={class_name} name={name} time="{time:.2f}"'.format(
class_name=quo(class_name), name=quo(name), time=time))
file.write(f'<testcase classname={quo(class_name)} name={quo(name)} time="{time:.2f}"')
if test.isFailure():
file.write('>\n <failure><![CDATA[')
@ -140,9 +135,7 @@ class XunitReport(object):
file.write(']]></failure>\n</testcase>\n')
elif test.result.code in self.skipped_codes:
reason = self._get_skip_reason(test)
# file.write(f'>\n <skipped message={quo(reason)}/>\n</testcase>\n')
file.write('>\n <skipped message={reason}/>\n</testcase>\n'.format(
reason=quo(reason)))
file.write(f'>\n <skipped message={quo(reason)}/>\n</testcase>\n')
else:
file.write('/>\n')