10000 Skip <=1.16 function execution tests because nobody can figure out ho… · CommandAPI/CommandAPI@52f290e · GitHub
[go: up one dir, main page]

Skip to content

Commit 52f290e

Browse files
committed
Skip <=1.16 function execution tests because nobody can figure out how to run them
1 parent 2638665 commit 52f290e

File tree

2 files changed

+29
-18
lines changed
  • commandapi-platforms/commandapi-bukkit/commandapi-bukkit-test
    • commandapi-bukkit-test-impl-1.16.5/src/main/java/dev/jorel/commandapi/test
    • commandapi-bukkit-test-tests/src/test/java/dev/jorel/commandapi/test/arguments

2 files changed

+29
-18
lines changed

commandapi-platforms/commandapi-bukkit/commandapi-bukkit-test/commandapi-bukkit-test-impl-1.16.5/src/main/java/dev/jorel/commandapi/test/MockNMS.java

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
import net.minecraft.server.v1_16_R3.CustomFunctionData;
6666
import net.minecraft.server.v1_16_R3.DispenserRegistry;
6767
import net.minecraft.server.v1_16_R3.EntityPlayer;
68+
import net.minecraft.server.v1_16_R3.GameProfilerDisabled;
6869
import net.minecraft.server.v1_16_R3.GameRules;
6970
import net.minecraft.server.v1_16_R3.IRecipe;
7071
import net.minecraft.server.v1_16_R3.IRegistry;
@@ -467,34 +468,30 @@ public <T> T getMinecraftServer() {
467468
// We're using 2 as the function compilation level.
468469
// Mockito.when(minecraftServerMock.??()).thenReturn(2);
469470
Mockito.when(minecraftServerMock.getFunctionData()).thenAnswer(i -> {
470-
CustomFunctionData serverFunctionLibrary = Mockito.mock(CustomFunctionData.class);
471+
CustomFunctionData customFunctionData = Mockito.mock(CustomFunctionData.class);
471472

472473
// Functions
473-
Mockito.when(serverFunctionLibrary.a(any(MinecraftKey.class))).thenAnswer(invocation -> Optional.ofNullable(functions.get(invocation.getArgument(0))));
474-
Mockito.when(serverFunctionLibrary.f()).thenAnswer(invocation -> functions.keySet());
474+
Mockito.when(customFunctionData.a(any(MinecraftKey.class))).thenAnswer(invocation -> Optional.ofNullable(functions.get(invocation.getArgument(0))));
475+
Mockito.when(customFunctionData.f()).thenAnswer(invocation -> functions.keySet());
475476

476477
// Tags
477-
Mockito.when(serverFunctionLibrary.b(any())).thenAnswer(invocation -> {
478+
Mockito.when(customFunctionData.b(any())).thenAnswer(invocation -> {
478479
Collection<CustomFunction> tagsFromResourceLocation = tags.getOrDefault(invocation.getArgument(0), List.of());
479480
return Tag.b(Set.copyOf(tagsFromResourceLocation));
480481
});
481-
Mockito.when(serverFunctionLibrary.g()).thenAnswer(invocation -> tags.keySet());
482-
483-
return serverFunctionLibrary;
484-
// return new CustomFunctionManager(minecraftServerMock, serverFunctionLibrary) {
485-
//
486-
// // Make sure we don't use ServerFunctionManager#getDispatcher!
487-
// // That method accesses MinecraftServer.vanillaCommandDispatcher
488-
// // directly (boo) and that causes all sorts of nonsense.
489-
// @Override
490-
// public CommandDispatcher<CommandSourceStack> getDispatcher() {
491-
// return Brigadier.getCommandDispatcher();
492-
// }
493-
// };
482+
Mockito.when(customFunctionData.g()).thenAnswer(invocation -> tags.keySet());
483+
484+
// Command dispatcher
485+
Mockito.when(customFunctionData.getCommandDispatcher()).thenAnswer(invocation -> Brigadier.getCommandDispatcher());
486+
487+
// Command chain length
488+
Mockito.when(customFunctionData.b()).thenReturn(65536);
489+
490+
return customFunctionData;
494491
});
495492

496493
Mockito.when(minecraftServerMock.getGameRules()).thenAnswer(i -> new GameRules());
497-
// Mockito.when(minecraftServerMock.getMethodProfiler()).thenAnswer(i -> InactiveMetricsRecorder.INSTANCE.getProfiler());
494+
Mockito.when(minecraftServerMock.getMethodProfiler()).thenAnswer(i -> GameProfilerDisabled.a);
498495

499496

500497
return (T) minecraftServerMock;

commandapi-platforms/commandapi-bukkit/commandapi-bukkit-test/commandapi-bukkit-test-tests/src/test/java/dev/jorel/commandapi/test/arguments/ArgumentFunctionTests.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package dev.jorel.commandapi.test.arguments;
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assumptions.assumeTrue;
45

56
import java.util.List;
67

@@ -11,6 +12,7 @@
1112

1213
import be.seeseemelk.mockbukkit.entity.PlayerMock;
1314
import dev.jorel.commandapi.CommandAPICommand;
15+
import dev.jorel.commandapi.MCVersion;
1416
import dev.jorel.commandapi.arguments.FunctionArgument;
1517
import dev.jorel.commandapi.arguments.GreedyStringArgument;
1618
import dev.jorel.commandapi.test.MockPlatform;
@@ -77,6 +79,12 @@ void executionTestWithFunctionArgument() {
7779

7880
// Run the function (which should run the /mysay command)
7981
result[0].run();
82+
83+
// TODO: I can't figure out how to get commands to run on 1.16.5 and
84+
// I don't think we really care. If you decide you want to care, feel
85+
// free to implement function running for 1.16.5, but I'm not spending
86+
// any more time on it - Skepter
87+
assumeTrue(version.greaterThanOrEqualTo(MCVersion.V1_17));
8088

8189
// Check that /mysay was run successfully...
8290
assertEquals("hi", sayResults.get());
@@ -125,6 +133,12 @@ void executionTestWithFunctionArgumentTag() {
125133
for(FunctionWrapper wrapper : result) {
126134
wrapper.run();
127135
}
136+
137+
// TODO: I can't figure out how to get commands to run on 1.16.5 and
138+
// I don't think we really care. If you decide you want to care, feel
139+
// free to implement function running for 1.16.5, but I'm not spending
140+
// any more time on it - Skepter
141+
assumeTrue(version.greaterThanOrEqualTo(MCVersion.V1_17));
128142

129143
// Check that /mysay was run successfully...
130144
assertEquals("hi", sayResults.get());

0 commit comments

Comments
 (0)
0