diff options
Diffstat (limited to 'llvm/utils/update_analyze_test_checks.py')
-rwxr-xr-x | llvm/utils/update_analyze_test_checks.py | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/llvm/utils/update_analyze_test_checks.py b/llvm/utils/update_analyze_test_checks.py index 6c75388b670..db9be1333e1 100755 --- a/llvm/utils/update_analyze_test_checks.py +++ b/llvm/utils/update_analyze_test_checks.py @@ -58,14 +58,17 @@ def main(): help='The opt binary used to generate the test case') parser.add_argument( '--function', help='The function in the test file to update') + parser.add_argument('-u', '--update-only', action='store_true', + help='Only update test if it was already autogened') parser.add_argument('tests', nargs='+') args = parser.parse_args() - autogenerated_note = (ADVERT + 'utils/' + os.path.basename(__file__)) + script_name = os.path.basename(__file__) + autogenerated_note = (ADVERT + 'utils/' + script_name) opt_basename = os.path.basename(args.opt_binary) if (opt_basename != "opt"): - print('ERROR: Unexpected opt name: ' + opt_basename, file=sys.stderr) + common.error('Unexpected opt name: ' + opt_basename) sys.exit(1) test_paths = [test for pattern in args.tests for test in glob.glob(pattern)] @@ -75,6 +78,16 @@ def main(): with open(test) as f: input_lines = [l.rstrip() for l in f] + first_line = input_lines[0] if input_lines else "" + if 'autogenerated' in first_line and script_name not in first_line: + common.warn("Skipping test which wasn't autogenerated by " + script_name + ": " + test) + continue + + if args.update_only: + if not first_line or 'autogenerated' not in first_line: + common.warn("Skipping test which isn't autogenerated: " + test) + continue + 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 [] @@ -91,15 +104,19 @@ def main(): prefix_list = [] for l in run_lines: + if '|' not in l: + common.warn('Skipping unparseable RUN line: ' + l) + continue + (tool_cmd, filecheck_cmd) = tuple([cmd.strip() for cmd in l.split('|', 1)]) common.verify_filecheck_prefixes(filecheck_cmd) if not tool_cmd.startswith(opt_basename + ' '): - print('WARNING: Skipping non-%s RUN line: %s' % (opt_basename, l), file=sys.stderr) + common.warn('WSkipping non-%s RUN line: %s' % (opt_basename, l)) continue if not filecheck_cmd.startswith('FileCheck '): - print('WARNING: Skipping non-FileChecked RUN line: ' + l, file=sys.stderr) + common.warn('Skipping non-FileChecked RUN line: ' + l) continue tool_cmd_args = tool_cmd[len(opt_basename):].strip() |