From: Dylan Baker <[email protected]> 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 <[email protected]> --- 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.2 _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
