Files
WoW-Hybrid-gateway/tests/remember_password_test.py

19 lines
1.2 KiB
Python

from pathlib import Path
import subprocess,sys
root=Path(__file__).resolve().parents[1]
subprocess.run([sys.argv[1]],check=True)
subprocess.run(['lua5.1',str(root/'tests/remember_password_test.lua'),str(root/'compat/glue/remember_password.lua')],check=True)
sys.path.insert(0,str(root/'ops'))
from remember_password_glue import prepare
source=b'function AccountLogin_OnShow(self)\n\tAccountLogin_CheckAutoLogin();\nend\nfunction AccountLogin_Login()\n\t\tC_Login.Login(string.gsub(username, "||", "|"), AccountLogin.UI.PasswordEditBox);\nend\n'
source += b'function Extra()\n\tAccountLogin_CheckAutoLogin();\nend\n'
result=prepare(source)
assert b'function Extra()\n\tAccountLogin_CheckAutoLogin();\nend\n' in result
assert prepare(source.replace(b'\n',b'\r\n'))==result.replace(b'\n',b'\r\n')
assert prepare(result)==result # replacing the installed closure is idempotent
old=result.replace((root/'compat/glue/remember_password.lua').read_bytes(),b'return {Setup=function()end,BeforeLogin=function()return true end}\n',1)
assert prepare(old)==result # upgrade O without touching the surrounding priority gate
if len(sys.argv) > 2:
subprocess.run(["luac5.1", "-p", sys.argv[2]], check=True)