diff options
author | Dylan Baker <dylan@pnwbakers.com> | 2016-10-13 14:04:18 -0700 |
---|---|---|
committer | Dylan Baker <dylan@pnwbakers.com> | 2016-11-10 10:49:09 -0800 |
commit | 0a1cd0013f6726669d9b73482658fd454d94536c (patch) | |
tree | e5f78454126574088c046c13617743e8cb1cc226 /framework | |
parent | 2385a07cf4e0de347bb7dacb8749aea7023387e8 (diff) |
framework/profile: add a copy method to profile
This will allow a profile to be copied and "subclassed" without
affecting the original profile. This will allow a long-standing bug that
made it impossible to run two subclasses of all.py (say shader.py and
glslparser.py) at the same time, since they would both try to modify the
all.py profile in incompatible ways.
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/profile.py | 16 | ||||
-rw-r--r-- | framework/programs/print_commands.py | 2 |
2 files changed, 17 insertions, 1 deletions
diff --git a/framework/profile.py b/framework/profile.py index 4d111bfe4..a64855ed1 100644 --- a/framework/profile.py +++ b/framework/profile.py @@ -31,6 +31,7 @@ from __future__ import ( ) import collections import contextlib +import copy import importlib import itertools import multiprocessing @@ -398,6 +399,21 @@ class TestProfile(object): def teardown(self): """Method to od post-run teardown.""" + def copy(self): + """Create a copy of the TestProfile. + + This method creates a copy with references to the original instance + (using copy.copy), except for the test_list attribute, which is copied + using copy.deepcopy, which is necessary to ensure that filter_tests + only affects the right instance. This allows profiles to be + "subclassed" by other profiles, without modifying the original. + """ + new = copy.copy(self) + new.test_list = copy.deepcopy(self.test_list) + new.forced_test_list = copy.copy(self.forced_test_list) + new.filters = copy.copy(self.filters) + return new + def load_test_profile(filename): """Load a python module and return it's profile attribute. diff --git a/framework/programs/print_commands.py b/framework/programs/print_commands.py index 033ca870b..6e68eb56d 100644 --- a/framework/programs/print_commands.py +++ b/framework/programs/print_commands.py @@ -95,7 +95,7 @@ def main(input_): profile_ = profile.load_test_profile(args.testProfile) - profile_._prepare_test_list() + profile_.prepare_test_list() for name, test in six.iteritems(profile_.test_list): assert isinstance(test, Test) print(args.format_string.format( |