[Piglit] [PATCH 2/2] summary/html: Fix processing of Windows results.
Ilia Mirkin
imirkin at alum.mit.edu
Thu Jun 5 12:29:51 PDT 2014
On Thu, Jun 5, 2014 at 3:20 PM, <jfonseca at vmware.com> wrote:
> From: José Fonseca <jfonseca at vmware.com>
>
> - Prevent the use of reserved characters in filenames (e.g., '>' and '<'
> which are used in several cases.)
>
> - Handle mixture of backward and forward slashes gracefuly.
> ---
> framework/summary.py | 19 +++++++++++++++----
> 1 file changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/framework/summary.py b/framework/summary.py
> index d71fb53..9cb5646 100644
> --- a/framework/summary.py
> +++ b/framework/summary.py
> @@ -40,6 +40,15 @@ __all__ = [
> ]
>
>
> +def escapeFilename(key):
I believe the convention is lower_underscore, not lowerCamelCase.
(Although a few of the methods in HTMLIndex seem to disagree...)
> + """
> + Avoid reserved characters in filenames.
> + """
> + for c in '<>:"|?*':
> + key = key.replace(c, '_')
> + return key
import re
return re.sub(r'[<>:"|?*]', '_', key)
> +
> +
> class HTMLIndex(list):
> """
> Builds HTML output to be passed to the index mako template, which will be
> @@ -122,7 +131,7 @@ class HTMLIndex(list):
>
> # Split the group names and test names, then determine
> # which groups to close and which to open
> - openList = key.split('/')
> + openList = key.replace('\\', '/').split('/')
> test = openList.pop()
> openList, closeList = returnList(openList, list(currentDir))
>
> @@ -172,6 +181,8 @@ class HTMLIndex(list):
> except KeyError:
> href = key
>
> + href = escapeFilename(href)
> +
> try:
> self._testResult(each.name, href,
> summary.status[each.name][key])
> @@ -454,7 +465,8 @@ class Summary:
>
> # Then build the individual test results
> for key, value in each.tests.iteritems():
> - temp_path = path.join(destination, each.name, path.dirname(key))
> + html_path = path.join(destination, each.name, escapeFilename(key + ".html"))
> + temp_path = path.dirname(html_path)
>
> if value['result'] not in exclude:
> # os.makedirs is very annoying, it throws an OSError if
> @@ -469,8 +481,7 @@ class Summary:
> if value.get('time') is not None:
> value['time'] = datetime.timedelta(0, value['time'])
>
> - with open(path.join(destination, each.name, key + ".html"),
> - 'w') as out:
> + with open(path.join(html_path), 'w') as out:
Does path.join do anything useful here?
> out.write(testfile.render(
> testname=key,
> value=value,
> --
> 1.9.1
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
More information about the Piglit
mailing list