From d019995656c17888ed2f2749fafff43d6c27f67b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= Date: Thu, 1 Oct 2015 18:46:23 +0200 Subject: [PATCH] avocado.core.tree: Improve error message on missing !include file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a multiplex file includes a missing file, avocado only reports "there is a missing file" without any explanations whatsoever. This patch changes it to a ValueError with the original file and the missing one. Additionally it adds missing Exception to try/except, which was already possible on certain errors, to avoid tracebacks. Signed-off-by: Lukáš Doktor --- avocado/core/job.py | 4 ++-- avocado/core/tree.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/avocado/core/job.py b/avocado/core/job.py index 30a8485d..0e15d922 100644 --- a/avocado/core/job.py +++ b/avocado/core/job.py @@ -461,8 +461,8 @@ class Job(object): try: mux = multiplexer.Mux(self.args) - except IOError, details: - raise exceptions.OptionValidationError(details.strerror) + except (IOError, ValueError), details: + raise exceptions.OptionValidationError(details) self.args.test_result_total = mux.get_number_of_tests(test_suite) self._make_test_result() diff --git a/avocado/core/tree.py b/avocado/core/tree.py index 62ea6b8e..cd0c0eb0 100644 --- a/avocado/core/tree.py +++ b/avocado/core/tree.py @@ -333,6 +333,9 @@ def _create_from_yaml(path, cls_node=TreeNode): ypath = value[1] if not os.path.isabs(ypath): ypath = os.path.join(os.path.dirname(path), ypath) + if not os.path.exists(ypath): + raise ValueError("File '%s' included from '%s' does not " + "exist." % (ypath, path)) node.merge(_create_from_yaml('/:' + ypath, cls_node)) elif value[0].code == YAML_USING: if using: -- GitLab