"""Open the production native bowling scene without accessing player profiles.""" import hashlib import subprocess from pathlib import Path from check_hall_expansion import ROOT, OUT, prepare from check_artifacts import toolchain def main(): def profile(): return {str(p): hashlib.sha256(p.read_bytes()).digest() for p in (ROOT/'runtime').rglob('*') if p.is_file()} prepare() source = (OUT/'module.asm').read_text(encoding='cp1251') source = source.replace('end ExpansionTestStart', 'include tools/tests/bowling_play_ui.inc\nend BowlingUiStart') target = OUT/'bowling-ui' target.with_suffix('.asm').write_text(source, encoding='cp1251') ml,link = toolchain() sdk = sorted(Path('C:/Program Files (x86)/Windows Kits/10/Lib').glob('*/um/x86'))[-1] subprocess.run([str(ml),'/c','/coff','/Cp','/nologo','/I.', f'/Fo{target}.obj',f'{target}.asm'],cwd=ROOT,check=True) subprocess.run([str(link),'/nologo','/SUBSYSTEM:WINDOWS','/ENTRY:BowlingUiStart@0', f'/LIBPATH:{sdk}',f'/OUT:{target}.exe',f'{target}.obj', str(OUT/'helpers.obj'),'kernel32.lib','user32.lib','gdi32.lib', 'winmm.lib','ws2_32.lib'],cwd=ROOT,check=True) before = profile() result = subprocess.run([str(target.with_suffix('.exe'))],cwd=ROOT,timeout=900) assert result.returncode == 0,result.returncode assert profile() == before,'Interactive bowling changed the player profile' print('PASS: interactive native bowling closed without changing the player profile') if __name__ == '__main__': main()