[Piglit] [PATCH 17/20] framework: Simplify flow control in ExecTest.run().
Jon Severinsson
jon at severinsson.net
Wed Apr 17 09:14:56 PDT 2013
Both checks for skipping a test can be combined, and doing something
at most N times are best done with a for loop.
---
framework/exectest.py | 46 ++++++++++++++++------------------------------
1 fil ändrad, 16 tillägg(+), 30 borttagningar(-)
diff --git a/framework/exectest.py b/framework/exectest.py
index c30726c..55a0753 100644
--- a/framework/exectest.py
+++ b/framework/exectest.py
@@ -81,39 +81,30 @@ class ExecTest(Test):
for e in self.env:
fullenv[e] = str(self.env[e])
- if self.command is not None:
+ if self.skip_test or self.command is None:
+ results = TestResult()
+ results['result'] = 'skip'
+ if self.command is not None:
+ results['returncode'] = None
+ results['command'] = ' '.join(self.command)
+ else:
command = self.command
if valgrind:
command[:0] = ['valgrind', '--quiet', '--error-exitcode=1', '--tool=memcheck']
- i = 0
- while True:
- if self.skip_test:
- out = "PIGLIT: {'result': 'skip'}\n"
- err = ""
- returncode = None
- else:
- (out, err, returncode) = \
- self.get_command_result(command, fullenv)
-
- # https://bugzilla.gnome.org/show_bug.cgi?id=680214 is
- # affecting many developers. If we catch it
- # happening, try just re-running the test.
- if out.find("Got spurious window resize") >= 0:
- i = i + 1
- if i >= 5:
- break
- else:
+ # https://bugzilla.gnome.org/show_bug.cgi?id=680214 is
+ # affecting many developers. If we catch it
+ # happening, try just re-running the test.
+ for i in range(5):
+ (out, err, returncode) = \
+ self.get_command_result(command, fullenv)
+ if out.find("Got spurious window resize") < 0:
break
results = TestResult()
-
- if self.skip_test:
- results['result'] = 'skip'
- else:
- results['result'] = 'fail'
- out = self.interpretResult(out, returncode, results)
+ results['result'] = 'fail'
+ out = self.interpretResult(out, returncode, results)
if returncode is None:
pass
@@ -147,11 +138,6 @@ class ExecTest(Test):
self.handleErr(results, err)
- else:
- results = TestResult()
- if 'result' not in results:
- results['result'] = 'skip'
-
return results
def check_for_skip_scenario(self, command):
--
1.7.10.4
More information about the Piglit
mailing list