1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-01-27 17:34:48 +00:00

Relocate test mod to testMod source set

This'll be fun to rebase 1.17 on to :).
This commit is contained in:
Jonathan Coates 2021-08-17 14:00:59 +01:00
parent 79c5df1d92
commit 5eb711da87
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
51 changed files with 41 additions and 37 deletions

View File

@ -45,10 +45,17 @@ tasks.withType(JavaExec).configureEach {
}
}
sourceSets {
main.resources {
srcDir 'src/generated/resources'
}
testMod {}
}
minecraft {
runs {
client {
workingDirectory project.file('run')
all {
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
@ -59,40 +66,27 @@ minecraft {
}
}
client {
workingDirectory project.file('run')
}
server {
workingDirectory project.file("run/server")
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
arg "--nogui"
mods {
computercraft {
source sourceSets.main
}
}
}
data {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
args '--mod', 'computercraft', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
mods {
computercraft {
source sourceSets.main
}
}
}
testServer {
workingDirectory project.file('test-files/server')
parent runs.server
arg "--nogui"
mods {
cctest {
source sourceSets.test
source sourceSets.testMod
}
}
}
@ -101,13 +95,7 @@ minecraft {
mappings channel: 'parchment', version: "${mapping_version}-${mc_version}"
accessTransformer file('src/main/resources/META-INF/accesstransformer.cfg')
accessTransformer file('src/test/resources/META-INF/accesstransformer.cfg')
}
sourceSets {
main.resources {
srcDir 'src/generated/resources'
}
accessTransformer file('src/testMod/resources/META-INF/accesstransformer.cfg')
}
repositories {
@ -122,6 +110,9 @@ configurations {
shade
implementation.extendsFrom shade
cctJavadoc
testModImplementation.extendsFrom(implementation)
testModImplementation.extendsFrom(testImplementation)
}
dependencies {
@ -145,11 +136,17 @@ dependencies {
testImplementation 'org.jetbrains.kotlin:kotlin-reflect:1.3.72'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8'
testModImplementation sourceSets.main.output
cctJavadoc 'cc.tweaked:cct-javadoc:1.4.1'
}
// Compile tasks
compileTestModJava {
dependsOn(compileJava)
}
javadoc {
include "dan200/computercraft/api/**/*.java"
}
@ -185,7 +182,7 @@ jar {
from configurations.shade.collect { it.isDirectory() ? it : zipTree(it) }
}
[compileJava, compileTestJava].forEach {
[compileJava, compileTestJava, compileTestModJava].forEach {
it.configure {
options.compilerArgs << "-Xlint" << "-Xlint:-processing"
}
@ -320,7 +317,7 @@ license {
}
}
[licenseTest, licenseFormatTest].forEach {
[licenseTest, licenseFormatTest, licenseTestMod, licenseFormatTestMod].forEach {
it.configure {
include("**/*.java")
header file('config/license/main.txt')
@ -348,7 +345,7 @@ task setupServer(type: Copy) {
group "test server"
description "Sets up the environment for the test server."
from("src/test/server-files") {
from("src/testMod/server-files") {
include "eula.txt"
include "server.properties"
}
@ -358,7 +355,7 @@ task setupServer(type: Copy) {
tasks.register('testInGame', JavaExec.class).configure {
it.group('test server')
it.description("Runs tests on a temporary Minecraft server.")
it.dependsOn(setupServer, 'prepareRunTestServer', 'cleanTestInGame')
it.dependsOn(setupServer, 'prepareRunTestServer', 'cleanTestInGame', 'compileTestModJava')
// Copy from runTestServer. We do it in this slightly odd way as runTestServer
// isn't created until the task is configured (which is no good for us).

View File

@ -6,9 +6,10 @@
package dan200.computercraft.ingame.mod;
import com.mojang.brigadier.CommandDispatcher;
import dan200.computercraft.utils.Copier;
import net.minecraft.command.CommandSource;
import net.minecraft.server.MinecraftServer;
import net.minecraft.test.TestFunctionInfo;
import net.minecraft.test.TestRegistry;
import java.io.IOException;
import java.io.UncheckedIOException;
@ -30,7 +31,14 @@ class CCTestCommand
} ) )
.then( literal( "export" ).executes( context -> {
exportFiles( context.getSource().getServer() );
return 0;
int total = 0;
for( TestFunctionInfo function : TestRegistry.getAllTestFunctions() )
{
total += dispatcher.execute( "test import " + function.getTestName(), context.getSource() );
total += dispatcher.execute( "test export " + function.getTestName(), context.getSource() );
}
return total;
} ) )
);
}

View File

@ -3,7 +3,7 @@
* Copyright Daniel Ratcliffe, 2011-2021. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com
*/
package dan200.computercraft.utils;
package dan200.computercraft.ingame.mod;
import com.google.common.io.MoreFiles;

View File

@ -29,7 +29,7 @@ import java.util.Collection;
@Mod( TestMod.MOD_ID )
public class TestMod
{
public static final Path sourceDir = Paths.get( "../../src/test/server-files/" ).toAbsolutePath();
public static final Path sourceDir = Paths.get( "../../src/testMod/server-files/" ).toAbsolutePath();
public static final String MOD_ID = "cctest";

View File

@ -9,4 +9,3 @@ test.eq("computercraft:turtle_normal", new_details.name, "Still a turtle")
test.neq(old_details.nbt, new_details.nbt, "Colour has changed")
test.ok()