mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-26 22:10:18 +00:00
Share test fixtures across modules
- Move art.arcane.iris.testsupport into core/src/testFixtures and apply java-test-fixtures to core - Consume core test fixtures from the bukkit plugin, nms, probe and the three loader adapters - Delete the duplicate ProjectPaths copies in the bukkit-plugin and modded-common test trees - Point ModdedMessageContributorTest at the shared ProjectPaths - Guard CommandPackCompatTest, NativeTransitionColumnTest and StubPlatformStateTest with PlatformLeakGuard - Release the probe runtime state after DimensionStackSuperflatProbeTest opens a workspace - Keep core main classes ahead of the core jar on the test classpath so the bytecode gates still scan a directory
This commit is contained in:
1 parent
fd146de1ad
commit
9dcaed5315
21 files changed
+34
-187
No files matched your search
+5
@@ -6,6 +6,7 @@ import art.arcane.iris.spi.IrisPlatform;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.spi.PlatformRegistries;
|
||||
import art.arcane.iris.testsupport.PlatformLeakGuard;
|
||||
import net.minecraft.SharedConstants;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.server.Bootstrap;
|
||||
@@ -16,6 +17,7 @@ import net.minecraft.world.level.block.RotatedPillarBlock;
|
||||
import net.minecraft.world.level.block.LiquidBlock;
|
||||
import net.minecraft.world.level.levelgen.Heightmap;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.mockito.MockedStatic;
|
||||
|
||||
@@ -30,6 +32,9 @@ import static org.mockito.Mockito.mockStatic;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public final class NativeTransitionColumnTest {
|
||||
@Rule
|
||||
public final PlatformLeakGuard leakGuard = PlatformLeakGuard.clean();
|
||||
|
||||
@BeforeClass
|
||||
public static void bootstrap() {
|
||||
SharedConstants.tryDetectVersion();
|
||||
|
||||
@@ -22,6 +22,7 @@ dependencies {
|
||||
testImplementation(libs.paper.api)
|
||||
testImplementation(libs.bstats)
|
||||
testImplementation(project(':core'))
|
||||
testImplementation(testFixtures(project(':core')))
|
||||
testImplementation(volmLibCoordinate) {
|
||||
transitive = false
|
||||
}
|
||||
|
||||
+4
-20
@@ -7,10 +7,8 @@ import art.arcane.iris.core.pack.PackValidationResult;
|
||||
import art.arcane.volmlib.util.director.compat.DirectorAnnotationCompatibility;
|
||||
import art.arcane.volmlib.util.director.runtime.DirectorNodeDescriptor;
|
||||
import art.arcane.volmlib.util.director.runtime.DirectorParameterDescriptor;
|
||||
import art.arcane.iris.spi.IrisPlatform;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import art.arcane.iris.testsupport.PlatformLeakGuard;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
@@ -20,22 +18,8 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class CommandPackCompatTest {
|
||||
private IrisPlatform previousPlatform;
|
||||
|
||||
/** The persisted Minecraft version is only used when no platform is bound, so pin that here. */
|
||||
@Before
|
||||
public void unbindPlatform() {
|
||||
previousPlatform = IrisPlatforms.isBound() ? IrisPlatforms.get() : null;
|
||||
IrisPlatforms.unbind();
|
||||
}
|
||||
|
||||
@After
|
||||
public void rebindPlatform() {
|
||||
IrisPlatforms.unbind();
|
||||
if (previousPlatform != null) {
|
||||
IrisPlatforms.bind(previousPlatform);
|
||||
}
|
||||
}
|
||||
@Rule
|
||||
public final PlatformLeakGuard leakGuard = PlatformLeakGuard.clean();
|
||||
|
||||
private static CompatFinding block(CompatAction action, String subjectKey) {
|
||||
return new CompatFinding(
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
package art.arcane.iris.testsupport;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.CodeSource;
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
public final class ProjectPaths {
|
||||
private static final Path MODULE_ROOT = resolveModuleRoot();
|
||||
private static final Path REPOSITORY_ROOT = resolveRepositoryRoot(MODULE_ROOT);
|
||||
|
||||
private ProjectPaths() {
|
||||
}
|
||||
|
||||
public static Path moduleRoot() {
|
||||
return MODULE_ROOT;
|
||||
}
|
||||
|
||||
public static Path repositoryRoot() {
|
||||
return REPOSITORY_ROOT;
|
||||
}
|
||||
|
||||
public static Path moduleFile(String relative) {
|
||||
return MODULE_ROOT.resolve(relative).normalize();
|
||||
}
|
||||
|
||||
public static Path repositoryFile(String relative) {
|
||||
return REPOSITORY_ROOT.resolve(relative).normalize();
|
||||
}
|
||||
|
||||
public static File moduleFileAt(String relative) {
|
||||
return moduleFile(relative).toFile();
|
||||
}
|
||||
|
||||
public static File repositoryFileAt(String relative) {
|
||||
return repositoryFile(relative).toFile();
|
||||
}
|
||||
|
||||
private static Path resolveModuleRoot() {
|
||||
ProtectionDomain domain = ProjectPaths.class.getProtectionDomain();
|
||||
CodeSource source = domain == null ? null : domain.getCodeSource();
|
||||
URL location = source == null ? null : source.getLocation();
|
||||
|
||||
if (location != null) {
|
||||
try {
|
||||
Path current = Path.of(location.toURI()).toAbsolutePath().normalize();
|
||||
|
||||
while (current != null) {
|
||||
Path name = current.getFileName();
|
||||
|
||||
if (name != null && "build".equals(name.toString()) && current.getParent() != null) {
|
||||
return current.getParent();
|
||||
}
|
||||
|
||||
current = current.getParent();
|
||||
}
|
||||
} catch (URISyntaxException | IllegalArgumentException ignored) {
|
||||
return Path.of("").toAbsolutePath().normalize();
|
||||
}
|
||||
}
|
||||
|
||||
return Path.of("").toAbsolutePath().normalize();
|
||||
}
|
||||
|
||||
private static Path resolveRepositoryRoot(Path moduleRoot) {
|
||||
Path current = moduleRoot;
|
||||
|
||||
while (current != null) {
|
||||
if (Files.isRegularFile(current.resolve("settings.gradle"))
|
||||
&& Files.isDirectory(current.resolve("core/src/main/java"))) {
|
||||
return current;
|
||||
}
|
||||
|
||||
current = current.getParent();
|
||||
}
|
||||
|
||||
return moduleRoot;
|
||||
}
|
||||
}
|
||||
@@ -141,6 +141,7 @@ dependencies {
|
||||
implementation("net.fabricmc:fabric-loader:${fabricLoaderVersion}")
|
||||
testImplementation('junit:junit:4.13.2')
|
||||
testImplementation('org.mockito:mockito-core:5.23.0')
|
||||
testImplementation(testFixtures('art.arcane:core'))
|
||||
testImplementation(libs.spigot) {
|
||||
transitive = false
|
||||
}
|
||||
|
||||
@@ -158,6 +158,7 @@ dependencies {
|
||||
implementation minecraft.dependency("net.minecraftforge:forge:${forgeVersion}")
|
||||
testImplementation('junit:junit:4.13.2')
|
||||
testImplementation('org.mockito:mockito-core:5.23.0')
|
||||
testImplementation(testFixtures('art.arcane:core'))
|
||||
testImplementation(libs.spigot) {
|
||||
transitive = false
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ package art.arcane.iris.modded.localization;
|
||||
|
||||
import art.arcane.iris.core.localization.IrisLanguage;
|
||||
import art.arcane.iris.core.localization.IrisMessages;
|
||||
import art.arcane.iris.modded.testsupport.ProjectPaths;
|
||||
import art.arcane.iris.testsupport.ProjectPaths;
|
||||
import art.arcane.volmlib.util.localization.MessageKey;
|
||||
import art.arcane.volmlib.util.localization.VolmitLocales;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
-82
@@ -1,82 +0,0 @@
|
||||
package art.arcane.iris.modded.testsupport;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.CodeSource;
|
||||
import java.security.ProtectionDomain;
|
||||
|
||||
public final class ProjectPaths {
|
||||
private static final Path MODULE_ROOT = resolveModuleRoot();
|
||||
private static final Path REPOSITORY_ROOT = resolveRepositoryRoot(MODULE_ROOT);
|
||||
|
||||
private ProjectPaths() {
|
||||
}
|
||||
|
||||
public static Path moduleRoot() {
|
||||
return MODULE_ROOT;
|
||||
}
|
||||
|
||||
public static Path repositoryRoot() {
|
||||
return REPOSITORY_ROOT;
|
||||
}
|
||||
|
||||
public static Path moduleFile(String relative) {
|
||||
return MODULE_ROOT.resolve(relative).normalize();
|
||||
}
|
||||
|
||||
public static Path repositoryFile(String relative) {
|
||||
return REPOSITORY_ROOT.resolve(relative).normalize();
|
||||
}
|
||||
|
||||
public static File moduleFileAt(String relative) {
|
||||
return moduleFile(relative).toFile();
|
||||
}
|
||||
|
||||
public static File repositoryFileAt(String relative) {
|
||||
return repositoryFile(relative).toFile();
|
||||
}
|
||||
|
||||
private static Path resolveModuleRoot() {
|
||||
ProtectionDomain domain = ProjectPaths.class.getProtectionDomain();
|
||||
CodeSource source = domain == null ? null : domain.getCodeSource();
|
||||
URL location = source == null ? null : source.getLocation();
|
||||
|
||||
if (location != null) {
|
||||
try {
|
||||
Path current = Path.of(location.toURI()).toAbsolutePath().normalize();
|
||||
|
||||
while (current != null) {
|
||||
Path name = current.getFileName();
|
||||
|
||||
if (name != null && "build".equals(name.toString()) && current.getParent() != null) {
|
||||
return current.getParent();
|
||||
}
|
||||
|
||||
current = current.getParent();
|
||||
}
|
||||
} catch (URISyntaxException | IllegalArgumentException ignored) {
|
||||
return Path.of("").toAbsolutePath().normalize();
|
||||
}
|
||||
}
|
||||
|
||||
return Path.of("").toAbsolutePath().normalize();
|
||||
}
|
||||
|
||||
private static Path resolveRepositoryRoot(Path moduleRoot) {
|
||||
Path current = moduleRoot;
|
||||
|
||||
while (current != null) {
|
||||
if (Files.isRegularFile(current.resolve("settings.gradle"))
|
||||
&& Files.isDirectory(current.resolve("core/src/main/java"))) {
|
||||
return current;
|
||||
}
|
||||
|
||||
current = current.getParent();
|
||||
}
|
||||
|
||||
return moduleRoot;
|
||||
}
|
||||
}
|
||||
@@ -132,6 +132,7 @@ configurations.testRuntimeClasspath.extendsFrom(configurations.runtimeClasspath,
|
||||
dependencies {
|
||||
testImplementation('junit:junit:4.13.2')
|
||||
testImplementation('org.mockito:mockito-core:5.23.0')
|
||||
testImplementation(testFixtures('art.arcane:core'))
|
||||
testImplementation(libs.spigot) {
|
||||
transitive = false
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user