-
Notifications
You must be signed in to change notification settings - Fork 270
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
Allow fabric-loader-junit EnvType to be changed #806
Conversation
I handled this in my loader PR here: #776 I dont believe setting the system property like that in Gradle applies when the tests are run via the IDE, especially when running indiviual tests. Thus why a solution like mine above is needed. I still need to finish off and test my two PRs before merging them. |
I see, that makes sense. For IntelliJ IDEA at least, I can confirm that the IDE executes the buildscript each time before the tests are executed (also for single tests, because they are invoked with I don't know about VSCode and Eclipse thought... So your approach is probably more compatible. |
Yeah, if you select "Run tests using IntelliJ IDEA", it does not use the buildscript. Maybe both solutions could be used. Loom could configure the If running through the IDE, I think your solution is defenitely needed (unless extra system properties for tests can somehow be defined in the .iml or something...) But if there would be an API for the loom extension, I if think that would also be pretty nice to use. loom {
test {
systemProperty("fabric.side", "server") // auto configure according to serverOnlyMinecraftJar()
systemProperty("foo", "bar")
}
} In that case my PR would probably be obsolete... |
I dont think your PR is obsolete in anyway, In my PR I failed to notice the existing system prop for setting the env. And the loom changes required for this PR should be minimal and much lower risk. This PR also does not prevent a change like mine from being done later down the line. |
junit/src/main/java/net/fabricmc/loader/impl/junit/FabricLoaderLauncherSessionListener.java
Outdated
Show resolved
Hide resolved
…rLauncherSessionListener.java use default value instead of Optional API Co-authored-by: modmuss50 <[email protected]>
You are right, this PR is not obsolete. What I meant was the configuration of the test task by loom, which might be redundant if there already is a config file containing the property. Anyways, I think this PR is ready. I did some manual testing and it seems to work without the optional API just fine. |
junit/src/main/java/net/fabricmc/loader/impl/junit/FabricLoaderLauncherSessionListener.java
Outdated
Show resolved
Hide resolved
…rLauncherSessionListener.java Remove unused parseEnvType method Co-authored-by: modmuss50 <[email protected]>
This allows the EnvType in
FabricLoaderLauncherSessionListener
to be tweaked via thefabric.side
system property.With this, server-only mods can also be unit tested.
Closes #804.
Minor detail: It would be better to introduce a utility method somewhere that parses the
fabric.side
property.I essentially use the same switch block as in
Knot#init
. However, introducing the method to thefabric-loader
subproject would also require a new version offabric-loader
for such a minor feature. Therefore, I've duplicated the parser for now.Usage
One way to tweak the unit-test EnvType, in Gradle buildscripts:
I will also open a pull request on loom for automatically adding the property when
loom.serverOnlyMinecraftJar()
is configured.