Skip to content

Commit

Permalink
build: Fix JUnit trying to test Mixin classes
Browse files Browse the repository at this point in the history
Also added `abstract` modifiers to all mixin test classes, and did a small local variable rename.
  • Loading branch information
Steveplays28 committed Mar 15, 2024
1 parent b889276 commit 3c919bd
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ test {
events "passed", "skipped", "failed"
}
jvmArgs("-ea", "-Dmixin.debug.verbose=true", "-Dmixin.debug.export=true", "-Dmixin.checks.interfaces=true")
exclude "**/mixin*"
}

tasks.withType(ProcessResources).configureEach {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(DefaultAttributes.class)
public class MixinDefaultAttributesTest {
public abstract class MixinDefaultAttributesTest {
@Redirect(method = "<clinit>", at = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/ai/attributes/DefaultAttributes;SUPPLIERS:Ljava/util/Map;", shift = At.Shift.BY, by = -1))
private static ImmutableMap<?, ?> cubic_chunks_3$fixNeoForgeRegistryError(ImmutableMap.Builder<?, ?> instance) {
return ImmutableMap.builder().build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(Player.class)
public class MixinPlayerTest {
public abstract class MixinPlayerTest {
@Inject(method = "createAttributes", at = @At(value = "HEAD"), cancellable = true)
private static void cubic_chunks_3$fixNeoForgeErrors(CallbackInfoReturnable<AttributeSupplier.Builder> cir) {
cir.setReturnValue(AttributeSupplier.builder());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.spongepowered.asm.mixin.Shadow;

@Mixin(ServerPlayer.class)
public class MixinServerPlayerTest {
public abstract class MixinServerPlayerTest {
@Shadow
@SuppressWarnings("unused")
public ServerGamePacketListenerImpl connection = Mockito.mock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ private ServerPlayer setupServerPlayer(ServerLevel serverLevel) {
ServerPlayer player = setupServerPlayer(serverLevelReference.value());

// teleportTo takes the destination level to teleport to as a param, so we mock it
ServerLevel serverLevelReferenceSpy = spy(serverLevelReference.value());
ServerLevel serverLevelSpy = spy(serverLevelReference.value());
ServerChunkCache serverChunkCacheMock = mock(ServerChunkCache.class);
Mockito.when(serverLevelReferenceSpy.getChunkSource()).thenReturn(serverChunkCacheMock);
Mockito.when(serverLevelSpy.getChunkSource()).thenReturn(serverChunkCacheMock);

player.teleportTo(serverLevelReferenceSpy, 0, 0, 0, mock(), 0, 0);
player.teleportTo(serverLevelSpy, 0, 0, 0, mock(), 0, 0);

// Verify that serverChunkCacheMock.addRegionTicket(...) is called once
Mockito.verify(serverChunkCacheMock, Mockito.times(1))
Expand Down

0 comments on commit 3c919bd

Please sign in to comment.