-
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(MTE): allow a test to add its own EngineSubsystem #5044
Conversation
/** | ||
* Do not add an extra subsystem to the integration environment. | ||
* <p> | ||
* [Odd marker interface because annotation fields cannot default to null.] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ Can/should one use Optional
? Can there be more than subsystem added (in principle, not necessarily in practice)? If so, this could also be a list.
In any case, having this marker interface in engine-tests
is just fine, as it is definitely understandable and we should probably not spent too much time and effort on this (now).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we can. The list of types allowed to annotations is quite limited.
/** | ||
* The network mode the host engine starts with. | ||
* <p> | ||
* See {@link NetworkMode} for details on the options. | ||
* <p> | ||
* Some modes automatically include a {@link LocalPlayer}. | ||
* <p> | ||
* If you want to simulate multiple players with | ||
* {@link org.terasology.engine.integrationenvironment.Engines#createClient Engines.createClient}, | ||
* you will need a mode with a {@linkplain NetworkMode#isServer() server}. | ||
*/ | ||
NetworkMode networkMode() default NetworkMode.NONE; | ||
|
||
/** | ||
* Add an additional subsystem to the engine. | ||
* <p> | ||
* A new instance will be included in the engine's subsystems when it is created. | ||
* <p> | ||
* Implementing {@link EngineSubsystem#initialise} gives you the opportunity to | ||
* make changes to the configuration <em>before</em> it would otherwise be available. | ||
*/ | ||
Class<? extends EngineSubsystem> subsystem() default NO_SUBSYSTEM.class; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 thanks for the doc strings!
@@ -195,16 +194,31 @@ TerasologyEngine createHeadlessEngine() throws IOException { | |||
TerasologyEngine createHeadedEngine() throws IOException { | |||
EngineSubsystem audio = new LwjglAudio(); | |||
TerasologyEngineBuilder terasologyEngineBuilder = new TerasologyEngineBuilder() | |||
.add(new WithUnittestModule()) | |||
.add(new IntegrationEnvironmentSubsystem()) | |||
.add(audio) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ for the sake of consistency, can we just inline the creation of audio
here as well, or do we need it explicitly somewhere else?
.add(audio) | |
.add(new LwjglAudio()) |
@@ -195,16 +194,31 @@ TerasologyEngine createHeadlessEngine() throws IOException { | |||
TerasologyEngine createHeadedEngine() throws IOException { | |||
EngineSubsystem audio = new LwjglAudio(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EngineSubsystem audio = new LwjglAudio(); |
@IntegrationEnvironment(subsystem=SomeEngineSubsystem.class)
, giving the author more control during engine initialization and much more power to shoot themselves in the foot.integrationenvironment.Engines
and in to anIntegrationEnvironmentSubsystem
. This makes it easier to guess when that code will be run (compared to usual non-MTE code), and makes it easier to override if needed.Review Hints
IntegrationEnvironmentSubsystem.registerCurrentDirectoryIfModule is a direct move of a method formerly in
integrationenvironent.Engines
.How to test
This is an MTE-only change, so there's no player-visible impact. You could use
CustomSubsystemTest
as an example to start from if you want to experiment with it yourself.