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 <[email protected]> --- framework/profile.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/framework/profile.py b/framework/profile.py index 9bdc720..987873b 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 -- 2.8.2 _______________________________________________ Piglit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/piglit
