render: add test for double switchable lights

https://github.com/w23/xash3d-fwgs/issues/679
This commit is contained in:
Ivan Avdeev
2023-12-04 13:50:54 -05:00
parent d62e8b0a3a
commit 7c6fa9627d
26 changed files with 83 additions and 4 deletions

View File

@@ -39,7 +39,7 @@ def test_list(arg: str) -> [str]:
for item in items:
r = re.compile(item)
for save in saves:
if r.match(save):
if r.search(save):
tests.append(save)
if not tests:
raise argparse.ArgumentTypeError(f'No tests match {item}. Available tests are: {saves}')
@@ -52,7 +52,7 @@ parser.add_argument('--tests', '-t', type=test_list, default=saves, help='Run on
# TODO how to check that the dir is valid? presence of xash3d executable and valve dir?
parser.add_argument('--xash-dir', '-x', type=str, default=os.getcwd(), help='Path to xash3d-fwgs installation directory')
# TODO parse commands in type=.. function
# TODO parse commands in type=.. function
parser.add_argument('command', type=str, default=None, help='Action to perform')
args = parser.parse_args()
@@ -96,6 +96,7 @@ def compile():
def copy_assets():
print('Copying assets')
shutil.copy2(src=f'{ROOT}/vulkan_debug.wad', dst=f'{args.xash_dir}/valve/')
shutil.copytree(src=f'{ROOT}/maps', dst=f'{args.xash_dir}/valve/maps/', dirs_exist_ok=True)
shutil.copytree(src=f'{ROOT}/save', dst=f'{args.xash_dir}/valve/save/', dirs_exist_ok=True)
with open(f'{args.xash_dir}/rendertest.script', 'w') as script:
@@ -134,6 +135,7 @@ def compare_one(test: str, channel: str, image_base: str, image_gold: str, image
return ret
def compare():
mkdir_p(WORKDIR)
screenshot_base = f'{args.xash_dir}/valve/rendertest'
diffs = []
with concurrent.futures.ThreadPoolExecutor() as executor:
@@ -150,7 +152,7 @@ def compare():
executor.submit(subprocess.run, ['convert',
'(', image_gold, '-bordercolor', 'gold', '-border', '2x2', '-gravity', 'SouthWest', '-font', 'Impact', '-pointsize', '24', '-fill', 'gold', '-stroke', 'black', '-annotate', '0', 'GOLD', ')',
'(', image_test, '-bordercolor', 'white', '-border', '2x2', '-fill', 'white', '-annotate', '0', 'TEST', ')',
'-loop', '0', '-set', 'delay', '25', image_flip], check=True)
'-loop', '0', '-set', 'delay', '100', image_flip], check=True)
results = [diff.result() for diff in diffs]
# json.dump(results, open(f'{WORKDIR}/data.json', 'w'))
@@ -181,7 +183,6 @@ def command_run():
copy_assets()
render()
compare()
#report()
def command_render():
compile()