summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2018-03-27 12:05:12 -0700
committerDylan Baker <dylan@pnwbakers.com>2018-05-01 14:30:21 -0700
commitcf601813227ca78a5e501a112ab5e5b89ae5c3c2 (patch)
tree443cdfe73bce93c14549e91d010c1d18c4b9b11c /framework
parent1fd6f243cd853892834a25613e738f877845f57d (diff)
profile: allow forcing python or xml loading
This will be used during build time to allow profiles that modify other profiles to load XML instead of rebuilding. Tested-by: Rafael Antognolli <rafael.antognolli@intel.com>
Diffstat (limited to 'framework')
-rw-r--r--framework/profile.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/framework/profile.py b/framework/profile.py
index 7b1b41be1..2395b2250 100644
--- a/framework/profile.py
+++ b/framework/profile.py
@@ -429,7 +429,7 @@ class TestProfile(object):
yield k, v
-def load_test_profile(filename):
+def load_test_profile(filename, python=None):
"""Load a python module and return it's profile attribute.
All of the python test files provide a profile attribute which is a
@@ -449,15 +449,24 @@ def load_test_profile(filename):
Arguments:
filename -- the name of a python module to get a 'profile' from
+
+ Keyword Arguments:
+ python -- If this is None (the default) XML is tried, and then a python
+ module. If True, then only python is tried, if False then only
+ XML is tried.
"""
name = os.path.splitext(os.path.basename(filename))[0]
- xml = os.path.join(ROOT_DIR, 'tests', name + '.xml')
- if os.path.exists(xml):
- return XMLProfile(xml)
+ xml = os.path.join('tests', name + '.xml')
+ if not python:
+ xml = os.path.join(ROOT_DIR, 'tests', name + '.xml')
+ if os.path.exists(xml):
+ return XMLProfile(xml)
+
+ if python is False:
+ raise exceptions.PiglitFatalError('Cannot open "tests/{}.xml"'.format(name))
try:
- mod = importlib.import_module('tests.{0}'.format(
- os.path.splitext(os.path.basename(filename))[0]))
+ mod = importlib.import_module('tests.{0}'.format(name))
except ImportError:
raise exceptions.PiglitFatalError(
'Failed to import "{}", there is either something wrong with the '