[Piglit] [patch v3 07/15] glsl_parser_test.py: Use a regex for finding entries
Anuj Phogat
anuj.phogat at gmail.com
Tue Aug 19 15:22:02 PDT 2014
This patch causes no value assigned to 'require_extensions' field
in *.vert and *.frag files in spec/glsl-4.00/compiler/built-in-functions,
which results in an error while using piglit-run.py.
On Mon, Jul 28, 2014 at 5:34 PM, Dylan Baker <baker.dylan.c at gmail.com> wrote:
> This replaces string searching with a single regex statement and the use
> of a match object to find and write key value pairs into the StringIO
> that is ultimately read into the config file.
>
> Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
> ---
> framework/glsl_parser_test.py | 26 +++++++++++---------------
> 1 file changed, 11 insertions(+), 15 deletions(-)
>
> diff --git a/framework/glsl_parser_test.py b/framework/glsl_parser_test.py
> index 78d4ca8..909f052 100644
> --- a/framework/glsl_parser_test.py
> +++ b/framework/glsl_parser_test.py
> @@ -142,20 +142,20 @@ class GLSLParserTest(PiglitTest):
> # This allows us to run the loop until we find the header, stop and
> # then run again looking for the config sections.
> # This reduces the need for if statements substantially
> - lines = (l for l in testfile)
> + lines = (l.strip() for l in testfile)
>
> - is_header = re.compile(r'\s*(//|/\*|\*)\s*\[config\]')
> + is_header = re.compile(r'(//|/\*|\*)\s*\[config\]')
> for line in lines:
> if is_header.match(line):
> break
> else:
> raise GLSLParserException("No [config] section found!")
>
> - is_header = re.compile(r'\s*(//|/\*|\*)\s*\[end config\]')
> - for line in lines:
> - # Remove all leading whitespace
> - line = line.strip()
> + is_header = re.compile(r'(//|/\*|\*)\s*\[end config\]')
> + is_metadata = re.compile(
> + r'(//|/\*|\*)\s*(?P<key>[a-z_]*)\:\s(?P<value>[A-Za-z0-9._ ]*)')
>
> + for line in lines:
> # If strip renendered '' that means we had a blank newline,
> # just go on
> if line in ['', '//']:
> @@ -163,15 +163,11 @@ class GLSLParserTest(PiglitTest):
> # If we get to the end of the config break
> elif is_header.match(line):
> break
> - # If the starting character is a two character comment
> - # remove that and any newly revealed whitespace, then write
> - # it into the StringIO
> - elif line[:2] in ['//', '/*', '*/']:
> - text_io.write(line[2:].lstrip() + '\n')
> - # If we have just * then we're in the middle of a C style
> - # comment, do like above
> - elif line[:1] == '*':
> - text_io.write(line[1:].lstrip() + '\n')
> +
> + match = is_metadata.match(line)
> + if match:
> + # Match 1 will be the comment, so skip that.
> + text_io.write('{0}: {1}\n'.format(*match.group(2, 3)))
> else:
> raise GLSLParserException(
> "The config section is malformed."
> --
> 2.0.2
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
More information about the Piglit
mailing list