-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
test: Move ModuleTestingEnvironment to engine-tests #5010
Conversation
…gine.integrationenvironment for #4545 and Terasology/ModuleTestingEnvironment#39 from ModuleTestingEnvironment commit adf9b6df0407a62c15092a82960d8711e28bb7b7
The BugBug: The world generators in But only under MTE. There is another test that shows it as The CausePart I: The Engine ModuleWhen we were straightening out the upgrade to gestalt v7, we had to revise the idea of the engine module: the set of classes and resources that are not in their own gestalt Module, but that need to be registered with something in the ModuleEnvironment so they can be properly addressed. Without it, gestalt-asset can't load assets from them, and gestalt-module cannot categorize their Components. One of the factors was TeraNUI. Terasology had recently switched to using the independently packaged version of TeraNUI. It is not distributed as a gestalt module, but it defines asset types and has other classes that must be part of the API accessible to a Terasology ModuleEnvironment. So I cobbled together this function ModuleManager::loadAndConfigureEngineModule, which rougly defines the contents of the "engine module" as being things in the // the normal Package Module inclusion test
packageModule.getClassPredicate().test(clazz)
// OR anything loaded from the same classpath entry as that other stuff!
|| config.getUrls().contains(ClasspathHelper.forClass(clazz)) We had also been working on splitting subsystems out from the Engine, and that "list of other classes" grew to include all of the Engine's active subsystems: // add all subsystems as engine module parts. (needed for ECS classes loaded from external subsystems)
allSubsystems.stream().map(Object::getClass).forEach(this::addToClassesOnClasspathsToAddToEngine); Part II: The Unittest ModuleYou can't write tests for a module system without letting your tests define at least a few things outside the engine module. We put those things in a Despite that being neither in the engine module nor anywhere else you'd look for a module by default, some ambitious auto-discovery code would find those classes and then throw a fit about not being able to associate them with a module. I figured the way to handle that would be for Okay, Until It Wasn'tSomehow that worked okay for a while. The tests that cared about which module the That lasted until I tried to move the ModuleTestingEnvironment classes from the module where they had been to When those tests run, The Suddenly we have a situation where our Frankenstein engine module looks at those classes and says "hey, those come from the same place as a Subsystem, they must be mine!" The |
The deserializer doesn't load it ("" is an invalid URN) and I couldn't find it referenced as part of any check-loader-errors test.
Restores the alternate behavior described in the docstring, correcting a regression introduced in #4795. This "LocalPlayer without camera" situation has come up in headless MTE tests.
It does have error catching, but detecting this gives a much clearer log than a NullPointerException and stack trace.
Proposed FixFix: Do not add all EngineSubsystem class paths to the engine-module. Because I don't want to get sidetracked by reorganizing DiscordRPCSubsystem, I've named it as a special case: Terasology/engine/src/main/java/org/terasology/engine/core/TerasologyEngine.java Lines 108 to 115 in 1176bb1
Alternate Proposals
|
This PR is down to one failing test on CI, where it seems to be failing consistently. I've tried a number of things to reproduce locally, and I've been entirely successful—that is, It Works On My Machine every time. Help on getting a reproduction environment would be much appreciated. |
Gosh, that is a _lot_ of lines for a log statement, but slf4j 1.7 doesn't have a way to parameterize the severity level.
…s is run Instead of waiting for the jar task. This is probably the reason things didn't seem to work unless you built jars _before_ running the code.
I think I found out what had been breaking things for some modules! One was an extra comma: MovingBlocks/gestalt#133 And the other was the module under test being in a weird state because it had been picked up from the classpath but its module.txt was not read for other reasons: MovingBlocks/Terasology@ I've pushed |
Implicit in the sense that it does not appear in More specifically, Terasology/build-logic/src/main/kotlin/terasology-module.gradle.kts Lines 53 to 55 in 6508667
|
One more detail on that: Most of what was in MTE wasn't really usable from module runtime (as Terasology/ModuleTestingEnvironment#39 pointed out); it didn't provide any assets or components that had a URI you could look up in a ModuleEnvironment. There are a few exceptions, the most commonl of which are the WorldGenerators used in test scenarios. Those got moved to a module named For example: If you had a reference to one of those such as @UseWorldGenerator("ModuleTestingEnvironment:dummy") it is now @UseWorldGenerator("unittest:dummy") |
That does mean the Lines 45 to 46 in 4a301c3
|
for #4545
and Terasology/ModuleTestingEnvironment#39
from ModuleTestingEnvironment commit adf9b6df0407a62c15092a82960d8711e28bb7b7
Module Changes
No module changes are required at this time. The old ModuleTestingEnvironment code is still there and will keep doing what it does.
But as we make changes to better integrate that code with the other code in engine-tests, we're likely to make some API change somewhere so old MTE won't work with new engines past that point.
Migrating module tests should be straightforward: change your import paths to the ones based in
org.terasology.engine.integrationenvironment
, and you even get to delete ModuleTestingEnvironment from your module.txt dependencies.I have pushed
test/moveMTE
branches to some modules with these changes already.For Reviewers
The new files added under engine-tests/src/main/org/terasology/engine/integrationenvironment are almost direct copies of the https://github.com/Terasology/ModuleTestingEnvironment sources. I changed a few package paths and names here and there, but the logic is untouched; I recommend you treat them as old code and don't feel like you need to audit all 2600 lines.
There are a few changed files in engine. Most of those are various null checks for things I bumped in to while testing this out. Most of those could go in to a separate PR if you wanted them to, but I think they're small enough that I don't expect that to be what makes or breaks whether this PR gets reviewed.
The most significant engine change is the one to core.TerasologyEngine, detailed in this post from the 9th and the one following it.
How to test
Run engine tests (
unitTest
andintegrationTest
), run your module tests.You could run the game just for funsies but since this is almost entirely changes in engine-tests, there shouldn't be any differences there. Unless I got one of the null checks backwards.
Outstanding before merging