Skip to content

Commit

Permalink
Implement tests for Paper
Browse files Browse the repository at this point in the history
Spoiler alert: They fail.
  • Loading branch information
DerEchtePilz committed Feb 28, 2024
1 parent 7caadae commit bfbe182
Show file tree
Hide file tree
Showing 100 changed files with 1,833 additions and 207 deletions.
2 changes: 1 addition & 1 deletion commandapi-codecov/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<!-- Code coverage the tests -->
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-bukkit-test-tests</artifactId>
<artifactId>commandapi-paper-test-tests</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-paper-shade</artifactId>
<artifactId>commandapi-bukkit-core</artifactId>
<version>${project.version}</version>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-paper-shade</artifactId>
<artifactId>commandapi-bukkit-core</artifactId>
<version>${project.version}</version>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-paper-shade</artifactId>
<artifactId>commandapi-bukkit-core</artifactId>
<version>${project.version}</version>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-paper-shade</artifactId>
<artifactId>commandapi-bukkit-core</artifactId>
<version>${project.version}</version>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-paper-shade</artifactId>
<artifactId>commandapi-bukkit-core</artifactId>
<version>${project.version}</version>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-paper-shade</artifactId>
<artifactId>commandapi-bukkit-core</artifactId>
<version>${project.version}</version>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-paper-shade</artifactId>
<artifactId>commandapi-bukkit-core</artifactId>
<version>${project.version}</version>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-paper-shade</artifactId>
<artifactId>commandapi-bukkit-core</artifactId>
<version>${project.version}</version>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-paper-shade</artifactId>
<artifactId>commandapi-bukkit-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,5 @@

<!-- Tests -->
<module>commandapi-bukkit-kotlin-test</module>
<module>commandapi-bukkit-test-tests</module>
</modules>
</project>
3 changes: 1 addition & 2 deletions commandapi-platforms/commandapi-bukkit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
<!-- NMS versions -->
<module>commandapi-bukkit-nms</module>

<!-- Tests do not compile at this time. This is a big todo
<module>commandapi-bukkit-test</module> -->
<module>commandapi-bukkit-test</module>
</modules>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-paper-test</artifactId>
<version>9.4.0-SNAPSHOT</version>
</parent>

<artifactId>commandapi-paper-test-impl-1.16.5</artifactId>

<properties>
<spigot.version>1.16.5-R0.1-SNAPSHOT</spigot.version>
</properties>

<repositories>
<repository>
<!-- NBT API -->
<id>codemc-repo-public</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
<layout>default</layout>
</repository>
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.io/repository/nms/</url>
<layout>default</layout>
</repository>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>minecraft-libraries</id>
<url>https://libraries.minecraft.net</url>
</repository>
</repositories>

<dependencies>
<!-- Main dependencies -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.6.1</version>
</dependency>
<dependency>
<!-- This is literally just for testing, we're not actually packaging this -->
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId>
<version>2.11.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>brigadier</artifactId>
<version>1.0.17</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-paper-test-impl</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-paper-shade</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-bukkit-test-impl-1.16.5</artifactId>
<version>${project.version}</version>
</dependency>

<!-- Version-specific dependencies -->
<dependency>
<groupId>com.github.seeseemelk</groupId>
<artifactId>MockBukkit-v1.16</artifactId>
<version>1.5.2</version>
</dependency>
<dependency>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>${spigot.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>${spigot.version}</version>
<scope>provided</scope>
</dependency>

<!--
Spigot 1.16.5 is really fussy and wants log4j. If you do give it
log4j, every test fails for some reason, so we don't give it what it
wants. We can already assert that tests ARE running properly due to
test failures being reported, and by writing files during tests.
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.19.0</version>
</dependency>
-->

</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package dev.jorel.commandapi.test;

import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import dev.jorel.commandapi.CommandAPIPaper;
import dev.jorel.commandapi.nms.NMS;
import dev.jorel.commandapi.nms.NMS_1_16_R3;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.minecraft.server.v1_16_R3.CommandListenerWrapper;

public class PaperMockNMS extends PaperMockPlatform<CommandListenerWrapper> {

private final CommandAPIPaper<CommandListenerWrapper> basePaperNMS;

public PaperMockNMS(CommandAPIPaper<?> basePaperNMS) {
this.basePaperNMS = (CommandAPIPaper<CommandListenerWrapper>) basePaperNMS;
}

@Override
public Component getChat(CommandContext<CommandListenerWrapper> cmdCtx, String key) throws CommandSyntaxException {
return basePaperNMS.getChat(cmdCtx, key);
}

@Override
public NamedTextColor getChatColor(CommandContext<CommandListenerWrapper> cmdCtx, String key) {
return basePaperNMS.getChatColor(cmdCtx, key);
}

@Override
public Component getChatComponent(CommandContext<CommandListenerWrapper> cmdCtx, String key) {
return basePaperNMS.getChatComponent(cmdCtx, key);
}

@Override
public NMS<?> bukkitNMS() {
return new MockNMS(new NMS_1_16_R3());
}
}

0 comments on commit bfbe182

Please sign in to comment.