[Piglit] [PATCH] summary.py: Replace path separators in testrun names
Emil Velikov
emil.l.velikov at gmail.com
Thu Sep 4 14:49:10 PDT 2014
On 04/09/14 21:54, Dylan Baker wrote:
> This solves the bug of running piglit run -n 'wip/foo' which causes a
> number of issues in the html summary generation.
>
>From a quick look it seems that it might help with a funny issue that I'm seeing:
Whenever piglit is ran on Windows the testname uses \\ as path separator (in
some cases / is also used). When trying to generate summary under Linux, the
script ends up generating a ton of spec\extenstion_name\test files, rather
than structuring everything as normal.
Am I imagining or this will bring all the segfaults in bash to an end ?
Thanks
Emil
> CC: Jason Ekstrand <jason at jlekstrand.net>
> Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
> ---
> framework/summary.py | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/framework/summary.py b/framework/summary.py
> index d1b737b..debd6a7 100644
> --- a/framework/summary.py
> +++ b/framework/summary.py
> @@ -47,6 +47,11 @@ def escape_filename(key):
> return re.sub(r'[<>:"|?*#]', '_', key)
>
>
> +def escape_pathname(key):
> + """ Remove / and \\ from names """
> + return re.sub(r'[/\\]', '_', key)
> +
> +
> def normalize_href(href):
> """Force backward slashes in URLs."""
> return href.replace('\\', '/')
> @@ -113,7 +118,7 @@ class HTMLIndex(list):
> self._newRow()
> self.append({'type': 'other', 'text': '<td />'})
> for each in summary.results:
> - href = posixpath.join(each.name, "index.html")
> + href = posixpath.join(escape_pathname(each.name), "index.html")
> href = normalize_href(href)
> self.append({'type': 'other',
> 'text': '<td class="head"><b>%(name)s</b><br />'
> @@ -454,7 +459,8 @@ class Summary:
>
> # Iterate across the tests creating the various test specific files
> for each in self.results:
> - os.mkdir(path.join(destination, each.name))
> + name = escape_pathname(each.name)
> + os.mkdir(path.join(destination, name))
>
> if each.time_elapsed is not None:
> time = datetime.timedelta(0, each.time_elapsed)
> @@ -463,7 +469,7 @@ class Summary:
>
> self.__find_totals(each)
>
> - with open(path.join(destination, each.name, "index.html"), 'w') as out:
> + with open(path.join(destination, name, "index.html"), 'w') as out:
> out.write(testindex.render(name=each.name,
> totals=self.totals,
> time=time,
> @@ -474,7 +480,7 @@ class Summary:
>
> # Then build the individual test results
> for key, value in each.tests.iteritems():
> - html_path = path.join(destination, each.name, escape_filename(key + ".html"))
> + html_path = path.join(destination, name, escape_filename(key + ".html"))
> temp_path = path.dirname(html_path)
>
> if value['result'] not in exclude:
>
More information about the Piglit
mailing list