Add compatibility notes, resource-provider and hook checks, and payload bundling script. Remove generated engine mixin stubs, engine target lists and prebuilt binaries now produced by the build. Co-Authored-By: Claude Opus 5.5 <[email protected]>
46 lines
1.8 KiB
Python
46 lines
1.8 KiB
Python
"""Run with python check/bundle_payloads_check.py."""
|
|
import importlib.util
|
|
import tempfile
|
|
import zipfile
|
|
from pathlib import Path
|
|
|
|
spec = importlib.util.spec_from_file_location('bundle_payloads', Path(__file__).resolve().parents[1] / 'scripts/bundle_payloads.py')
|
|
bundle = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(bundle)
|
|
|
|
|
|
def entries(path):
|
|
with zipfile.ZipFile(path) as jar:
|
|
return {name: jar.read(name) for name in jar.namelist()}
|
|
|
|
|
|
test_root = Path(__file__).resolve().parents[1] / 'work'
|
|
test_root.mkdir(exist_ok=True)
|
|
with tempfile.TemporaryDirectory(dir=test_root) as temporary:
|
|
directory = Path(temporary)
|
|
inputs = {}
|
|
for version in ('1.21.1', '1.21.11'):
|
|
path = directory / f'input-{version}.jar'
|
|
with zipfile.ZipFile(path, 'w') as jar:
|
|
jar.writestr('prestige-engine/minecraft-version.txt', version)
|
|
jar.writestr('imgui/ImGui.class', b'shared library')
|
|
jar.writestr('library/Different.class', version.encode())
|
|
jar.writestr('dev/zprestige/Prestige.class', b'keep game code local')
|
|
jar.writestr('fabric.mod.json', b'keep metadata local')
|
|
inputs[version] = path
|
|
output = directory / 'output'
|
|
bundle.pack(inputs, output)
|
|
common = entries(output / 'common.jar')
|
|
assert common == {'imgui/ImGui.class': b'shared library'}
|
|
for version, original in inputs.items():
|
|
variant = entries(output / f'{version}.jar')
|
|
assert not common.keys() & variant.keys()
|
|
assert common | variant == entries(original), 'Split must reconstruct every original entry exactly'
|
|
try:
|
|
bundle.pack({'1.21.2': inputs['1.21.1']}, directory / 'bad')
|
|
except ValueError:
|
|
pass
|
|
else:
|
|
raise AssertionError('Mismatched payload target accepted')
|
|
print('Bundle reconstruction and target checks passed')
|