test_shaders: Add the option to generate diff instead.
Signed-off-by: Sebastián Aedo <saedo@codeweavers.com>
This commit is contained in:
parent
e9cc640334
commit
2bb051206b
@ -629,13 +629,22 @@ def regression_check_reflect(shader, json_file, args):
|
|||||||
shutil.move(json_file, reference)
|
shutil.move(json_file, reference)
|
||||||
else:
|
else:
|
||||||
print('Generated reflection json in {} does not match reference {}!'.format(json_file, reference))
|
print('Generated reflection json in {} does not match reference {}!'.format(json_file, reference))
|
||||||
with open(json_file, 'r') as f:
|
if args.diff:
|
||||||
print('')
|
diff_path = generate_diff_file(reference, glsl)
|
||||||
print('Generated:')
|
with open(diff_path, 'r') as f:
|
||||||
print('======================')
|
print('')
|
||||||
print(f.read())
|
print('Diff:')
|
||||||
print('======================')
|
print(f.read())
|
||||||
print('')
|
print('')
|
||||||
|
remove_file(diff_path)
|
||||||
|
else:
|
||||||
|
with open(json_file, 'r') as f:
|
||||||
|
print('')
|
||||||
|
print('Generated:')
|
||||||
|
print('======================')
|
||||||
|
print(f.read())
|
||||||
|
print('======================')
|
||||||
|
print('')
|
||||||
|
|
||||||
# Otherwise, fail the test. Keep the shader file around so we can inspect.
|
# Otherwise, fail the test. Keep the shader file around so we can inspect.
|
||||||
if not args.keep:
|
if not args.keep:
|
||||||
@ -649,6 +658,19 @@ def regression_check_reflect(shader, json_file, args):
|
|||||||
make_reference_dir(reference)
|
make_reference_dir(reference)
|
||||||
shutil.move(json_file, reference)
|
shutil.move(json_file, reference)
|
||||||
|
|
||||||
|
def generate_diff_file(origin, generated):
|
||||||
|
diff_destination = create_temporary()
|
||||||
|
with open(diff_destination, "w") as f:
|
||||||
|
try:
|
||||||
|
subprocess.check_call(["diff", origin, generated], stdout=f)
|
||||||
|
except subprocess.CalledProcessError as e:
|
||||||
|
# diff returns 1 when the files are different so we can safely
|
||||||
|
# ignore this case.
|
||||||
|
if e.returncode != 1:
|
||||||
|
raise e
|
||||||
|
|
||||||
|
return diff_destination
|
||||||
|
|
||||||
def regression_check(shader, glsl, args):
|
def regression_check(shader, glsl, args):
|
||||||
reference = reference_path(shader[0], shader[1], args.opt)
|
reference = reference_path(shader[0], shader[1], args.opt)
|
||||||
joined_path = os.path.join(shader[0], shader[1])
|
joined_path = os.path.join(shader[0], shader[1])
|
||||||
@ -665,13 +687,22 @@ def regression_check(shader, glsl, args):
|
|||||||
shutil.move(glsl, reference)
|
shutil.move(glsl, reference)
|
||||||
else:
|
else:
|
||||||
print('Generated source code in {} does not match reference {}!'.format(glsl, reference))
|
print('Generated source code in {} does not match reference {}!'.format(glsl, reference))
|
||||||
with open(glsl, 'r') as f:
|
if args.diff:
|
||||||
print('')
|
diff_path = generate_diff_file(reference, glsl)
|
||||||
print('Generated:')
|
with open(diff_path, 'r') as f:
|
||||||
print('======================')
|
print('')
|
||||||
print(f.read())
|
print('Diff:')
|
||||||
print('======================')
|
print(f.read())
|
||||||
print('')
|
print('')
|
||||||
|
remove_file(diff_path)
|
||||||
|
else:
|
||||||
|
with open(glsl, 'r') as f:
|
||||||
|
print('')
|
||||||
|
print('Generated:')
|
||||||
|
print('======================')
|
||||||
|
print(f.read())
|
||||||
|
print('======================')
|
||||||
|
print('')
|
||||||
|
|
||||||
# Otherwise, fail the test. Keep the shader file around so we can inspect.
|
# Otherwise, fail the test. Keep the shader file around so we can inspect.
|
||||||
if not args.keep:
|
if not args.keep:
|
||||||
@ -869,6 +900,9 @@ def main():
|
|||||||
parser.add_argument('--keep',
|
parser.add_argument('--keep',
|
||||||
action = 'store_true',
|
action = 'store_true',
|
||||||
help = 'Leave failed GLSL shaders on disk if they fail regression. Useful for debugging.')
|
help = 'Leave failed GLSL shaders on disk if they fail regression. Useful for debugging.')
|
||||||
|
parser.add_argument('--diff',
|
||||||
|
action = 'store_true',
|
||||||
|
help = 'Displays a diff instead of the generated output on failure. Useful for debugging.')
|
||||||
parser.add_argument('--malisc',
|
parser.add_argument('--malisc',
|
||||||
action = 'store_true',
|
action = 'store_true',
|
||||||
help = 'Use malisc offline compiler to determine static cycle counts before and after spirv-cross.')
|
help = 'Use malisc offline compiler to determine static cycle counts before and after spirv-cross.')
|
||||||
|
Loading…
Reference in New Issue
Block a user