<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Aug 30, 2014 at 4:20 PM, Dylan Baker <span dir="ltr"><<a href="mailto:baker.dylan.c@gmail.com" target="_blank">baker.dylan.c@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This causes problems in the html summary generator, since os.mkdir<br>
doesn't understand that it's a string not a full path (and the<br>
underlying file system probably can't understand that either). Instead<br>
of raising an error we silently replace any illegal characters with an<br>
underscore.<br>
<br>
Signed-off-by: Dylan Baker <<a href="mailto:dylanx.c.baker@intel.com">dylanx.c.baker@intel.com</a>><br>
---<br>
 framework/results.py             | 21 ++++++++++++++++++++-<br>
 framework/tests/results_tests.py | 16 ++++++++++++++++<br>
 2 files changed, 36 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/framework/results.py b/framework/results.py<br>
index efc7029..c89b39c 100644<br>
--- a/framework/results.py<br>
+++ b/framework/results.py<br>
@@ -305,7 +305,7 @@ class TestrunResult(object):<br>
                                 'lspci',<br>
                                 'results_version',<br>
                                 'time_elapsed']<br>
-        <a href="http://self.name" target="_blank">self.name</a> = None<br>
+        self.__name = None<br>
         self.uname = None<br>
         self.options = None<br>
         self.glxinfo = None<br>
@@ -406,6 +406,25 @@ class TestrunResult(object):<br>
                            if k in self.serialized_keys),<br>
                       f, default=_piglit_encoder, indent=JSONWriter.INDENT)<br>
<br>
+    @property<br>
+    def name(self):<br>
+        return self.__name<br>
+<br>
+    @name.setter<br>
+    def name(self, name):<br>
+        """ Set the name of the test run<br>
+<br>
+        We don't allow path seperators in the name, they are silently replaced<br>
+        with underscores.<br>
+<br>
+        """<br>
+        replace = ['/', '\\']<br>
+<br>
+        for r in replace:<br>
+            name = name.replace(r, '_')<br>
+<br>
+        self.__name = name<br>
+<br></blockquote><div><br></div><div>Personally, I'd rather we mangle things when we turn them into file names rather than mangling the original.  This way the original string still shows up in table headers etc.  That said, this also accomplishes the objective of not crashing in stupid places.<br>
</div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
 def load_results(filename):<br>
     """ Loader function for TestrunResult class<br>
diff --git a/framework/tests/results_tests.py b/framework/tests/results_tests.py<br>
index 54661cc..02438cf 100644<br>
--- a/framework/tests/results_tests.py<br>
+++ b/framework/tests/results_tests.py<br>
@@ -159,3 +159,19 @@ def test_update_results_old():<br>
         res = results.update_results(base, <a href="http://f.name" target="_blank">f.name</a>)<br>
<br>
     nt.assert_equal(res.results_version, results.CURRENT_JSON_VERSION)<br>
+<br>
+<br>
+@utils.nose_generator<br>
+def test_testrunresult_set_name():<br>
+    """ Generate tests for the name setter """<br>
+    emsg = '"{}" should have been replaced but was not'<br>
+<br>
+    def test(value, expected, message):<br>
+        """ The actual test """<br>
+        t = results.TestrunResult()<br>
+        <a href="http://t.name" target="_blank">t.name</a> = value<br>
+        nt.assert_equal(<a href="http://t.name" target="_blank">t.name</a>, expected, msg=message)<br>
+<br>
+    for x in ['/', '\\']:<br>
+        test.description = 'TestrunResult.name replaces "{}" with "_"'.format(x)<br>
+        yield test, 'a{}name'.format(x), 'a_name', emsg.format(x)<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.1.0<br>
<br>
_______________________________________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/piglit" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</font></span></blockquote></div><br></div></div>