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

Fabric Game Test API #1622

Merged
merged 23 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import net.minecraft.world.level.storage.LevelStorage;

import net.fabricmc.fabric.api.gametest.v1.FabricGameTest;
import net.fabricmc.loader.FabricLoader;

public final class FabricGameTestHelper {
public static final boolean ENABLED = System.getProperty("fabric-api.gametest") != null;
Expand All @@ -53,7 +52,6 @@ public static void runHeadlessServer(LevelStorage.Session session, ResourcePackM
LOGGER.info("Starting test server");
MinecraftServer server = TestServer.startServer(thread -> {
TestServer testServer = new TestServer(thread, session, resourcePackManager, serverResourceManager, getBatches(), BlockPos.ORIGIN, registryManager);
FabricLoader.INSTANCE.setGameInstance(testServer);
return testServer;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package net.fabricmc.fabric.test.gametest;

import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.block.Blocks;
import net.minecraft.test.GameTest;
import net.minecraft.test.TestContext;
Expand All @@ -29,6 +30,9 @@ public void diamond(TestContext context) {
context.addInstantFinalTask(() ->
context.checkBlock(new BlockPos(0, 2, 0), (block) -> block == Blocks.DIAMOND_BLOCK, "Expect block to be diamond")
);

// This should be null for the game tests
assert FabricLoader.getInstance().getGameInstance() == null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't assert useless by default? It should probably be if (FabricLoader.getInstance().getGameInstance() != null) throw new AssertionError();

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might just remove this, was just a quick test tbh;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can just add -ea for vm args for test mod runs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's enabled for the regular test task too.

}

@GameTest(structureName = FabricGameTest.EMPTY_STRUCTURE)
Expand Down