[Piglit] [PATCH 4/4] framework: Fix the same bug for resume in the previous commit

Dylan Baker dylan at pnwbakers.com
Thu Jun 22 22:03:08 UTC 2017


The resume path duplicates the 2 lines of code, so the same fix is
required there.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/backends/json.py                |  5 +++--
 unittests/framework/backends/test_json.py | 15 +++++++--------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/framework/backends/json.py b/framework/backends/json.py
index 98689cc09..dd08bf053 100644
--- a/framework/backends/json.py
+++ b/framework/backends/json.py
@@ -290,8 +290,9 @@ def _resume(results_dir):
 
     # Load all of the test names and added them to the test list
     tests_dir = os.path.join(results_dir, 'tests')
-    file_list = sorted(os.listdir(tests_dir),
-                       key=lambda p: int(os.path.splitext(p)[0]))
+    file_list = sorted(
+        (l for l in os.listdir(tests_dir) if l.endswith('.json')),
+        key=lambda p: int(os.path.splitext(p)[0]))
 
     for file_ in file_list:
         with open(os.path.join(tests_dir, file_), 'r') as f:
diff --git a/unittests/framework/backends/test_json.py b/unittests/framework/backends/test_json.py
index 94d8fbf54..ccf445747 100644
--- a/unittests/framework/backends/test_json.py
+++ b/unittests/framework/backends/test_json.py
@@ -202,13 +202,11 @@ class TestResume(object):
         assert set(test.tests.keys()) == \
             {'group1/test1', 'group1/test2', 'group2/test3'}
 
-    @pytest.mark.xfail
-    def test_load_invalid_folder(self, tmpdir):
-        """backends.json._resume: ignores invalid results"""
-        # XXX: I'm not sure if this test is worth fixing or not, it would
-        # involve a lot of code, and for this case to actually be tripped a
-        # user would have to write a file into the tests directory that isn't a
-        # number
+    def test_load_invalid_ext(self, tmpdir):
+        """backends.json._resume: ignores invalid results extensions.
+
+        This gets triggered by an incomplete atomic write
+        """
         f = six.text_type(tmpdir)
         backend = backends.json.JSONBackend(f)
         backend.initialize(shared.INITIAL_METADATA)
@@ -218,13 +216,14 @@ class TestResume(object):
             t(results.TestResult('pass'))
         with backend.write_test("group2/test3") as t:
             t(results.TestResult('fail'))
-        with open(os.path.join(f, 'tests', 'x.json'), 'w') as w:
+        with open(os.path.join(f, 'tests', '3.json.tmp'), 'w') as w:
             w.write('foo')
         test = backends.json._resume(f)
 
         assert set(test.tests.keys()) == \
             {'group1/test1', 'group1/test2', 'group2/test3'}
 
+
     def test_load_incomplete(self, tmpdir):
         """backends.json._resume: loads incomplete results.
 
-- 
2.13.1



More information about the Piglit mailing list