import lit.util
+
def parse_args():
- parser = argparse.ArgumentParser()
+ parser = argparse.ArgumentParser(prog='lit')
parser.add_argument('test_paths',
nargs='+',
metavar="TEST_PATH",
help='File or path to include in the test suite')
- parser.add_argument("--version",
- dest="show_version",
- help="Show version and exit",
- version="lit " + lit.__version__,
- action="version")
+ parser.add_argument('--version',
+ action='version',
+ version='%(prog)s ' + lit.__version__)
parser.add_argument("-j", "--threads", "--workers",
dest="workers",
return opts
+
def _positive_int(arg):
return _int(arg, 'positive', lambda i: i > 0)
+
def _non_negative_int(arg):
return _int(arg, 'non-negative', lambda i: i >= 0)
+
def _int(arg, kind, pred):
desc = "requires {} integer, but found '{}'"
try:
raise _error(desc, kind, arg)
return i
+
def _case_insensitive_regex(arg):
import re
try:
except re.error as reason:
raise _error("invalid regular expression: '{}', {}", arg, reason)
+
def _error(desc, *args):
msg = desc.format(*args)
return argparse.ArgumentTypeError(msg)
-# Basic sanity check that usage works.
+# Basic sanity check for `--help` and `--version` options.
#
-# RUN: %{lit} --help > %t.out
-# RUN: FileCheck < %t.out %s
+# RUN: %{lit} --help | FileCheck %s --check-prefix=HELP
+# RUN: %{lit} --version 2>&1 | FileCheck %s --check-prefix=VERSION
#
-# CHECK: usage: lit.py [-h]
+# HELP: usage: lit [-h]
+# VERSION: lit {{[0-9]+\.[0-9]+\.[0-9]+[a-zA-Z0-9]*}}