[Piglit] [PATCH 05/13] core.py: rename Environment to Options
Dylan Baker
baker.dylan.c at gmail.com
Sun Jun 22 15:48:16 PDT 2014
On Saturday, June 21, 2014 09:43:56 AM Ilia Mirkin wrote:
> On Sat, Jun 21, 2014 at 8:06 AM, Dylan Baker <baker.dylan.c at gmail.com>
wrote:
> > Environment doesn't really describe what the class is (although,
> > honestly it's a pretty bad class design), but Options comes much closer
> > to what it is.
> >
> > Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
> > ---
> >
> > framework/core.py | 17 +++++++++++++++--
> > framework/exectest.py | 6 +++---
> > framework/profile.py | 4 ++--
> > framework/programs/run.py | 30 +++++++++++++++---------------
> > framework/tests/core_tests.py | 2 +-
> > framework/tests/profile_tests.py | 8 ++++----
>
> You forgot
>
> piglit-print-commands.py
>
> > 6 files changed, 40 insertions(+), 27 deletions(-)
> >
> > diff --git a/framework/core.py b/framework/core.py
> > index 6f476d0..2005a4e 100644
> > --- a/framework/core.py
> > +++ b/framework/core.py
> > @@ -40,7 +40,7 @@ import framework.status as status
> >
> > from .threads import synchronized_self
> >
> > __all__ = ['PIGLIT_CONFIG',
> >
> > - 'Environment',
> > + 'Options',
> >
> > 'TestrunResult',
> > 'TestResult',
> > 'JSONWriter',
> >
> > @@ -326,7 +326,20 @@ class TestrunResult:
> > json.dump(raw_dict, file, indent=JSONWriter.INDENT)
> >
> > -class Environment:
> > +class Options(object):
> > + """ Contains options for a piglit run
> > +
> > + Options are as follows:
> > + concurrent -- True if concurrency is to be used
> > + execute -- False for dry run
> > + filter -- list of compiled regex which include exclusively tests that
> > match + exclude_filter -- list of compiled regex which exclude tests
> > that match + valgrind -- True if valgrind is to be used
> > + dmesg -- True if dmesg checking is desired. This forces concurrency
> > off + verbose -- verbosity level.
> > + env -- environment variables set for each test before run
> > +
> > + """
> >
> > def __init__(self, concurrent=True, execute=True,
> > include_filter=None,
> >
> > exclude_filter=None, valgrind=False, dmesg=False,
> >
> > verbose=False):
> > diff --git a/framework/exectest.py b/framework/exectest.py
> > index ad6f2ae..d7cad6e 100644
> > --- a/framework/exectest.py
> > +++ b/framework/exectest.py
> > @@ -28,7 +28,7 @@ import time
> >
> > import sys
> > import traceback
> >
> > -from .core import TestResult, Environment
> > +from .core import TestResult, Options
> >
> > __all__ = ['Test',
> >
> > @@ -49,7 +49,7 @@ else:
> > class Test(object):
> > - ENV = Environment()
> > + ENV = Options()
>
> Perhaps rename this to OPTS?
Yeah, I was just being lazy...
>
> > __slots__ = ['ENV', 'run_concurrent', 'env', 'result', 'cwd',
> > '_command',
> >
> > '_test_hook_execute_run']
> >
> > @@ -191,7 +191,7 @@ class Test(object):
> > def get_command_result(self):
> > # Set the environment for the tests. Use the default settings
> > created
> >
> > - # in the Environment constructor first, then use any user defined
> > + # in the Options constructor first, then use any user defined
> >
> > # variables, finally, use any variables set for the test in the
> > test
> > # profile
> > fullenv = self.ENV.env.copy()
> >
> > diff --git a/framework/profile.py b/framework/profile.py
> > index affd4b6..ba481a3 100644
> > --- a/framework/profile.py
> > +++ b/framework/profile.py
> >
> > @@ -121,7 +121,7 @@ class TestProfile(object):
> > runs it's own filters plus the filters in the self.filters name
> >
> > Arguments:
> > - env - a core.Environment instance
> > + env - a core.Options instance
>
> and rename all these too...
>
> Anyways, not super-required, if you don't feel like doing it, you still get
> my
>
> Reviewed-by: Ilia Mirkin <imirkin at alum.mit.edu>
>
> once you also update piglit-print-commands.py.
>
> > """
> > self._flatten_group_hierarchy()
> >
> > @@ -181,7 +181,7 @@ class TestProfile(object):
> > Finally it will print a final summary of the tests
> >
> > Arguments:
> > - env -- a core.Environment instance
> > + env -- a core.Options instance
> >
> > json_writer -- a core.JSONWriter instance
> >
> > """
> >
> > diff --git a/framework/programs/run.py b/framework/programs/run.py
> > index 0189e48..6008eb5 100644
> > --- a/framework/programs/run.py
> > +++ b/framework/programs/run.py
> >
> > @@ -129,14 +129,14 @@ def run(input_):
> > core.PIGLIT_CONFIG.read(os.path.abspath(
> >
> > os.path.join(os.path.dirname(__file__), 'piglit.conf')))
> >
> > - # Pass arguments into Environment
> > - env = core.Environment(concurrent=args.concurrency,
> > - exclude_filter=args.exclude_tests,
> > - include_filter=args.include_tests,
> > - execute=args.execute,
> > - valgrind=args.valgrind,
> > - dmesg=args.dmesg,
> > - verbose=args.verbose)
> > + # Pass arguments into Options
> > + env = core.Options(concurrent=args.concurrency,
> > + exclude_filter=args.exclude_tests,
> > + include_filter=args.include_tests,
> > + execute=args.execute,
> > + valgrind=args.valgrind,
> > + dmesg=args.dmesg,
> > + verbose=args.verbose)
> >
> > # Set the platform to pass to waffle
> >
> > if args.platform:
> > @@ -211,13 +211,13 @@ def resume(input_):
> > args = parser.parse_args(input_)
> >
> > results = core.load_results(args.results_path)
> >
> > - env = core.Environment(concurrent=results.options['concurrent'],
> > -
> > exclude_filter=results.options['exclude_filter'], -
> > include_filter=results.options['filter'], -
> > execute=results.options['execute'],
> > - valgrind=results.options['valgrind'],
> > - dmesg=results.options['dmesg'],
> > - verbose=results.options['verbose'])
> > + env = core.Options(concurrent=results.options['concurrent'],
> > + exclude_filter=results.options['exclude_filter'],
> > + include_filter=results.options['filter'],
> > + execute=results.options['execute'],
> > + valgrind=results.options['valgrind'],
> > + dmesg=results.options['dmesg'],
> > + verbose=results.options['verbose'])
> >
> > if results.options.get('platform'):
> > env.env['PIGLIT_PLATFORM'] = results.options['platform']
> >
> > diff --git a/framework/tests/core_tests.py b/framework/tests/core_tests.py
> > index 44462ce..15858b8 100644
> > --- a/framework/tests/core_tests.py
> > +++ b/framework/tests/core_tests.py
> >
> > @@ -49,7 +49,7 @@ def test_generate_initialize():
> > """
> > yieldable = check_initialize
> >
> > - for target in [core.Environment, core.TestrunResult, core.TestResult,
> > + for target in [core.Options, core.TestrunResult, core.TestResult,
> >
> > core.PiglitJSONEncoder]:
> > yieldable.description = "Test that {} initializes".format(
> >
> > target.__name__)
> >
> > diff --git a/framework/tests/profile_tests.py
> > b/framework/tests/profile_tests.py index de4730f..c861cfc 100644
> > --- a/framework/tests/profile_tests.py
> > +++ b/framework/tests/profile_tests.py
> >
> > @@ -211,7 +211,7 @@ def test_matches_filter_mar_1(data):
> > Nothing should be filtered.
> >
> > """
> >
> > - env = core.Environment()
> > + env = core.Options()
> >
> > profile_ = profile.TestProfile()
> > profile_.test_list = data
> >
> > @@ -223,7 +223,7 @@ def test_matches_filter_mar_1(data):
> > @nt.nottest
> >
> > def test_matches_filter_mar_2(data):
> > """ Tests 'not env.filter or matches_any_regex() mar is False"""
> >
> > - env = core.Environment(include_filter=['test5'])
> > + env = core.Options(include_filter=['test5'])
> >
> > profile_ = profile.TestProfile()
> > profile_.test_list = data
> >
> > @@ -237,7 +237,7 @@ def test_matches_filter_mar_2(data):
> > @nt.nottest
> >
> > def test_matches_env_exclude(data):
> > """ Tests 'not path in env.exclude_tests """
> >
> > - env = core.Environment()
> > + env = core.Options()
> >
> > env.exclude_tests.add('group3/test5')
> >
> > profile_ = profile.TestProfile()
> >
> > @@ -253,7 +253,7 @@ def test_matches_env_exclude(data):
> > @nt.nottest
> >
> > def test_matches_exclude_mar(data):
> > """ Tests 'not matches_any_regexp() """
> >
> > - env = core.Environment(exclude_filter=['test5'])
> > + env = core.Options(exclude_filter=['test5'])
> >
> > profile_ = profile.TestProfile()
> > profile_.test_list = data
> >
> > --
> > 2.0.0
> >
> > _______________________________________________
> > Piglit mailing list
> > Piglit at lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/piglit
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140622/097e626f/attachment-0001.sig>
More information about the Piglit
mailing list