diff options
author | David Bolvansky <david.bolvansky@gmail.com> | 2019-08-07 14:44:50 +0000 |
---|---|---|
committer | David Bolvansky <david.bolvansky@gmail.com> | 2019-08-07 14:44:50 +0000 |
commit | 7169ea391a7cc21da171e1c8acb5731e390d6852 (patch) | |
tree | 9c99dc047d4bbe2cff98004e71a0c91cfe11799a /llvm/utils/UpdateTestChecks | |
parent | 762bc3351f29b5a71dca31ddd114034a383ff0bd (diff) | |
download | bcm5719-llvm-7169ea391a7cc21da171e1c8acb5731e390d6852.tar.gz bcm5719-llvm-7169ea391a7cc21da171e1c8acb5731e390d6852.zip |
[UpdateTestChecks] Update tests option
Summary:
Port of new feature introduced https://reviews.llvm.org/D65610 to other update scripts.
- update_*_checks.py: add an alias -u for --update-only
- port --update-only to other update_*_test_checks.py scripts
- update script aborts if the test file was generated by another update_*_test_checks.py utility
Reviewers: lebedev.ri, RKSimon, MaskRay, reames, gbedwell
Reviewed By: MaskRay
Subscribers: llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D65793
llvm-svn: 368174
Diffstat (limited to 'llvm/utils/UpdateTestChecks')
-rw-r--r-- | llvm/utils/UpdateTestChecks/common.py | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py index 336ccb9ba77..ecb3a0f0a72 100644 --- a/llvm/utils/UpdateTestChecks/common.py +++ b/llvm/utils/UpdateTestChecks/common.py @@ -72,6 +72,17 @@ SCRUB_KILL_COMMENT_RE = re.compile(r'^ *#+ +kill:.*\n') SCRUB_LOOP_COMMENT_RE = re.compile( r'# =>This Inner Loop Header:.*|# in Loop:.*', flags=re.M) + +def error(msg, test_file=None): + if test_file: + msg = '{}: {}'.format(msg, test_file) + print('ERROR: {}'.format(msg), file=sys.stderr) + +def warn(msg, test_file=None): + if test_file: + msg = '{}: {}'.format(msg, test_file) + print('WARNING: {}'.format(msg), file=sys.stderr) + def scrub_body(body): # Scrub runs of whitespace out of the assembly, but leave the leading # whitespace in place. @@ -108,7 +119,7 @@ def build_function_body_dictionary(function_re, scrubber, scrubber_args, raw_too if 'analysis' in m.groupdict(): analysis = m.group('analysis') if analysis.lower() != 'cost model analysis': - print('WARNING: Unsupported analysis mode: %r!' % (analysis,), file=sys.stderr) + warn('Unsupported analysis mode: %r!' % (analysis,)) if func.startswith('stress'): # We only use the last line of the function body for stress tests. scrubbed_body = '\n'.join(scrubbed_body.splitlines()[-1:]) @@ -123,8 +134,7 @@ def build_function_body_dictionary(function_re, scrubber, scrubber_args, raw_too continue else: if prefix == prefixes[-1]: - print('WARNING: Found conflicting asm under the ' - 'same prefix: %r!' % (prefix,), file=sys.stderr) + warn('Found conflicting asm under the same prefix: %r!' % (prefix,)) else: func_dict[prefix][func] = None continue @@ -272,8 +282,8 @@ def check_prefix(prefix): hint = "" if ',' in prefix: hint = " Did you mean '--check-prefixes=" + prefix + "'?" - print(("WARNING: Supplied prefix '%s' is invalid. Prefix must contain only alphanumeric characters, hyphens and underscores." + hint) % - (prefix), file=sys.stderr) + warn(("Supplied prefix '%s' is invalid. Prefix must contain only alphanumeric characters, hyphens and underscores." + hint) % + (prefix)) def verify_filecheck_prefixes(fc_cmd): @@ -287,5 +297,4 @@ def verify_filecheck_prefixes(fc_cmd): for prefix in prefixes: check_prefix(prefix) if prefixes.count(prefix) > 1: - print("WARNING: Supplied prefix '%s' is not unique in the prefix list." % - (prefix,), file=sys.stderr) + warn("Supplied prefix '%s' is not unique in the prefix list." % (prefix,)) |