1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-04-29 14:13:13 +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 { minecraft {
runs { runs {
client { all {
workingDirectory project.file('run')
property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug' property 'forge.logging.console.level', 'debug'
@ -59,40 +66,27 @@ minecraft {
} }
} }
client {
workingDirectory project.file('run')
}
server { server {
workingDirectory project.file("run/server") workingDirectory project.file("run/server")
property 'forge.logging.markers', 'REGISTRIES'
property 'forge.logging.console.level', 'debug'
arg "--nogui" arg "--nogui"
mods {
computercraft {
source sourceSets.main
}
}
} }
data { data {
workingDirectory project.file('run') 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/') args '--mod', 'computercraft', '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/')
mods {
computercraft {
source sourceSets.main
}
}
} }
testServer { testServer {
workingDirectory project.file('test-files/server') workingDirectory project.file('test-files/server')
parent runs.server parent runs.server
arg "--nogui"
mods { mods {
cctest { cctest {
source sourceSets.test source sourceSets.testMod
} }
} }
} }
@ -101,13 +95,7 @@ minecraft {
mappings channel: 'parchment', version: "${mapping_version}-${mc_version}" mappings channel: 'parchment', version: "${mapping_version}-${mc_version}"
accessTransformer file('src/main/resources/META-INF/accesstransformer.cfg') accessTransformer file('src/main/resources/META-INF/accesstransformer.cfg')
accessTransformer file('src/test/resources/META-INF/accesstransformer.cfg') accessTransformer file('src/testMod/resources/META-INF/accesstransformer.cfg')
}
sourceSets {
main.resources {
srcDir 'src/generated/resources'
}
} }
repositories { repositories {
@ -122,6 +110,9 @@ configurations {
shade shade
implementation.extendsFrom shade implementation.extendsFrom shade
cctJavadoc cctJavadoc
testModImplementation.extendsFrom(implementation)
testModImplementation.extendsFrom(testImplementation)
} }
dependencies { dependencies {
@ -145,11 +136,17 @@ dependencies {
testImplementation 'org.jetbrains.kotlin:kotlin-reflect:1.3.72' testImplementation 'org.jetbrains.kotlin:kotlin-reflect:1.3.72'
testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8' testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.8'
testModImplementation sourceSets.main.output
cctJavadoc 'cc.tweaked:cct-javadoc:1.4.1' cctJavadoc 'cc.tweaked:cct-javadoc:1.4.1'
} }
// Compile tasks // Compile tasks
compileTestModJava {
dependsOn(compileJava)
}
javadoc { javadoc {
include "dan200/computercraft/api/**/*.java" include "dan200/computercraft/api/**/*.java"
} }
@ -185,7 +182,7 @@ jar {
from configurations.shade.collect { it.isDirectory() ? it : zipTree(it) } from configurations.shade.collect { it.isDirectory() ? it : zipTree(it) }
} }
[compileJava, compileTestJava].forEach { [compileJava, compileTestJava, compileTestModJava].forEach {
it.configure { it.configure {
options.compilerArgs << "-Xlint" << "-Xlint:-processing" options.compilerArgs << "-Xlint" << "-Xlint:-processing"
} }
@ -320,7 +317,7 @@ license {
} }
} }
[licenseTest, licenseFormatTest].forEach { [licenseTest, licenseFormatTest, licenseTestMod, licenseFormatTestMod].forEach {
it.configure { it.configure {
include("**/*.java") include("**/*.java")
header file('config/license/main.txt') header file('config/license/main.txt')
@ -348,7 +345,7 @@ task setupServer(type: Copy) {
group "test server" group "test server"
description "Sets up the environment for the 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 "eula.txt"
include "server.properties" include "server.properties"
} }
@ -358,7 +355,7 @@ task setupServer(type: Copy) {
tasks.register('testInGame', JavaExec.class).configure { tasks.register('testInGame', JavaExec.class).configure {
it.group('test server') it.group('test server')
it.description("Runs tests on a temporary Minecraft 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 // 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). // 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; package dan200.computercraft.ingame.mod;
import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.CommandDispatcher;
import dan200.computercraft.utils.Copier;
import net.minecraft.command.CommandSource; import net.minecraft.command.CommandSource;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.test.TestFunctionInfo;
import net.minecraft.test.TestRegistry;
import java.io.IOException; import java.io.IOException;
import java.io.UncheckedIOException; import java.io.UncheckedIOException;
@ -30,7 +31,14 @@ class CCTestCommand
} ) ) } ) )
.then( literal( "export" ).executes( context -> { .then( literal( "export" ).executes( context -> {
exportFiles( context.getSource().getServer() ); 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. * Copyright Daniel Ratcliffe, 2011-2021. Do not distribute without permission.
* Send enquiries to dratcliffe@gmail.com * Send enquiries to dratcliffe@gmail.com
*/ */
package dan200.computercraft.utils; package dan200.computercraft.ingame.mod;
import com.google.common.io.MoreFiles; import com.google.common.io.MoreFiles;

View File

@ -29,7 +29,7 @@ import java.util.Collection;
@Mod( TestMod.MOD_ID ) @Mod( TestMod.MOD_ID )
public class TestMod 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"; 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.neq(old_details.nbt, new_details.nbt, "Colour has changed")
test.ok() test.ok()