[Piglit] [Patch v2 2/4] framework/core.py: Add pre_run and post_run hooks to TestProfile
Tom Stellard
tom at stellard.net
Tue Apr 8 13:16:29 PDT 2014
On Tue, Apr 08, 2014 at 01:12:35PM -0700, Dylan Baker wrote:
> These hooks no-op in the default TestProfile class, however they are
> intended to give versatility and power to external test suites, which
> may have specific environment requirements, setup requirements, or
> teardown requirements, by allowing them to subclass TestProfile and set
> these methods.
Do you have an example of what these hooks could be used for?
-Tom
> ---
> framework/core.py | 24 +++++++++++++++++++++++-
> 1 file changed, 23 insertions(+), 1 deletion(-)
>
> diff --git a/framework/core.py b/framework/core.py
> index 5238f60..48dd9b0 100644
> --- a/framework/core.py
> +++ b/framework/core.py
> @@ -474,14 +474,34 @@ class TestProfile(object):
> self.test_list = dict(item for item in self.test_list.iteritems()
> if check_all(item))
>
> + def pre_run_hook(self):
> + """ Hook executed at the start of TestProfile.run
> +
> + To make use of this hook one will need to subclass TestProfile, and
> + set this to do something, as be dfault it will no-op
> +
> + """
> + pass
> +
> + def post_run_hook(self):
> + """ Hook executed at the end of TestProfile.run
> +
> + To make use of this hook one will need to subclass TestProfile, and
> + set this to do something, as be dfault it will no-op
> +
> + """
> + pass
> +
> def run(self, env, json_writer):
> '''
> Schedule all tests in profile for execution.
>
> See ``Test.schedule`` and ``Test.run``.
> '''
> -
> self.prepare_test_list(env)
> +
> + self.pre_run_hook()
> +
> log = Log(len(self.test_list), env.verbose)
>
> def test(pair):
> @@ -523,6 +543,8 @@ class TestProfile(object):
>
> log.summary()
>
> + self.post_run_hook()
> +
> def filter_tests(self, function):
> """Filter out tests that return false from the supplied function
>
> --
> 1.9.1
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
More information about the Piglit
mailing list