29 lines
2.0 KiB
Python
29 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
from pathlib import Path
|
|
import importlib.util
|
|
import subprocess
|
|
import tempfile
|
|
ROOT=Path(__file__).resolve().parents[1]
|
|
spec=importlib.util.spec_from_file_location("stage",ROOT/"ops/stage_addon_text_size.py")
|
|
stage=importlib.util.module_from_spec(spec);spec.loader.exec_module(stage)
|
|
subprocess.run(["lua5.1",str(ROOT/"tests/addon_text_size_test.lua"),str(ROOT/"client_addons/OctoTextSize/OctoTextSize.lua")],check=True)
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
root=Path(directory)
|
|
for name in ("pfQuest","TWThreat","Blizzard_Test","aux-addon"):
|
|
p=root/name;p.mkdir();(p/(name+".toc")).write_text("## OptionalDeps: Existing\nmain.lua\n")
|
|
(p/"main.lua").write_text("setfenv(1, pfQuestEnv) local f=CreateFrame('Frame')\n" if name=="pfQuest" else "local f=CreateFrame('Frame')\n")
|
|
(root/"aux-addon/compat.lua").write_text("local G=_G\nfunction C.CreateFrame(...) return adopt(G.CreateFrame(...)) end\n")
|
|
untouched=(root/"Blizzard_Test/main.lua").read_bytes()
|
|
assert stage.patch(root)
|
|
assert not stage.patch(root), "staging must be idempotent"
|
|
assert (root/"Blizzard_Test/main.lua").read_bytes()==untouched
|
|
assert (root/"pfQuest/main.lua").read_text().startswith("setfenv(1, pfQuestEnv)\n"+stage.MARKER)
|
|
assert stage.MARKER not in (root/"aux-addon/main.lua").read_text()
|
|
assert "adopt((G.OctoTextSize" in (root/"aux-addon/compat.lua").read_text()
|
|
assert "Existing, OctoTextSize" in (root/"pfQuest/pfQuest.toc").read_text()
|
|
for lua in root.rglob("*.lua"):subprocess.run(["luac5.1","-p",str(lua)],check=True)
|
|
for lua in (ROOT/"client_addons").rglob("*.lua"):
|
|
if lua.parent.name=="OctoTextSize" or lua.name=="compat.lua" and lua.parent.name=="aux-addon" or lua.read_text().startswith(stage.MARKER):
|
|
subprocess.run(["luac5.1","-p",str(lua)],check=True)
|
|
print("PASS source/staging integration: private environments retained, aux factory retained, dependencies, idempotence, Blizzard excluded, Lua syntax")
|