[Piglit] [PATCH 2/3] generated_tests: store templates in .cache on linux

Dylan Baker baker.dylan.c at gmail.com
Mon Sep 28 18:05:18 PDT 2015


Like the html summary changes this means that templates survive across
reboots.
---
 generated_tests/templates/__init__.py | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/generated_tests/templates/__init__.py b/generated_tests/templates/__init__.py
index f974825..d4d5d39 100644
--- a/generated_tests/templates/__init__.py
+++ b/generated_tests/templates/__init__.py
@@ -31,10 +31,20 @@ from mako.lookup import TemplateLookup
 
 
 # Based on a similar setup in framework/summary
-MAKO_TEMP_DIR = os.path.join(tempfile.gettempdir(),
-                             'piglit-{0}'.format(getpass.getuser()),
-                             'version-{0}'.format(sys.version.split()[0]),
-                             'generators', 'templates')
+if sys.platform.startswith('linux'):
+    _cache = os.path.expandvars('$XDG_CACHE_HOME') 
+    if _cache == '$XDG_CACHE_HOME':
+        _cache = os.path.expandvars('$HOME/.cache')
+    MAKO_TEMP_DIR = os.path.join(
+        _cache,
+        'piglit',
+        'version-{}'.format(sys.version.split()[0]),
+        'generators')
+else:
+    MAKO_TEMP_DIR = os.path.join(tempfile.gettempdir(),
+                                 'piglit-{0}'.format(getpass.getuser()),
+                                 'version-{0}'.format(sys.version.split()[0]),
+                                 'generators')
 
 TEMPLATE_DIR = os.path.abspath(os.path.dirname(__file__))
 
-- 
2.5.3



More information about the Piglit mailing list