提交 3423ca96 编写于 作者: L Lukáš Doktor

avocado.core.parser: Introduce "mux_debug" option

The mux need to support debugging the options. This is a basic
implementation which allows requesting mux to use TreeNodeDebug. Then
it's the plugin's job to check whether mux uses debug (`mux.debug`) and
act accordingly.

In this basic implementation the debug is only enabled for `--multiplex`
and `@None` is used for other injects (like `--mux-inject`)
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 c773cbce
......@@ -391,22 +391,27 @@ class Mux(object):
This is a multiplex object which multiplexes the test_suite.
"""
def __init__(self):
def __init__(self, debug=False):
"""
:param debug: Store whether this instance should debug the mux
:note: people need to check whether mux uses debug and reflect that
in order to provide the right results.
"""
self._has_multiple_variants = None
self.variants = None
self.data = tree.TreeNode()
self.debug = debug
self.data = tree.TreeNodeDebug() if debug else tree.TreeNode()
self._mux_path = None
def parse(self, args, debug=False):
def parse(self, args):
"""
Apply options defined on the cmdline
:param args: Parsed cmdline arguments
:param debug: Whether to debug the mux parsing
"""
filter_only = getattr(args, 'filter_only', None)
filter_out = getattr(args, 'filter_out', None)
self._parse_basic_injects(args, debug)
self._parse_basic_injects(args)
mux_tree = tree.apply_filters(self.data, filter_only, filter_out)
self.variants = MuxTree(mux_tree)
self._mux_path = getattr(args, 'mux_path', None)
......@@ -417,17 +422,16 @@ class Mux(object):
self.data_inject = _report_mux_already_parsed
self.data_merge = _report_mux_already_parsed
def _parse_basic_injects(self, args, debug):
def _parse_basic_injects(self, args):
"""
Inject data from the basic injects defined by Mux
:param args: Parsed cmdline arguments
:param debug: Whether to debug the mux parsing
"""
# Merge the multiplex_files
multiplex_files = getattr(args, "multiplex", None)
if multiplex_files:
self.data_merge(yaml2tree(multiplex_files, debug=debug))
self.data_merge(yaml2tree(multiplex_files, debug=self.debug))
# FIXME: Backward compatibility params, to be removed when 36 LTS is
# discontinued
......
......@@ -125,7 +125,7 @@ class Parser(object):
dest='subcommand')
# Allow overriding default params by plugins
self.args.mux = multiplexer.Mux()
self.args.mux = multiplexer.Mux(getattr(self.args, "mux-debug", False))
# FIXME: Backward compatibility params, to be removed when 36 LTS is
# discontinued
self.args.default_avocado_params = tree.TreeNode()
......
......@@ -57,8 +57,8 @@ class Multiplex(CLICmd):
"the final multiplex tree.")
env_parser = parser.add_argument_group("environment view options")
env_parser.add_argument('-d', '--debug', action='store_true',
default=False, help="Debug multiplexed "
"files.")
dest="mux_debug", default=False,
help="Debug the multiplex tree.")
tree_parser = parser.add_argument_group("tree view options")
tree_parser.add_argument('-t', '--tree', action='store_true',
default=False, help='Shows the multiplex '
......@@ -69,17 +69,17 @@ class Multiplex(CLICmd):
def run(self, args):
log = logging.getLogger("avocado.app")
err = None
if args.tree and args.debug:
if args.tree and args.mux_debug:
err = "Option --tree is incompatible with --debug."
elif not args.tree and args.inherit:
err = "Option --inherit can be only used with --tree"
if err:
log.error(err)
sys.exit(exit_codes.AVOCADO_FAIL)
mux = multiplexer.Mux()
mux = multiplexer.Mux(args.mux_debug)
root = mux.data
try:
mux.parse(args, debug=args.debug)
mux.parse(args)
except (IOError, ValueError) as details:
log.error("Unable to parse mux: %s", details)
sys.exit(exit_codes.AVOCADO_JOB_FAIL)
......@@ -97,7 +97,7 @@ class Multiplex(CLICmd):
log.info('Variants generated:')
for (index, tpl) in enumerate(mux.variants):
if not args.debug:
if not args.mux_debug:
paths = ', '.join([x.path for x in tpl])
else:
color = output.TERM_SUPPORT.LOWLIGHT
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册