42 lines
1.7 KiB
Python
42 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
import pathlib
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
root = pathlib.Path(__file__).resolve().parents[1]
|
|
import tempfile
|
|
fixture_directory = tempfile.TemporaryDirectory()
|
|
wire = pathlib.Path(fixture_directory.name) / "start-rolls.bin"
|
|
result = subprocess.run([sys.argv[1], "--emit-start-rolls", str(wire)])
|
|
if result.returncode:
|
|
sys.exit(result.returncode)
|
|
lua = shutil.which('lua5.1')
|
|
if not lua:
|
|
raise SystemExit('lua5.1 is required for the native loot cache regression')
|
|
subprocess.run([lua, str(root / 'tests/native_loot_roll_cache_test.lua'),
|
|
str(root / 'ops/native_loot_roll_cache.lua')], check=True)
|
|
|
|
# Check the complete pinned native child, including the appended native scope.
|
|
sys.path.insert(0, str(root / 'ops'))
|
|
from native_loot_roll_cache import adapt
|
|
import tempfile
|
|
original = (root / 'tests/fixtures/native_group_loot_frame.lua').read_bytes()
|
|
helper = (root / 'ops/native_loot_roll_cache.lua').read_bytes()
|
|
prepared = adapt(original, helper)
|
|
assert prepared.startswith(original)
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
path = pathlib.Path(directory) / 'GroupLootFrame.lua'; path.write_bytes(prepared)
|
|
subprocess.run([shutil.which('luac5.1'), '-p', str(path)], check=True)
|
|
try:
|
|
adapt(original + b' ', helper)
|
|
except ValueError:
|
|
pass
|
|
else:
|
|
raise AssertionError('Changed native preimage was accepted')
|
|
assert 'NativeLootRollCache.lua' not in (root / 'client_addons/WoWHybridUI/WoWHybridUI.toc').read_text()
|
|
|
|
subprocess.run([lua, str(root / 'tests/native_loot_roll_wire_test.lua'), str(wire),
|
|
str(root / 'tests/fixtures/native_group_loot_frame.lua'),
|
|
str(root / 'ops/native_loot_roll_cache.lua')], check=True)
|
|
fixture_directory.cleanup()
|