Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependency system for Mineunit modules #38

Open
S-S-X opened this issue Oct 21, 2021 · 1 comment
Open

Dependency system for Mineunit modules #38

S-S-X opened this issue Oct 21, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@S-S-X
Copy link
Owner

S-S-X commented Oct 21, 2021

As Mineunit is kind of built from modules and those are growing pretty fast it would be good to have well defined dependencies between modules.
Currently dependencies are handled by just implicitly loading dependencies when module is included in test set.

For example server module requires few others:

mineunit/server.lua

Lines 5 to 9 in 3ab99b0

mineunit("nodetimer")
mineunit("common/chatcommands")
mineunit("game/chat")

And itemstack requires metadata:

mineunit("metadata")

It would be good to have all these in one place so that loading order could be handled better, currently there's no well defined module loading order especially if modules are included individually.

However there's some upsides with not having well defined initialization order: it enforces writing code with better fault tolerance.
Basically it is harder to make shortcuts, global variables cannot be trusted.

It would be good if dependency system wont take away those restrictions but to enforce that quality it probably requires some way to test modules while ignoring dependencies.

@S-S-X S-S-X added the enhancement New feature or request label Oct 21, 2021
@S-S-X
Copy link
Owner Author

S-S-X commented Aug 4, 2022

One example why current system is not nice, following will work fine:

require("mineunit")
mineunit("player")
mineunit("protection")
mineunit("common/after")

But this will fail with error not related to protection module in any way:

require("mineunit")
mineunit("player")
--mineunit("protection")
mineunit("common/after")

In this case actual error is missing core.register_globalstep

0 successes / 0 failures / 1 error / 0 pending : 0.00436 seconds

Error → .../mineunit/common/after.lua @ 5
suite spec/init_spec.lua
.../mineunit/common/after.lua:5: attempt to call field 'register_globalstep' (a nil value)

@S-S-X S-S-X added this to Mineunit Jan 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

1 participant