mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-25 21:40:05 +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
+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;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user