mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-08 21:30:23 +01:00
aco/tests: improve reporting of failed code checks
Instead of just reporting the failed statements, print where they originated. This is useful for tests which have a number of similar checks. Signed-off-by: Rhys Perry <pendingchaos02@gmail.com> Reviewed-by: Timur Kristóf <timur.kristof@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10898>
This commit is contained in:
parent
9bf30c4a5c
commit
bb52484df5
1 changed files with 12 additions and 10 deletions
|
|
@ -40,10 +40,10 @@ initial_code = '''
|
|||
import re
|
||||
|
||||
def insert_code(code):
|
||||
insert_queue.append(CodeCheck(code))
|
||||
insert_queue.append(CodeCheck(code, current_position))
|
||||
|
||||
def insert_pattern(pattern):
|
||||
insert_queue.append(PatternCheck(pattern, False, '(code pattern)'))
|
||||
insert_queue.append(PatternCheck(pattern, False, current_position))
|
||||
|
||||
def vector_gpr(prefix, name, size, align):
|
||||
insert_code(f'{name} = {name}0')
|
||||
|
|
@ -80,8 +80,9 @@ def search_re(pattern):
|
|||
'''
|
||||
|
||||
class Check:
|
||||
def __init__(self, data):
|
||||
def __init__(self, data, position):
|
||||
self.data = data.rstrip()
|
||||
self.position = position
|
||||
|
||||
def run(self, state):
|
||||
pass
|
||||
|
|
@ -109,12 +110,12 @@ class CodeCheck(Check):
|
|||
state.result.log += state.g['log']
|
||||
state.g['log'] = ''
|
||||
except BaseException as e:
|
||||
state.result.log += 'code check raised exception:\n'
|
||||
state.result.log += 'code check at %s raised exception:\n' % self.position
|
||||
state.result.log += code + '\n'
|
||||
state.result.log += str(e)
|
||||
return False
|
||||
if not state.g['success']:
|
||||
state.result.log += 'code check failed:\n'
|
||||
state.result.log += 'code check at %s failed:\n' % self.position
|
||||
state.result.log += code + '\n'
|
||||
return False
|
||||
return True
|
||||
|
|
@ -338,9 +339,8 @@ def do_match(g, pattern, output, skip_lines, in_func=False):
|
|||
|
||||
class PatternCheck(Check):
|
||||
def __init__(self, data, search, position):
|
||||
Check.__init__(self, data)
|
||||
Check.__init__(self, data, position)
|
||||
self.search = search
|
||||
self.position = position
|
||||
|
||||
def run(self, state):
|
||||
pattern_stream = StringStream(self.data.rstrip(), 'pattern')
|
||||
|
|
@ -363,12 +363,13 @@ class CheckState:
|
|||
self.variant = variant
|
||||
self.checks = checks
|
||||
|
||||
self.checks.insert(0, CodeCheck(initial_code))
|
||||
self.checks.insert(0, CodeCheck(initial_code, None))
|
||||
self.insert_queue = []
|
||||
|
||||
self.g = {'success': True, 'funcs': {}, 'insert_queue': self.insert_queue,
|
||||
'variant': variant, 'log': '', 'output': StringStream(output, 'output'),
|
||||
'CodeCheck': CodeCheck, 'PatternCheck': PatternCheck}
|
||||
'CodeCheck': CodeCheck, 'PatternCheck': PatternCheck,
|
||||
'current_position': ''}
|
||||
|
||||
class TestResult:
|
||||
def __init__(self, expected):
|
||||
|
|
@ -381,6 +382,7 @@ def check_output(result, variant, checks, output):
|
|||
|
||||
while len(state.checks):
|
||||
check = state.checks.pop(0)
|
||||
state.current_position = check.position
|
||||
if not check.run(state):
|
||||
result.result = 'failed'
|
||||
return
|
||||
|
|
@ -398,7 +400,7 @@ def parse_check(variant, line, checks, pos):
|
|||
if len(checks) and isinstance(checks[-1], CodeCheck):
|
||||
checks[-1].data += '\n' + line
|
||||
else:
|
||||
checks.append(CodeCheck(line))
|
||||
checks.append(CodeCheck(line, pos))
|
||||
elif line.startswith('!'):
|
||||
checks.append(PatternCheck(line[1:], False, pos))
|
||||
elif line.startswith('>>'):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue