Commit 9e77bd0c authored by Mathieu Giraud's avatar Mathieu Giraud

Merge branch 'feature-options' into 'dev'

Feature options

See merge request !11
parents 6df6bebb 50c51ea3
Pipeline #71670 passed with stages
in 12 seconds
./should --no-f demo/cal.should
$ Do not launch any 'f' test
0:TODO
./should --no-a demo/cal.should
$ Do not launch any 'a' test
0:ALLOW
./should --only-f demo/cal.should
$ Launch only the two 'f' tests
r:Summary.* TODO:2
r:Summary.* total:2
./should --only-a demo/cal.should
$ Launch only the unique 'a' test
......
......@@ -242,16 +242,17 @@ for (mod_char, mod_long, mod_help) in MODIFIERS:
parser = ArgParser(description='Test command-line applications through .should files',
fromfile_prefix_chars='@',
epilog='''Example:
epilog='''Example (see also README.md and demo/*.should):
%(prog)s demo/hello.should''',
add_help=False,
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('--version', action='version',
version='%(prog)s {version}'.format(version=__version__))
options = ArgParser(fromfile_prefix_chars='@') # Can be used in !OPTIONS: directive
for p in (parser, options):
group = parser.add_argument_group('running tests (can also be set per test in !OPTIONS)')
for p in (group, options):
p.add_argument('--cd', metavar='PATH', help='directory from which to run the test commands')
p.add_argument('--cd-same', action='store_true', help='run the test commands from the same directory as the .should files')
p.add_argument('--launcher', metavar='CMD', default='', help='launcher preceding each command (or replacing %s)' % VAR_LAUNCHER)
......@@ -260,14 +261,17 @@ for p in (parser, options):
p.add_argument('--var', metavar='NAME=value', action='append', help='variable definition (then use $NAME in .should files)')
p.add_argument('--timeout', type=int, default = TIMEOUT, help = 'Delay (in seconds) after which the task is stopped (default: %(default)d)')
parser.add_argument('--shuffle', action='store_true', help='shuffle the tests')
group = parser.add_argument_group('filter options')
group = parser.add_argument_group('selecting tests to be run')
group.add_argument('--shuffle', action='store_true', help='shuffle the tests')
group.add_argument('--no-a', action='store_true', help="do not launch 'a' tests")
group.add_argument('--no-f', action='store_true', help="do not launch 'f' tests")
group.add_argument('--only-a', action='store_true', help="launches only 'a' tests")
group.add_argument('--only-f', action='store_true', help="launches only 'f' tests")
output = parser.add_argument_group('output options')
group.add_argument(RETRY_FLAG, action='store_true', help='launches only the last failed or warned tests')
output = parser.add_argument_group('controlling output')
output.add_argument('--log', action='append_const', dest='output', const=OUT_LOG, help='stores the output into .log files')
output.add_argument('--tap', action='append_const', dest='output', const=OUT_TAP, help='outputs .tap files')
......@@ -275,8 +279,12 @@ output.add_argument('--xml', action='append_const', dest='output', const=OUT_XML
output.add_argument('-v', '--verbose', action='count', help='increase verbosity', default=1)
output.add_argument('-q', '--quiet', action='store_const', dest='verbose', const=0, help='verbosity to zero')
output.add_argument("-h", "--help", action="help", help="show this help message and exit")
output.add_argument('--version', action='version',
version='%(prog)s {version}'.format(version=__version__))
parser.add_argument('file', metavar='should-file', nargs='+', help='''input files (.should)''')
parser.add_argument(RETRY_FLAG, action='store_true', help='launch again the last failed or warned tests')
class ShouldException(BaseException):
pass
......@@ -1114,10 +1122,12 @@ if __name__ == '__main__':
random.shuffle(args.file)
# Filters
only = None
if args.only_f or args.only_a:
only = lambda test: ((MOD_TODO in test.modifiers) >= args.only_f) and ((MOD_ALLOW in test.modifiers) >= args.only_a)
only = lambda test: (
((MOD_TODO in test.modifiers) <= (not args.no_f)) and
((MOD_TODO in test.modifiers) >= args.only_f) and
((MOD_ALLOW in test.modifiers) <= (not args.no_a)) and
((MOD_ALLOW in test.modifiers) >= args.only_a)
)
# Launch tests
fs = FileSet(args.file, timeout = args.timeout, modifiers=''.join(args.mod if args.mod else []))
status = fs.test(variables = variables, cd = args.cd, cd_same = args.cd_same, output = args.output, verbose = args.verbose, only = only)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment