提交 28a08d8e 编写于 作者: L Lukáš Doktor

avocado.plugins.yaml_to_mux: Allow empty yaml files

This patch avoids avocado crash on empty multiplex yaml file. Empty file
contains basically nothing and that is how it's handled now.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 6be4aca0
......@@ -170,6 +170,8 @@ def _create_from_yaml(path, cls_node=tree.TreeNode):
# Load the tree
with open(path) as stream:
loaded_tree = yaml.load(stream, Loader)
if loaded_tree is None:
return
loaded_tree = tree_node_from_values('', loaded_tree)
# Add prefix
......@@ -192,12 +194,16 @@ def create_from_yaml(paths, debug=False):
"""
def _merge(data, path):
""" Normal run """
data.merge(_create_from_yaml(path))
tmp = _create_from_yaml(path)
if tmp:
data.merge(tmp)
def _merge_debug(data, path):
""" Use NamedTreeNodeDebug magic """
node_cls = tree.get_named_tree_cls(path)
data.merge(_create_from_yaml(path, node_cls))
tmp = _create_from_yaml(path, node_cls)
if tmp:
data.merge(tmp)
if not debug:
data = tree.TreeNode()
......
......@@ -34,12 +34,17 @@ class MultiplexTests(unittest.TestCase):
def setUp(self):
self.tmpdir = tempfile.mkdtemp(prefix='avocado_' + __name__)
def run_and_check(self, cmd_line, expected_rc):
def run_and_check(self, cmd_line, expected_rc, tests=None):
os.chdir(basedir)
result = process.run(cmd_line, ignore_status=True)
self.assertEqual(result.exit_status, expected_rc,
"Command %s did not return rc "
"%d:\n%s" % (cmd_line, expected_rc, result))
if tests:
exp = ("PASS %s | ERROR 0 | FAIL %s | SKIP 0 | WARN 0 | "
"INTERRUPT 0" % tests)
self.assertIn(exp, result.stdout, "%s not in stdout:\n%s"
% (exp, result))
return result
def test_mplex_plugin(self):
......@@ -101,6 +106,12 @@ class MultiplexTests(unittest.TestCase):
expected_rc = exit_codes.AVOCADO_ALL_OK
self.run_and_check(cmd_line, expected_rc)
def test_empty_file(self):
cmd_line = ("./scripts/avocado run -m selftests/.data/empty_file "
"-- passtest.py")
result = self.run_and_check(cmd_line, exit_codes.AVOCADO_ALL_OK,
(1, 0))
def test_run_mplex_params(self):
for variant_msg in (('/run/short', 'A'),
('/run/medium', 'ASDFASDF'),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册