diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2016-05-03 14:39:30 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2016-05-10 14:35:19 -0700 |
commit | cc4fcb5d966098ba4ea8b88e41441872694ef7ca (patch) | |
tree | 4df71585d90fc62f0b5c71b51007e0ef7f8c525f /framework | |
parent | 69d635b17d66957b8a598c7cb8dbdbd0ebdab657 (diff) |
framework/profile: Fail gracefully when reordering of tests fail
Currently if a test name is passed that doesn't exist in the first
profile a stack trace will be generated. This isn't necessary, since
it's an expected behavior that reordering fails when asked to order
a test not contained in the profile. Instead just fail gracefully with
a helpful message.
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/profile.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/framework/profile.py b/framework/profile.py index 9bdc720ea..987873bb4 100644 --- a/framework/profile.py +++ b/framework/profile.py @@ -170,8 +170,15 @@ class TestDict(collections.MutableMapping): def reorder(self, order): """Reorder the TestDict to match the order of the provided list.""" new = collections.OrderedDict() - for k in order: - new[k] = self.__container[k] + try: + for k in order: + new[k] = self.__container[k] + except KeyError: + # If there is a name in order that isn't available in self there + # will be a KeyError, this is expected. In this case fail + # gracefully and report the error to the user. + raise exceptions.PiglitFatalError( + 'Cannot reorder test: "{}", it is not in the profile.'.format(k)) self.__container = new |