[Piglit] [PATCH 2/9] tests/oglconform.py: Use tempfile module instead of hard-coded filename
baker.dylan.c at gmail.com
baker.dylan.c at gmail.com
Wed Oct 21 11:06:27 PDT 2015
From: Dylan Baker <baker.dylan.c at gmail.com>
This is a nice cleanup, since it allows us to a) not have a hardcoded
dependency of /tmp existing, b) it means that the temporary file is
removed after it's used automatically, and c) it allows us to test the
_make_profile function.
I would really prefer not to refactor without tests, but refactoring
is a requirement to test this function, so this needs to land before
tests.
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
tests/oglconform.py | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/tests/oglconform.py b/tests/oglconform.py
index 37a834e..a34d433 100644
--- a/tests/oglconform.py
+++ b/tests/oglconform.py
@@ -24,6 +24,7 @@
import os
import re
import subprocess
+import tempfile
from framework import grouptools, exceptions, core
from framework.profile import TestProfile, Test
@@ -64,19 +65,19 @@ class OGLCTest(Test):
def _make_profile():
profile = TestProfile()
- testlist_file = '/tmp/oglc.tests'
- with open(os.devnull, "w") as devnull:
- subprocess.call([bin_oglconform, '-generateTestList', testlist_file],
- stdout=devnull.fileno(), stderr=devnull.fileno())
+ with tempfile.NamedTemporaryFile() as f:
+ with open(os.devnull, "w") as devnull:
+ subprocess.call([bin_oglconform, '-generateTestList', f.name],
+ stdout=devnull.fileno(), stderr=devnull.fileno())
- with open(testlist_file) as f:
- testlist = f.read().splitlines()
- for l in testlist:
+ f.seek(0)
+
+ for l in f.readlines():
try:
category, test = l.split()
- profile.test_list[grouptools.join('oglconform', category, test)] \
- = OGLCTest(category, test)
+ group = grouptools.join('oglconform', category, test)
+ profile.test_list[group] = OGLCTest(category, test)
except:
continue
--
2.6.1
More information about the Piglit
mailing list