diff options
| author | Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> | 2019-12-02 10:50:23 +0000 |
|---|---|---|
| committer | Alex Richardson <Alexander.Richardson@cl.cam.ac.uk> | 2019-12-02 11:06:30 +0000 |
| commit | d9542db49e90457de62af3bfe395aaf4c47b68a5 (patch) | |
| tree | 377ec48c0c1ddcf014f94a3a472e29e3f6b1f80f /llvm/utils/update_mca_test_checks.py | |
| parent | 160a5045c699ac523eac3c7a1984705c3e86720e (diff) | |
| download | bcm5719-llvm-d9542db49e90457de62af3bfe395aaf4c47b68a5.tar.gz bcm5719-llvm-d9542db49e90457de62af3bfe395aaf4c47b68a5.zip | |
[UpdateTestChecks] Share the code to parse RUN: lines between all scripts
Summary:
This commit also introduces a common.debug() function to avoid many
`if args.verbose:` statements. Depends on D70428.
Reviewers: xbolva00, MaskRay, jdoerfert
Reviewed By: MaskRay
Subscribers: llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D70432
Diffstat (limited to 'llvm/utils/update_mca_test_checks.py')
| -rwxr-xr-x | llvm/utils/update_mca_test_checks.py | 30 |
1 files changed, 2 insertions, 28 deletions
diff --git a/llvm/utils/update_mca_test_checks.py b/llvm/utils/update_mca_test_checks.py index ba0a99392e0..0522c80be4d 100755 --- a/llvm/utils/update_mca_test_checks.py +++ b/llvm/utils/update_mca_test_checks.py @@ -83,26 +83,6 @@ def _parse_args(): return args -def _find_run_lines(input_lines, args): - raw_lines = [m.group(1) - for m in [common.RUN_LINE_RE.match(l) for l in input_lines] - if m] - run_lines = [raw_lines[0]] if len(raw_lines) > 0 else [] - for l in raw_lines[1:]: - if run_lines[-1].endswith(r'\\'): - run_lines[-1] = run_lines[-1].rstrip('\\') + ' ' + l - else: - run_lines.append(l) - - if args.verbose: - sys.stderr.write('Found {} RUN line{}:\n'.format( - len(run_lines), '' if len(run_lines) == 1 else 's')) - for line in run_lines: - sys.stderr.write(' RUN: {}\n'.format(line)) - - return run_lines - - def _get_run_infos(run_lines, args): run_infos = [] for run_line in run_lines: @@ -544,9 +524,7 @@ def _write_output(test_path, input_lines, prefix_list, block_infos, # noqa return sys.stderr.write(' [{} lines total]\n'.format(len(output_lines))) - if args.verbose: - sys.stderr.write( - 'Writing {} lines to {}...\n\n'.format(len(output_lines), test_path)) + common.debug('Writing', len(output_lines), 'lines to', test_path, '..\n\n') with open(test_path, 'wb') as f: f.writelines(['{}\n'.format(l).encode('utf-8') for l in output_lines]) @@ -562,17 +540,13 @@ def main(): # will be written once per source location per test. _configure_warnings(args) - if args.verbose: - sys.stderr.write( - 'Scanning for RUN lines in test file: {}\n'.format(test_path)) - if not os.path.isfile(test_path): raise Error('could not find test file: {}'.format(test_path)) with open(test_path) as f: input_lines = [l.rstrip() for l in f] - run_lines = _find_run_lines(input_lines, args) + run_lines = common.find_run_lines(test_path, input_lines) run_infos = _get_run_infos(run_lines, args) common_prefix, prefix_pad = _get_useful_prefix_info(run_infos) block_infos = _get_block_infos(run_infos, test_path, args, common_prefix) |

