mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-25 13:30:08 +00:00
Full audit fixpass: 93 defect fixes, 14 perf wins, vestigial cleanup
This commit is contained in:
1 parent
13e02ecd2f
commit
14b6280668
215 files changed
+4604
-2407
No files matched your search
+1
-1
@@ -22,7 +22,7 @@ public class IrisStartupOrderingTest {
|
||||
@Test
|
||||
public void externalDatapacksValidateBeforeDimensionPacks() throws Exception {
|
||||
String source = Files.readString(Path.of(System.getProperty("iris.startupSource")));
|
||||
String enable = section(source, "private void enable()", "public void addShutdownHook()");
|
||||
String enable = section(source, "private boolean enable()", "public void addShutdownHook()");
|
||||
|
||||
assertOrdered(enable,
|
||||
"DatapackIngestService.validateOnStartup();",
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
package art.arcane.iris.core.commands;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class CommandIrisDownloadDefaultTest {
|
||||
@Test
|
||||
public void downloadBranchParamDefaultsToTheCoreConstant() throws Exception {
|
||||
String source = Files.readString(Path.of("src/main/java/art/arcane/iris/core/commands/CommandIris.java"));
|
||||
int branchParam = source.indexOf("name = \"branch\"");
|
||||
assertTrue("CommandIris must declare the branch param", branchParam >= 0);
|
||||
String declaration = source.substring(branchParam, source.indexOf(')', branchParam));
|
||||
assertTrue("branch param default must be PackDownloader.DEFAULT_BRANCH, not a literal",
|
||||
declaration.contains("defaultValue = PackDownloader.DEFAULT_BRANCH"));
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package art.arcane.iris.core.commands;
|
||||
|
||||
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 org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class CommandPackOptionalPackContractTest {
|
||||
private static DirectorParameterDescriptor packParam(String method) throws Exception {
|
||||
DirectorNodeDescriptor node = DirectorAnnotationCompatibility
|
||||
.fromMethod(CommandPack.class.getDeclaredMethod(method, String.class))
|
||||
.orElseThrow();
|
||||
DirectorParameterDescriptor pack = node.getParameters().get(0);
|
||||
assertEquals("pack", pack.getName());
|
||||
return pack;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bareValidateAndStatusAreInvocableWithoutAPackArgument() throws Exception {
|
||||
for (String method : List.of("validate", "status")) {
|
||||
DirectorParameterDescriptor pack = packParam(method);
|
||||
assertFalse(method + " must not require a pack", pack.isRequired());
|
||||
assertFalse(method + " needs a non-blank default for Director to treat it as optional",
|
||||
pack.getDefaultValue().isBlank());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void cleanupAndRestoreStillRequireAPack() throws Exception {
|
||||
for (String method : List.of("cleanup", "restore")) {
|
||||
DirectorNodeDescriptor node = DirectorAnnotationCompatibility
|
||||
.fromMethod(findMethod(method))
|
||||
.orElseThrow();
|
||||
DirectorParameterDescriptor pack = node.getParameters().get(0);
|
||||
assertEquals("pack", pack.getName());
|
||||
assertTrue(method + " must keep requiring a pack", pack.isRequired());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allPacksPredicateAcceptsSentinelBlankAndNull() {
|
||||
assertTrue(CommandPack.wantsAllPacks(null));
|
||||
assertTrue(CommandPack.wantsAllPacks(""));
|
||||
assertTrue(CommandPack.wantsAllPacks(" "));
|
||||
assertTrue(CommandPack.wantsAllPacks("*"));
|
||||
assertFalse(CommandPack.wantsAllPacks("overworld"));
|
||||
}
|
||||
|
||||
private static java.lang.reflect.Method findMethod(String name) {
|
||||
for (java.lang.reflect.Method method : CommandPack.class.getDeclaredMethods()) {
|
||||
if (method.getName().equals(name)) {
|
||||
return method;
|
||||
}
|
||||
}
|
||||
throw new AssertionError("CommandPack must declare " + name);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user