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:
Brian Neumann-Fopiano committed 2026-09-08 05:27:49 -04:00
1 parent fd146de1ad
commit 9dcaed5315
21 files changed
+34 -187

No files matched your search

@@ -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;
}
}