aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/UpdateTestChecks/common.py
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/utils/UpdateTestChecks/common.py')
-rw-r--r--llvm/utils/UpdateTestChecks/common.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index 17f7386..35b7ba6 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -44,8 +44,9 @@ class InputLineInfo(object):
class TestInfo(object):
def __init__(self, test, parser, script_name, input_lines, args, argv,
- comment_prefix):
+ comment_prefix, argparse_callback):
self.parser = parser
+ self.argparse_callback = argparse_callback
self.path = test
self.args = args
self.argv = argv
@@ -68,14 +69,14 @@ class TestInfo(object):
if input_line.startswith(self.autogenerated_note_prefix):
continue
self.args, self.argv = check_for_command(input_line, self.parser,
- self.args, self.argv)
+ self.args, self.argv, self.argparse_callback)
if not self.args.enabled:
output_lines.append(input_line)
continue
yield InputLineInfo(input_line, line_num, self.args, self.argv)
-def itertests(test_patterns, parser, script_name, comment_prefix=None):
+def itertests(test_patterns, parser, script_name, comment_prefix=None, argparse_callback=None):
for pattern in test_patterns:
# On Windows we must expand the patterns ourselves.
tests_list = glob.glob(pattern)
@@ -86,19 +87,21 @@ def itertests(test_patterns, parser, script_name, comment_prefix=None):
with open(test) as f:
input_lines = [l.rstrip() for l in f]
args = parser.parse_args()
+ if argparse_callback is not None:
+ argparse_callback(args)
argv = sys.argv[:]
first_line = input_lines[0] if input_lines else ""
if UTC_ADVERT in first_line:
if script_name not in first_line and not args.force_update:
warn("Skipping test which wasn't autogenerated by " + script_name, test)
continue
- args, argv = check_for_command(first_line, parser, args, argv)
+ args, argv = check_for_command(first_line, parser, args, argv, argparse_callback)
elif args.update_only:
assert UTC_ADVERT not in first_line
warn("Skipping test which isn't autogenerated: " + test)
continue
yield TestInfo(test, parser, script_name, input_lines, args, argv,
- comment_prefix)
+ comment_prefix, argparse_callback)
def should_add_line_to_output(input_line, prefix_set):
@@ -510,10 +513,12 @@ def get_autogennote_suffix(parser, args):
return autogenerated_note_args
-def check_for_command(line, parser, args, argv):
+def check_for_command(line, parser, args, argv, argparse_callback):
cmd_m = UTC_ARGS_CMD.match(line)
if cmd_m:
cmd = cmd_m.group('cmd').strip().split(' ')
argv = argv + cmd
args = parser.parse_args(filter(lambda arg: arg not in args.tests, argv))
+ if argparse_callback is not None:
+ argparse_callback(args)
return args, argv