Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Mixin audit unit tests #76

Closed
wants to merge 2 commits into from
Closed
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
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ allprojects {
}
}

dependencies {
testImplementation "org.junit.jupiter:junit-jupiter:${rootProject.junit_version}"
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}

tasks.test {
useJUnitPlatform()
}

repositories {
mavenLocal {
mavenContent {
Expand Down
12 changes: 12 additions & 0 deletions fabric/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import java.util.stream.Collectors
import net.fabricmc.loom.util.gradle.SourceSetHelper

plugins {
id("quiet-fabric-loom")
id 'maven-publish'
Expand All @@ -7,6 +10,7 @@ dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings loom.officialMojangMappings()
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
testImplementation "net.fabricmc:fabric-loader-junit:${project.loader_version}"

runtimeOnly(project(":").sourceSets.main.output)
shadow(project(":"))
Expand Down Expand Up @@ -84,6 +88,14 @@ loom {
}
}

tasks.test {
def classPathGroups = SourceSetHelper.getClasspath(loom.mods.main, getProject()).stream()
.map(File.&getAbsolutePath)
.collect(Collectors.joining(File.pathSeparator))

systemProperty("fabric.classPathGroups", classPathGroups)
}

afterEvaluate {
loom.runs.configureEach { cfg ->
runConfigCommon.systemProperties.get().each {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package ca.spottedleaf.moonrise.fabric;

import net.minecraft.SharedConstants;
import net.minecraft.server.Bootstrap;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.spongepowered.asm.mixin.MixinEnvironment;

class MixinAuditTest {
@BeforeAll
static void beforeAll() {
SharedConstants.tryDetectVersion();
Bootstrap.bootStrap();
}

@Test
void auditMixins() {
MixinEnvironment.getCurrentEnvironment().audit();
}
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ concurrentutil_version=0.0.2-SNAPSHOT
yamlconfig_version=1.0.2-SNAPSHOT
cloth_version=16.0.141
modmenu_version=12.0.0-beta.1
junit_version=5.11.3
# version ids from modrinth
fabric_lithium_version=QhCwdt4l
neo_lithium_version=wDD955sb
Expand Down
4 changes: 4 additions & 0 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ neoForge {
server()
}
}
unitTest {
enable()
testedMod = mods.moonrise
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package ca.spottedleaf.moonrise.neoforge;

import org.junit.jupiter.api.Test;
import org.spongepowered.asm.mixin.MixinEnvironment;

class MixinAuditTest {
@Test
void auditMixins() {
final ClassLoader old = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(MixinAuditTest.class.getClassLoader());
MixinEnvironment.getCurrentEnvironment().audit();
} finally {
Thread.currentThread().setContextClassLoader(old);
}
}
}
Loading