mirror of
https://github.com/horizon-rust/horizon-mods.git
synced 2026-11-07 02:56:08 -10:00
The launcher strips these launcher-only tables before horizon-mixins reads a bundle's manifest (native_mods/api.rs). The check passed them through, so a mod with a trait package (cpm, #317) failed with E_MANIFEST "unknown field api" while players' launchers apply it. Mods with an API package are applied but not compiled, as health already leaves them out. Co-authored-by: Horizon agent <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
"""python3 -m unittest discover -s scripts -p 'test_*.py'"""
|
|
import tomllib
|
|
import unittest
|
|
|
|
from native_compat import strip_launcher_tables
|
|
|
|
MANIFEST = """[mod]
|
|
id = "example"
|
|
version = "1.0.0"
|
|
|
|
[compatibility]
|
|
horizon_revision = "0123456789abcdef0123456789abcdef01234567"
|
|
|
|
# A trait-mod package.
|
|
[api]
|
|
path = "api"
|
|
|
|
[dependencies]
|
|
jei = { optional = true }
|
|
|
|
[dependencies.ae2]
|
|
optional = false
|
|
|
|
[[module]]
|
|
id = "runtime"
|
|
file = "crates/horizon-client/src/game.rs"
|
|
name = "example_mod"
|
|
source = "runtime.rs"
|
|
|
|
[[injection]]
|
|
id = "frame"
|
|
target = "horizon_client::game::native_hooks::Game<'_>::native_frame"
|
|
helper = "frame.rs"
|
|
"""
|
|
|
|
|
|
class StripLauncherTables(unittest.TestCase):
|
|
def test_removes_only_the_launcher_tables(self):
|
|
stripped = tomllib.loads(strip_launcher_tables(MANIFEST))
|
|
original = tomllib.loads(MANIFEST)
|
|
self.assertNotIn("api", stripped)
|
|
self.assertNotIn("dependencies", stripped)
|
|
for key in ("mod", "compatibility", "module", "injection"):
|
|
self.assertEqual(stripped[key], original[key])
|
|
|
|
def test_a_manifest_without_them_is_unchanged(self):
|
|
plain = MANIFEST.split("# A trait-mod package.")[0] + MANIFEST.split('optional = false\n')[1]
|
|
self.assertEqual(strip_launcher_tables(plain), plain)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|