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.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/llvm/utils/UpdateTestChecks/common.py b/llvm/utils/UpdateTestChecks/common.py
index cf382c0..7e538d7 100644
--- a/llvm/utils/UpdateTestChecks/common.py
+++ b/llvm/utils/UpdateTestChecks/common.py
@@ -18,6 +18,13 @@ from typing import List
_verbose = False
_prefix_filecheck_ir_name = ''
+"""
+Version changelog:
+
+1: Initial version, used by tests that don't specify --version explicitly.
+"""
+DEFAULT_VERSION = 1
+
class Regex(object):
"""Wrap a compiled regular expression object to allow deep copy of a regexp.
This is required for the deep copy done in do_scrub.
@@ -138,6 +145,10 @@ def parse_commandline_args(parser):
dest='gen_unused_prefix_body',
default=True,
help='Generate a function body that always matches for unused prefixes. This is useful when unused prefixes are desired, and it avoids needing to annotate each FileCheck as allowing them.')
+ # This is the default when regenerating existing tests. The default when
+ # generating new tests is determined by DEFAULT_VERSION.
+ parser.add_argument('--version', type=int, default=1,
+ help='The version of output format')
args = parser.parse_args()
global _verbose, _global_value_regex, _global_hex_value_regex
_verbose = args.verbose
@@ -226,12 +237,18 @@ def itertests(test_patterns, parser, script_name, comment_prefix=None, argparse_
for test in tests_list:
with open(test) as f:
input_lines = [l.rstrip() for l in f]
- args = parser.parse_args()
+ first_line = input_lines[0] if input_lines else ""
+ is_regenerate = UTC_ADVERT in first_line
+
+ # If we're generating a new test, set the default version to the latest.
+ argv = sys.argv[:]
+ if not is_regenerate:
+ argv.insert(1, '--version=' + str(DEFAULT_VERSION))
+
+ args = parser.parse_args(argv[1:])
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 is_regenerate:
if script_name not in first_line and not args.force_update:
warn("Skipping test which wasn't autogenerated by " + script_name, test)
continue