glcpp: Handle bison-3.6 error message changes

In bison's commit 72c9fa4510eb (skeletons: use "end of file" instead of
"$end") in bison-3.6, '$end' was changed to 'end of file' in error
messages. Since our glcpp test cases contain the expected output text,
they rely on the particular messages printed by bison. The test case
084-unbalanced-parentheses fails when Mesa is built with bison-3.6 due
to this change.

To allow the test to pass on all supported versions of bison, we:

   1. Change '$end' -> 'end of file' in the .expected file, and
   2. Normalize the error generated by the test case with the same
      replacement

Cc: mesa-stable
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3181
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7659>
This commit is contained in:
Matt Turner 2020-11-17 14:58:24 -05:00 committed by Marge Bot
parent 2be8cebd0b
commit df29d0a111
2 changed files with 5 additions and 1 deletions

View File

@ -1,2 +1,2 @@
0:2(8): preprocessor error: syntax error, unexpected $end
0:2(8): preprocessor error: syntax error, unexpected end of file

View File

@ -83,6 +83,10 @@ def test_output(glcpp, filename, expfile, nl_format='\n'):
with open(expfile, 'r') as f:
expected = f.read()
# Bison 3.6 changed '$end' to 'end of file' in its error messages
# See: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3181
actual = actual.replace('$end', 'end of file')
if actual == expected:
return (True, [])
return (False, difflib.unified_diff(actual.splitlines(), expected.splitlines()))