1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

[UptestTestChecks][NFC] Share some common command line options code

Summary:
Add a function common.parse_commandline_args() that adds options common
to all tools (--verbose and --update-only) and returns the parsed
commandline arguments. I plan to use the shared parsing of --verbose in a
follow-up commit to remove most of the `if args.verbose:` checks in the
scripts.

Reviewers: xbolva00, MaskRay

Reviewed By: MaskRay

Subscribers: llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D70428
This commit is contained in:
Alex Richardson 2019-11-20 13:19:48 +00:00
parent 2188b5a3f1
commit b8a003f5ca
7 changed files with 14 additions and 28 deletions

View File

@ -13,6 +13,14 @@ else:
##### Common utilities for update_*test_checks.py ##### Common utilities for update_*test_checks.py
def parse_commandline_args(parser):
parser.add_argument('-v', '--verbose', action='store_true',
help='Show verbose output')
parser.add_argument('-u', '--update-only', action='store_true',
help='Only update test if it was already autogened')
return parser.parse_args()
def should_add_line_to_output(input_line, prefix_set): def should_add_line_to_output(input_line, prefix_set):
# Skip any blank comment lines in the IR. # Skip any blank comment lines in the IR.
if input_line.strip() == ';': if input_line.strip() == ';':

View File

@ -52,16 +52,12 @@ IR_FUNCTION_RE = re.compile('^\s*define\s+(?:internal\s+)?[^@]*@([\w-]+)\s*\(')
def main(): def main():
from argparse import RawTextHelpFormatter from argparse import RawTextHelpFormatter
parser = argparse.ArgumentParser(description=__doc__, formatter_class=RawTextHelpFormatter) parser = argparse.ArgumentParser(description=__doc__, formatter_class=RawTextHelpFormatter)
parser.add_argument('-v', '--verbose', action='store_true',
help='Show verbose output')
parser.add_argument('--opt-binary', default='opt', parser.add_argument('--opt-binary', default='opt',
help='The opt binary used to generate the test case') help='The opt binary used to generate the test case')
parser.add_argument( parser.add_argument(
'--function', help='The function in the test file to update') '--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='+') parser.add_argument('tests', nargs='+')
args = parser.parse_args() args = common.parse_commandline_args(parser)
script_name = os.path.basename(__file__) script_name = os.path.basename(__file__)
autogenerated_note = (ADVERT + 'utils/' + script_name) autogenerated_note = (ADVERT + 'utils/' + script_name)

View File

@ -90,7 +90,6 @@ def config():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description=__doc__, description=__doc__,
formatter_class=argparse.RawTextHelpFormatter) formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('-v', '--verbose', action='store_true')
parser.add_argument('--llvm-bin', help='llvm $prefix/bin path') parser.add_argument('--llvm-bin', help='llvm $prefix/bin path')
parser.add_argument('--clang', parser.add_argument('--clang',
help='"clang" executable, defaults to $llvm_bin/clang') help='"clang" executable, defaults to $llvm_bin/clang')
@ -104,10 +103,8 @@ def config():
parser.add_argument( parser.add_argument(
'--x86_extra_scrub', action='store_true', '--x86_extra_scrub', action='store_true',
help='Use more regex for x86 matching to reduce diffs between various subtargets') help='Use more regex for x86 matching to reduce diffs between various subtargets')
parser.add_argument('-u', '--update-only', action='store_true',
help='Only update test if it was already autogened')
parser.add_argument('tests', nargs='+') parser.add_argument('tests', nargs='+')
args = parser.parse_args() args = common.parse_commandline_args(parser)
args.clang_args = shlex.split(args.clang_args or '') args.clang_args = shlex.split(args.clang_args or '')
if args.clang is None: if args.clang is None:

View File

@ -24,8 +24,6 @@ ADVERT = ' NOTE: Assertions have been autogenerated by '
def main(): def main():
parser = argparse.ArgumentParser(description=__doc__) parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('-v', '--verbose', action='store_true',
help='Show verbose output')
parser.add_argument('--llc-binary', default='llc', parser.add_argument('--llc-binary', default='llc',
help='The "llc" binary to use to generate the test case') help='The "llc" binary to use to generate the test case')
parser.add_argument( parser.add_argument(
@ -38,10 +36,8 @@ def main():
help='Use more regex for x86 matching to reduce diffs between various subtargets') help='Use more regex for x86 matching to reduce diffs between various subtargets')
parser.add_argument( parser.add_argument(
'--no_x86_scrub_rip', action='store_false', dest='x86_scrub_rip') '--no_x86_scrub_rip', action='store_false', dest='x86_scrub_rip')
parser.add_argument('-u', '--update-only', action='store_true',
help='Only update test if it was already autogened')
parser.add_argument('tests', nargs='+') parser.add_argument('tests', nargs='+')
args = parser.parse_args() args = common.parse_commandline_args(parser)
script_name = os.path.basename(__file__) script_name = os.path.basename(__file__)

View File

@ -56,9 +56,6 @@ def _showwarning(message, category, filename, lineno, file=None, line=None):
def _parse_args(): def _parse_args():
parser = argparse.ArgumentParser(description=__doc__) parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('-v', '--verbose',
action='store_true',
help='show verbose output')
parser.add_argument('-w', parser.add_argument('-w',
action='store_true', action='store_true',
help='suppress warnings') help='suppress warnings')
@ -73,7 +70,7 @@ def _parse_args():
parser.add_argument('tests', parser.add_argument('tests',
metavar='<test-path>', metavar='<test-path>',
nargs='+') nargs='+')
args = parser.parse_args() args = common.parse_commandline_args(parser)
_configure_warnings(args) _configure_warnings(args)

View File

@ -430,17 +430,13 @@ def update_test_file(args, test):
def main(): def main():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawTextHelpFormatter) description=__doc__, formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('-v', '--verbose', action='store_true',
help='Show verbose output')
parser.add_argument('--llc-binary', dest='llc', default='llc', type=LLC, parser.add_argument('--llc-binary', dest='llc', default='llc', type=LLC,
help='The "llc" binary to generate the test case with') help='The "llc" binary to generate the test case with')
parser.add_argument('--remove-common-prefixes', action='store_true', parser.add_argument('--remove-common-prefixes', action='store_true',
help='Remove existing check lines whose prefixes are ' help='Remove existing check lines whose prefixes are '
'shared between multiple commands') 'shared between multiple commands')
parser.add_argument('-u', '--update-only', action='store_true',
help='Only update test if it was already autogened')
parser.add_argument('tests', nargs='+') parser.add_argument('tests', nargs='+')
args = parser.parse_args() args = common.parse_commandline_args(parser)
test_paths = [test for pattern in args.tests for test in glob.glob(pattern)] test_paths = [test for pattern in args.tests for test in glob.glob(pattern)]
for test in test_paths: for test in test_paths:

View File

@ -56,20 +56,16 @@ IR_FUNCTION_RE = re.compile('^\s*define\s+(?:internal\s+)?[^@]*@([\w-]+)\s*\(')
def main(): def main():
from argparse import RawTextHelpFormatter from argparse import RawTextHelpFormatter
parser = argparse.ArgumentParser(description=__doc__, formatter_class=RawTextHelpFormatter) parser = argparse.ArgumentParser(description=__doc__, formatter_class=RawTextHelpFormatter)
parser.add_argument('-v', '--verbose', action='store_true',
help='Show verbose output')
parser.add_argument('--opt-binary', default='opt', parser.add_argument('--opt-binary', default='opt',
help='The opt binary used to generate the test case') help='The opt binary used to generate the test case')
parser.add_argument( parser.add_argument(
'--function', help='The function in the test file to update') '--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('-p', '--preserve-names', action='store_true', parser.add_argument('-p', '--preserve-names', action='store_true',
help='Do not scrub IR names') help='Do not scrub IR names')
parser.add_argument('--function-signature', action='store_true', parser.add_argument('--function-signature', action='store_true',
help='Keep function signature information around for the check line') help='Keep function signature information around for the check line')
parser.add_argument('tests', nargs='+') parser.add_argument('tests', nargs='+')
args = parser.parse_args() args = common.parse_commandline_args(parser)
script_name = os.path.basename(__file__) script_name = os.path.basename(__file__)
autogenerated_note = (ADVERT + 'utils/' + script_name) autogenerated_note = (ADVERT + 'utils/' + script_name)