Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ dependencies {
api 'com.google.guava:guava:31.1-jre'
implementation 'org.jetbrains:annotations:23.0.0'

testImplementation 'junit:junit:4.13.2'
testImplementation platform('org.junit:junit-bom:5.14.4')
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

testCp(files(tasks.shadowJar.archiveFile))
}
Expand All @@ -58,6 +60,10 @@ jar {
}
}

test {
useJUnitPlatform()
}

shadowJar {
from(project.rootDir) {
include 'LICENSE'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import net.neoforged.jarcompatibilitychecker.data.ClassInfo;
import net.neoforged.jarcompatibilitychecker.data.MemberInfo;
import net.neoforged.jarcompatibilitychecker.data.MethodInfo;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;
Expand Down Expand Up @@ -437,15 +437,15 @@ private FixtureComparisonBuilder withMethodAnnotation(String name, String desc,
private FixtureComparisonBuilder withBaseMethodAnnotation(String name, String desc, String annotation) {
return withBaseClass(classInfo -> {
MethodInfo methodInfo = classInfo.getMethod(name, desc);
Assert.assertNotNull("Method " + name + desc + " not found", methodInfo);
Assertions.assertNotNull(methodInfo, "Method " + name + desc + " not found");
annotate(methodInfo, annotation);
});
}

private FixtureComparisonBuilder withInputMethodAnnotation(String name, String desc, String annotation) {
return withInputClass(classInfo -> {
MethodInfo methodInfo = classInfo.getMethod(name, desc);
Assert.assertNotNull("Method " + name + desc + " not found", methodInfo);
Assertions.assertNotNull(methodInfo, "Method " + name + desc + " not found");
annotate(methodInfo, annotation);
});
}
Expand Down Expand Up @@ -525,7 +525,7 @@ private static ClassInfo publicFinalClass(String name, String... annotations) {
private static ClassInfo publicClassWithAnnotatedPublicMethod(String name, String annotation) {
ClassInfo classInfo = publicClassWithPublicMethod(name);
MethodInfo methodInfo = classInfo.getMethod(METHOD_NAME, METHOD_DESC);
Assert.assertNotNull("Method " + METHOD_NAME + METHOD_DESC + " not found", methodInfo);
Assertions.assertNotNull(methodInfo, "Method " + METHOD_NAME + METHOD_DESC + " not found");
annotate(methodInfo, annotation);
return classInfo;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import net.neoforged.jarcompatibilitychecker.core.Incompatibility;
import net.neoforged.jarcompatibilitychecker.data.ClassInfo;
import org.jetbrains.annotations.Nullable;
import org.junit.Assert;
import org.junit.jupiter.api.Assertions;

import java.io.File;
import java.io.IOException;
Expand All @@ -25,7 +25,7 @@
public abstract class BaseCompatibilityTest {
protected Path getRoot() {
URL url = this.getClass().getResource("/test.marker");
Assert.assertNotNull("Could not find test.marker", url);
Assertions.assertNotNull(url, "Could not find test.marker");

try {
return new File(url.toURI()).getParentFile().toPath();
Expand All @@ -46,18 +46,18 @@ protected void assertIncompatible(ClassInfoComparisonResults comparisonResults,
if (testIncompatibilities.length == 0)
throw new IllegalArgumentException("Must provide at least one incompatibility to test");

Assert.assertFalse(className + " was compatible when incompatibilities were expected", comparisonResults.isCompatible());
Assertions.assertFalse(comparisonResults.isCompatible(), className + " was compatible when incompatibilities were expected");

List<Incompatibility<?>> incompatibilities = comparisonResults.getIncompatibilities();
Assert.assertEquals(className + " had the wrong number of incompatibilities: " + comparisonResults, testIncompatibilities.length, incompatibilities.size());
Assertions.assertEquals(testIncompatibilities.length, incompatibilities.size(), className + " had the wrong number of incompatibilities: " + comparisonResults);

for (int i = 0; i < testIncompatibilities.length; i++) {
IncompatibilityData testData = testIncompatibilities[i];
Incompatibility<?> incompatibility = incompatibilities.get(i);
Assert.assertEquals(className + " had an incompatibility with the wrong name: " + incompatibility, testData.getName(), incompatibility.getInfo().getName());
Assert.assertEquals(className + " had an incompatibility with the wrong descriptor: " + incompatibility, testData.getDesc(), incompatibility.getInfo().getDescriptor());
Assert.assertEquals(className + " had an incompatibility with the wrong message: " + incompatibility, testData.getMessage(), incompatibility.getMessage());
Assert.assertEquals(className + " had an incompatibility with mismatch error vs. warning: " + incompatibility, testData.isError(), incompatibility.isError());
Assertions.assertEquals(testData.getName(), incompatibility.getInfo().getName(), className + " had an incompatibility with the wrong name: " + incompatibility);
Assertions.assertEquals(testData.getDesc(), incompatibility.getInfo().getDescriptor(), className + " had an incompatibility with the wrong descriptor: " + incompatibility);
Assertions.assertEquals(testData.getMessage(), incompatibility.getMessage(), className + " had an incompatibility with the wrong message: " + incompatibility);
Assertions.assertEquals(testData.isError(), incompatibility.isError(), className + " had an incompatibility with mismatch error vs. warning: " + incompatibility);
}
}

Expand Down Expand Up @@ -92,16 +92,16 @@ protected void assertIncompatible(ClassInfoComparisonResults comparisonResults,
Object... formatArgs) {
if (formatArgs.length > 0)
message = String.format(Locale.ROOT, message, formatArgs);
Assert.assertFalse(className + " was compatible when incompatibilities were expected", comparisonResults.isCompatible());
Assertions.assertFalse(comparisonResults.isCompatible(), className + " was compatible when incompatibilities were expected");

List<Incompatibility<?>> incompatibilities = comparisonResults.getIncompatibilities();
Assert.assertEquals(className + " had more than one incompatibility when one was expected: " + comparisonResults, 1, incompatibilities.size());
Assertions.assertEquals(1, incompatibilities.size(), className + " had more than one incompatibility when one was expected: " + comparisonResults);

Incompatibility<?> incompatibility = incompatibilities.get(0);
Assert.assertEquals(className + " had an incompatibility with the wrong name: " + incompatibility, name, incompatibility.getInfo().getName());
Assert.assertEquals(className + " had an incompatibility with the wrong descriptor: " + incompatibility, desc, incompatibility.getInfo().getDescriptor());
Assert.assertEquals(className + " had an incompatibility with the wrong message: " + incompatibility, message, incompatibility.getMessage());
Assert.assertEquals(className + " had an incompatibility with mismatch error vs. warning: " + incompatibility, isError, incompatibility.isError());
Assertions.assertEquals(name, incompatibility.getInfo().getName(), className + " had an incompatibility with the wrong name: " + incompatibility);
Assertions.assertEquals(desc, incompatibility.getInfo().getDescriptor(), className + " had an incompatibility with the wrong descriptor: " + incompatibility);
Assertions.assertEquals(message, incompatibility.getMessage(), className + " had an incompatibility with the wrong message: " + incompatibility);
Assertions.assertEquals(isError, incompatibility.isError(), className + " had an incompatibility with mismatch error vs. warning: " + incompatibility);
}

protected void assertCompatible(boolean checkBinary, String folder, String className) {
Expand All @@ -110,7 +110,7 @@ protected void assertCompatible(boolean checkBinary, String folder, String class
}

protected void assertCompatible(ClassInfoComparisonResults comparisonResults, String className) {
Assert.assertTrue(className + " had incompatibilities when none were expected: " + comparisonResults, comparisonResults.isCompatible());
Assertions.assertTrue(comparisonResults.isCompatible(), className + " had incompatibilities when none were expected: " + comparisonResults);
}

protected ClassInfoComparisonResults getComparisonResults(boolean checkBinary, String folderName, String className) {
Expand All @@ -125,19 +125,19 @@ protected ClassInfoComparisonResults getComparisonResults(String folderName, Str
throw new IllegalArgumentException("Folder \"" + folderName + "\" does not match the real path \"" + folder.toRealPath().getFileName().toString() + "\"");

Path baseFolder = folder.resolve("base");
Assert.assertTrue(baseFolder + " not found", Files.exists(baseFolder));
Assert.assertEquals("Base folder in " + folderName + " has invalid casing", baseFolder.toAbsolutePath(), baseFolder.toRealPath());
Assertions.assertTrue(Files.exists(baseFolder), baseFolder + " not found");
Assertions.assertEquals(baseFolder.toAbsolutePath(), baseFolder.toRealPath(), "Base folder in " + folderName + " has invalid casing");

Path inputFolder = folder.resolve("input");
boolean inputExists = Files.exists(inputFolder); // If it doesn't exist, all base classes got deleted, which is technically valid.
if (inputExists)
Assert.assertEquals("Input folder in " + folderName + " has invalid casing", inputFolder.toAbsolutePath(), inputFolder.toRealPath());
Assertions.assertEquals(inputFolder.toAbsolutePath(), inputFolder.toRealPath(), "Input folder in " + folderName + " has invalid casing");

ClassInfoCache baseCache = ClassInfoCache.fromFolder(baseFolder);
ClassInfoCache inputCache = inputExists ? ClassInfoCache.fromFolder(inputFolder) : ClassInfoCache.empty();

ClassInfo baseClassInfo = baseCache.getMainClassInfo(className);
Assert.assertNotNull("Class with name " + className + " not found in " + baseFolder, baseClassInfo);
Assertions.assertNotNull(baseClassInfo, "Class with name " + className + " not found in " + baseFolder);

return comparison.compare(baseCache, baseClassInfo, inputCache, inputCache.getMainClassInfo(className));
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package net.neoforged.jarcompatibilitychecker.test;

import net.neoforged.jarcompatibilitychecker.core.IncompatibilityMessages;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.nio.file.Path;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package net.neoforged.jarcompatibilitychecker.test;

import net.neoforged.jarcompatibilitychecker.core.IncompatibilityMessages;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.nio.file.Path;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package net.neoforged.jarcompatibilitychecker.test;

import net.neoforged.jarcompatibilitychecker.core.IncompatibilityMessages;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.nio.file.Path;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import net.neoforged.jarcompatibilitychecker.core.ClassInfoComparisonResults;
import net.neoforged.jarcompatibilitychecker.core.IncompatibilityMessages;
import net.neoforged.jarcompatibilitychecker.data.ClassInfo;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package net.neoforged.jarcompatibilitychecker.test;

import net.neoforged.jarcompatibilitychecker.core.IncompatibilityMessages;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.nio.file.Path;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package net.neoforged.jarcompatibilitychecker.test;

import net.neoforged.jarcompatibilitychecker.core.IncompatibilityMessages;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.nio.file.Path;

Expand Down
Loading
Loading