Currently if one specifies a non-existant module (ie: piglit run deqp_gles4 out), then an uncaught ImportError will be raised. This patch fixes that by catching the exception and re-raising a PiglitFatalError.
Signed-off-by: Dylan Baker <[email protected]> --- framework/profile.py | 11 +++++++++-- framework/tests/profile_tests.py | 6 ++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/framework/profile.py b/framework/profile.py index 66d7899..bce28b9 100644 --- a/framework/profile.py +++ b/framework/profile.py @@ -411,7 +411,7 @@ class TestProfile(object): def load_test_profile(filename): - """ Load a python module and return it's profile attribute + """Load a python module and return it's profile attribute. All of the python test files provide a profile attribute which is a TestProfile instance. This loads that module and returns it or raises an @@ -419,7 +419,10 @@ def load_test_profile(filename): This method doesn't care about file extensions as a way to be backwards compatible with script wrapping piglit. 'tests/quick', 'tests/quick.tests', - and 'tests/quick.py' are all equally valid for filename + and 'tests/quick.py' are all equally valid for filename. + + This will raise a FatalError if the module doesn't exist, or if the module + doesn't have a profile attribute. Arguments: filename -- the name of a python module to get a 'profile' from @@ -433,6 +436,10 @@ def load_test_profile(filename): raise exceptions.PiglitFatalError( 'There is not profile attribute in module {}.\n' 'Did you specify the right file?'.format(filename)) + except ImportError: + raise exceptions.PiglitFatalError( + 'There is no test profile called "{}".\n' + 'Check your spelling?'.format(filename)) def merge_test_profiles(profiles): diff --git a/framework/tests/profile_tests.py b/framework/tests/profile_tests.py index 2488e7b..765528e 100644 --- a/framework/tests/profile_tests.py +++ b/framework/tests/profile_tests.py @@ -52,6 +52,12 @@ def test_load_test_profile_no_profile(): profile.load_test_profile('__init__') [email protected](exceptions.PiglitFatalError) +def test_load_test_profile_no_module(): + """profile.load_test_profile: Trying to load a non-existant module exits""" + profile.load_test_profile('this_module_will_never_ever_exist') + + def test_load_test_profile_returns(): """profile.load_test_profile: returns a TestProfile instance""" profile_ = profile.load_test_profile('sanity') -- 2.4.3 _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
