summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/runtime
diff options
context:
space:
mode:
authorPaulo Neves <ptsneves@gmail.com>2018-08-06 13:26:58 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2018-08-08 10:52:00 +0100
commit4a127a70a2b3fe6cb862fbb7508c48909e9588ac (patch)
treeef676c11c36459fdfcb7b7060c26de034c443b5b /meta/lib/oeqa/runtime
parent8ecf87ec1d9a07fe0c0b201b513e2502e38d3df1 (diff)
downloadpoky-4a127a70a2b3fe6cb862fbb7508c48909e9588ac.tar.gz
context.py: Do not mask exceptions needlessly.
There were a lot of assumptions in the controller import code of context.py which were not true anymore. These assumptions reflected themselves by catching exceptions and re-raising them with unhelpful error messages in other parts of the code. This commit does not fix the classes controller classes that became broken after the refactor but at least it allows for the exceptions to be thrown where the imports fail, thus actually showing what exactly went wrong with the import. An example of such an improvement is that before if the controller class failed during it's init contructor the controller would just be skipped and the task would just complain it could not find the controller. Now for example, if there is a NamerError due to a variable not being declared, the user will get that report. (From OE-Core rev: 719b0e88b875b067551067874778061f99b8c4b4) Signed-off-by: Paulo Neves <ptsneves@gmail.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/runtime')
-rw-r--r--meta/lib/oeqa/runtime/context.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/meta/lib/oeqa/runtime/context.py b/meta/lib/oeqa/runtime/context.py
index 0294003fc7..a7f3823996 100644
--- a/meta/lib/oeqa/runtime/context.py
+++ b/meta/lib/oeqa/runtime/context.py
@@ -112,12 +112,9 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
112 # XXX: Don't base your targets on this code it will be refactored 112 # XXX: Don't base your targets on this code it will be refactored
113 # in the near future. 113 # in the near future.
114 # Custom target module loading 114 # Custom target module loading
115 try: 115 target_modules_path = kwargs.get('target_modules_path', '')
116 target_modules_path = kwargs.get('target_modules_path', '') 116 controller = OERuntimeTestContextExecutor.getControllerModule(target_type, target_modules_path)
117 controller = OERuntimeTestContextExecutor.getControllerModule(target_type, target_modules_path) 117 target = controller(logger, target_ip, server_ip, **kwargs)
118 target = controller(logger, target_ip, server_ip, **kwargs)
119 except ImportError as e:
120 raise TypeError("Failed to import %s from available controller modules" % target_type)
121 118
122 return target 119 return target
123 120
@@ -173,10 +170,7 @@ class OERuntimeTestContextExecutor(OETestContextExecutor):
173 def _loadControllerFromModule(target, modulename): 170 def _loadControllerFromModule(target, modulename):
174 obj = None 171 obj = None
175 # import module, allowing it to raise import exception 172 # import module, allowing it to raise import exception
176 try: 173 module = __import__(modulename, globals(), locals(), [target])
177 module = __import__(modulename, globals(), locals(), [target])
178 except Exception as e:
179 return obj
180 # look for target class in the module, catching any exceptions as it 174 # look for target class in the module, catching any exceptions as it
181 # is valid that a module may not have the target class. 175 # is valid that a module may not have the target class.
182 try: 176 try: