[Piglit] [patch v3 07/15] glsl_parser_test.py: Use a regex for finding entries
Dylan Baker
baker.dylan.c at gmail.com
Thu Aug 21 17:10:23 PDT 2014
On Thursday, August 21, 2014 05:04:21 PM Anuj Phogat wrote:
> On Tue, Aug 19, 2014 at 8:24 PM, Dylan Baker <baker.dylan.c at gmail.com> wrote:
> > On Tuesday, August 19, 2014 03:22:02 PM Anuj Phogat wrote:
> >> 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.
> >
> > I can't replicate that problem.
> >
> Neither me with a fresh piglit clone. I couldn't figure out but something was
> wrong with piglit on my system. Sorry for the trouble.
No problem. I've added a todo to my list to make that error message
better.
>
> > If the generator is producing an empty requirement field we should fix
> > the generator to not do that.
> >
> >>
> >> 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140821/6ed462b6/attachment.sig>
More information about the Piglit
mailing list