The problem with the way global params work is that they surprise the user, they are applied at object initialization time. So the following code doesn't do what one expects: a = GleanTest("basic") GleanTest.globalParams = ['--quick'] b = GleanTest("basic") assert a.command == b.command
This would create an assertion failure with the current code, since global params are applied at instance initialization. Since these params are supposed to global one would expect them to be applied to all instances, regardless of when the instance was created and the class variable set. This patch achieves that by converting Test to a new-type class, allowing getters and setters to be created. With this change GleanTests don't add the globalParams to their command attribute, instead their getter returns command + self.globalParams. Signed-off-by: Dylan Baker <baker.dyla...@gmail.com> --- framework/core.py | 2 +- framework/exectest.py | 17 +++++++++++++---- framework/gleantest.py | 7 +++++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/framework/core.py b/framework/core.py index 7231938..c74d04d 100644 --- a/framework/core.py +++ b/framework/core.py @@ -451,7 +451,7 @@ class Environment: return result -class Test: +class Test(object): def __init__(self, runConcurrent=False): ''' 'runConcurrent' controls whether this test will diff --git a/framework/exectest.py b/framework/exectest.py index 7b1c058..15dd966 100644 --- a/framework/exectest.py +++ b/framework/exectest.py @@ -71,15 +71,24 @@ class ExecTest(Test): def __init__(self, command): Test.__init__(self) self.command = command - self.split_command = os.path.split(self.command[0])[1] + self.split_command = os.path.split(self._command[0])[1] self.env = {} self.timeout = None - if isinstance(self.command, basestring): - self.command = shlex.split(str(self.command)) self.skip_test = self.check_for_skip_scenario(command) + @property + def command(self): + return self._command + + @command.setter + def command(self, value): + if isinstance(value, basestring): + self._command = shlex.split(str(value)) + return + self._command = value + def interpretResult(self, out, returncode, results, dmesg): raise NotImplementedError return out @@ -270,7 +279,7 @@ class PlainExecTest(ExecTest): def __init__(self, command): ExecTest.__init__(self, command) # Prepend testBinDir to the path. - self.command[0] = os.path.join(testBinDir, self.command[0]) + self._command[0] = os.path.join(testBinDir, self._command[0]) def interpretResult(self, out, returncode, results, dmesg): outlines = out.split('\n') diff --git a/framework/gleantest.py b/framework/gleantest.py index 88432e0..d115c03 100644 --- a/framework/gleantest.py +++ b/framework/gleantest.py @@ -35,10 +35,13 @@ class GleanTest(ExecTest): def __init__(self, name): ExecTest.__init__(self, [glean_executable, - "-o", "-v", "-v", "-v", "-t", - "+"+name] + GleanTest.globalParams) + "-o", "-v", "-v", "-v", "-t", "+" + name]) self.name = name + @ExecTest.command.getter + def command(self): + return self._command + self.globalParams + def interpretResult(self, out, returncode, results, dmesg): if "{'result': 'skip'}" in out: results['result'] = 'skip' -- 1.8.5.2 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit