aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDylan Baker <baker.dylan.c@gmail.com>2015-07-30 08:27:27 -0700
committerDylan Baker <baker.dylan.c@gmail.com>2015-08-05 13:14:30 -0700
commitde017626427a49fdde14e6938b776978dd8ff3a7 (patch)
treec0ad1801a8f7e85d1fa765ba78af7d1f1119e3dd
parent6b998da2f7a99d9c72dc0fa9ce7549eb30172f67 (diff)
downloadpiglit-de017626427a49fdde14e6938b776978dd8ff3a7.tar.gz
framework: when searching a directory ignore files ending in .old
Currently if piglit updates a result to a new version, then tries to load from the same directory the first result will be 'results.json.old', and piglit will interpret the '.old' as a compression extension, and die in a fire. With this patch when searching a folder (but not when pointing directly at a file) piglit will ignore any files ending in '.old', which will correct the problem. A unit test is also included. Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
-rw-r--r--framework/backends/__init__.py2
-rw-r--r--framework/tests/backends_tests.py17
2 files changed, 18 insertions, 1 deletions
diff --git a/framework/backends/__init__.py b/framework/backends/__init__.py
index 5ce4d6f30..b0f784fd8 100644
--- a/framework/backends/__init__.py
+++ b/framework/backends/__init__.py
@@ -145,7 +145,7 @@ def load(file_path):
return _extension(file_path)
else:
for file_ in os.listdir(file_path):
- if file_.startswith('result'):
+ if file_.startswith('result') and not file_.endswith('.old'):
return _extension(file_)
tests = os.path.join(file_path, 'tests')
diff --git a/framework/tests/backends_tests.py b/framework/tests/backends_tests.py
index f2fad1108..39e3e2d78 100644
--- a/framework/tests/backends_tests.py
+++ b/framework/tests/backends_tests.py
@@ -212,3 +212,20 @@ def test_load_trailing_dot():
"""
backends.load('foo.test_backend..gz')
+
+@nt.with_setup(_notimplemented_setup, _registry_teardown)
+@utils.test_in_tempdir
+@nt.raises(backends.BackendError)
+def test_load_old():
+ """backends.load(): Ignores files ending in '.old'
+
+ If this raises a BackendError it means it didn't find a backend to use,
+ thus it skipped the file ending in '.old'.
+
+ """
+ os.mkdir('test')
+ file_path = os.path.join('test', 'results.test_backend.old')
+ with open(file_path, 'w') as f:
+ f.write('foo')
+
+ backends.load('test')