[Piglit] [PATCH 6/7] framework: change group separator from '/' to '@'

Dylan Baker baker.dylan.c at gmail.com
Thu Mar 12 15:42:09 PDT 2015


While / is convenient, since python provides a convenient posixpath
module for working with paths, which was to our advantage too. The
problem of course is that for posix users os.path.join and
grouptools.join are equivalent, so they happily mix the two. This
doesn't work out so well for windows users though, for whom os.path.join
and grouptools.join are not equivalent.

This patch replaces the use of / with @, a character that no os uses for
paths. This will hopefully put an end to the accidental mixing, or at
least force people to use grouptools.from_path.

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 framework/backends/json.py                         |  2 +-
 framework/grouptools.py                            |  2 +-
 framework/results.py                               | 14 ++++++++
 framework/tests/results_v3_tests.py                | 11 ------
 .../{results_v3_tests.py => results_v4_tests.py}   | 42 +++++++---------------
 5 files changed, 29 insertions(+), 42 deletions(-)
 copy framework/tests/{results_v3_tests.py => results_v4_tests.py} (69%)

diff --git a/framework/backends/json.py b/framework/backends/json.py
index d14eeb2..347d3d7 100644
--- a/framework/backends/json.py
+++ b/framework/backends/json.py
@@ -40,7 +40,7 @@ __all__ = [
 
 
 # The current version of the JSON results
-CURRENT_JSON_VERSION = 4
+CURRENT_JSON_VERSION = 5
 
 
 def piglit_encoder(obj):
diff --git a/framework/grouptools.py b/framework/grouptools.py
index 6224b99..abe52cf 100644
--- a/framework/grouptools.py
+++ b/framework/grouptools.py
@@ -41,7 +41,7 @@ __all__ = [
     'testname',
 ]
 
-SEPERATOR = '/'
+SEPERATOR = '@'
 
 
 def _normalize(group):
diff --git a/framework/results.py b/framework/results.py
index 5807be4..f44098c 100644
--- a/framework/results.py
+++ b/framework/results.py
@@ -244,6 +244,7 @@ def update_results(results, filepath):
             1: _update_one_to_two,
             2: _update_two_to_three,
             3: _update_three_to_four,
+            4: _update_four_to_five,
         }
 
         while results.results_version < CURRENT_JSON_VERSION:
@@ -462,3 +463,16 @@ def _update_three_to_four(results):
     results.results_version = 4
 
     return results
+
+
+def _update_four_to_five(results):
+    """Updates json results from version 4 to version 5."""
+    new_tests = {}
+
+    for name, test in results.tests.iteritems():
+        new_tests[name.replace('/', '@')] = test
+
+    results.tests = new_tests
+    results.results_version = 5
+
+    return results
diff --git a/framework/tests/results_v3_tests.py b/framework/tests/results_v3_tests.py
index c04d0c6..d90d110 100644
--- a/framework/tests/results_v3_tests.py
+++ b/framework/tests/results_v3_tests.py
@@ -123,14 +123,3 @@ def test_missing():
     del data['tests']['spec/arb_draw_instanced/instance-array-dereference']
 
     utils.fail_if(make_result, [data], KeyError)
-
-
-def test_load_results():
-    """Version 3: load_results properly updates."""
-    with utils.tempdir() as d:
-        tempfile = os.path.join(d, 'results.json')
-        with open(tempfile, 'w') as f:
-            json.dump(DATA, f)
-        with open(tempfile, 'r') as f:
-            result = results.load_results(tempfile)
-            nt.assert_equal(result.results_version, 4)
diff --git a/framework/tests/results_v3_tests.py b/framework/tests/results_v4_tests.py
similarity index 69%
copy from framework/tests/results_v3_tests.py
copy to framework/tests/results_v4_tests.py
index c04d0c6..43a3bf8 100644
--- a/framework/tests/results_v3_tests.py
+++ b/framework/tests/results_v4_tests.py
@@ -18,12 +18,11 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-"""Tests for version 3 to version 4."""
+"""Tests for version 4 to version 5."""
 
 from __future__ import print_function, absolute_import, division
 
 import os
-import copy
 try:
     import simplejson as json
 except ImportError:
@@ -46,7 +45,7 @@ TEST_DATA = {
 }
 
 DATA = {
-    "results_version": 3,
+    "results_version": 4,
     "name": "test",
     "options": {
         "profile": ['quick'],
@@ -68,12 +67,8 @@ DATA = {
         }
     },
     "tests": {
-        "spec/arb_texture_rg/fs-shadow2d-red-01": TEST_DATA,
-        "spec/arb_texture_rg/fs-shadow2d-red-02": TEST_DATA,
-        "spec/arb_texture_rg/fs-shadow2d-red-03": TEST_DATA,
-        "spec/arb_draw_instanced/draw-non-instanced": TEST_DATA,
-        "spec/arb_draw_instanced/instance-array-dereference": TEST_DATA,
         "glslparsertest/foo": TEST_DATA,
+        "a/test/group/of/great/length": TEST_DATA,
     }
 }
 
@@ -83,54 +78,43 @@ def make_result(data):
     with utils.with_tempfile(json.dumps(data)) as t:
         with open(t, 'r') as f:
             # pylint: disable=protected-access
-            return results._update_three_to_four(results.TestrunResult.load(f))
+            return results._update_four_to_five(results.TestrunResult.load(f))
 
 
-class TestV4(object):
+class TestV5(object):
     """Generate tests for each update."""
     @classmethod
     def setup_class(cls):
-        """Class setup. Create a TestrunResult with v3 data."""
+        """Class setup. Create a TestrunResult with v4 data."""
         cls.old = DATA['tests'].keys()
         cls.new = [
-            "spec/arb_texture_rg/execution/fs-shadow2d-red-01",
-            "spec/arb_texture_rg/execution/fs-shadow2d-red-02",
-            "spec/arb_texture_rg/execution/fs-shadow2d-red-03",
-            "spec/arb_draw_instanced/execution/draw-non-instanced",
-            "spec/arb_draw_instanced/execution/instance-array-dereference",
+            "glslparsertest at foo",
+            "a at test@group at of@great at length",
         ]
         cls.result = make_result(DATA)
 
     def test_old_removed(self):
-        """Version 3: All old test names are removed."""
+        """Version 4: All old test names are removed."""
         for old in self.old:
             nt.assert_not_in(old, self.result.tests)
 
     def test_new_added(self):
-        """Version 3: All new test names are added."""
+        """Version 4: All new test names are added."""
         for new in self.new:
             nt.assert_in(new, self.result.tests)
 
     def test_new_has_data(self):
-        """Version 3: All new tests have expected data."""
+        """Version 4: All new tests have expected data."""
         for new in self.new:
             nt.assert_dict_equal(self.result.tests[new], TEST_DATA)
 
 
-def test_missing():
-    """Version 3: updates successfully when tests to rename are not present."""
-    data = copy.copy(DATA)
-    del data['tests']['spec/arb_draw_instanced/instance-array-dereference']
-
-    utils.fail_if(make_result, [data], KeyError)
-
-
 def test_load_results():
-    """Version 3: load_results properly updates."""
+    """Version 4: load_results properly updates."""
     with utils.tempdir() as d:
         tempfile = os.path.join(d, 'results.json')
         with open(tempfile, 'w') as f:
             json.dump(DATA, f)
         with open(tempfile, 'r') as f:
             result = results.load_results(tempfile)
-            nt.assert_equal(result.results_version, 4)
+            nt.assert_equal(result.results_version, 5)
-- 
2.3.1



More information about the Piglit mailing list