mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-30 21:23:00 +00:00 
			
		
		
		
	Relocate test mod to testMod source set
This'll be fun to rebase 1.17 on to :).
This commit is contained in:
		
							
								
								
									
										59
									
								
								build.gradle
									
									
									
									
									
								
							
							
						
						
									
										59
									
								
								build.gradle
									
									
									
									
									
								
							| @@ -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). | ||||||
|   | |||||||
| @@ -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; | ||||||
|             } ) ) |             } ) ) | ||||||
|         ); |         ); | ||||||
|     } |     } | ||||||
| @@ -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; | ||||||
| 
 | 
 | ||||||
| @@ -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"; | ||||||
| 
 | 
 | ||||||
| @@ -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() | ||||||
| 
 |  | ||||||
		Reference in New Issue
	
	Block a user
	 Jonathan Coates
					Jonathan Coates