From 60909ce9a5d57ad1692bd268e1450c0faa55428f Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Wed, 26 Aug 2020 13:07:26 +0100 Subject: [PATCH] Tweak tests --- .../net/fabricmc/loom/BuildUtils.groovy | 4 +- .../loom/EmptyBuildFunctionalTest.groovy | 7 ++- .../EmptyBuildMojangFunctionalTest.groovy | 50 +++++++++++++++++++ .../loom/MixinBuildFunctionalTest.groovy | 12 +---- .../loom/SimpleBuildFunctionalTest.groovy | 2 - 5 files changed, 57 insertions(+), 18 deletions(-) create mode 100644 src/test/groovy/net/fabricmc/loom/EmptyBuildMojangFunctionalTest.groovy diff --git a/src/test/groovy/net/fabricmc/loom/BuildUtils.groovy b/src/test/groovy/net/fabricmc/loom/BuildUtils.groovy index bb2ca78..9a3083d 100644 --- a/src/test/groovy/net/fabricmc/loom/BuildUtils.groovy +++ b/src/test/groovy/net/fabricmc/loom/BuildUtils.groovy @@ -3,7 +3,7 @@ package net.fabricmc.loom /** * Created by Mitchell Skaggs on 6/12/2019. */ -static String genBuildFile() { +static String genBuildFile(String mappingsDep = "\"net.fabricmc:yarn:\${project.yarn_mappings}\"") { """ plugins { id 'fabric-loom' @@ -23,7 +23,7 @@ minecraft { dependencies { //to change the versions see the gradle.properties file minecraft "com.mojang:minecraft:\${project.minecraft_version}" - mappings "net.fabricmc:yarn:\${project.yarn_mappings}" + mappings ${mappingsDep} modCompile "net.fabricmc:fabric-loader:\${project.loader_version}" // Fabric API. This is technically optional, but you probably want it anyway. diff --git a/src/test/groovy/net/fabricmc/loom/EmptyBuildFunctionalTest.groovy b/src/test/groovy/net/fabricmc/loom/EmptyBuildFunctionalTest.groovy index 8a722cd..6980d78 100644 --- a/src/test/groovy/net/fabricmc/loom/EmptyBuildFunctionalTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/EmptyBuildFunctionalTest.groovy @@ -44,9 +44,8 @@ class EmptyBuildFunctionalTest extends Specification { result.task(":build").outcome == SUCCESS where: - mcVersion | yarnVersion | loaderVersion | fabricVersion - '1.14' | '1.14+build.21' | '0.4.8+build.155' | '0.3.0+build.183' - '1.14.1' | '1.14.1+build.10' | '0.4.8+build.155' | '0.3.0+build.183' - '1.14.2' | '1.14.2+build.7' | '0.4.8+build.155' | '0.3.0+build.183' + mcVersion | yarnVersion | loaderVersion | fabricVersion + '1.14' | '1.14+build.21' | '0.4.8+build.155' | '0.3.0+build.183' + '1.16.2' | '1.16.2+build.26:v2' | '0.9.2+build.206' | '0.19.0+build.398-1.16' } } diff --git a/src/test/groovy/net/fabricmc/loom/EmptyBuildMojangFunctionalTest.groovy b/src/test/groovy/net/fabricmc/loom/EmptyBuildMojangFunctionalTest.groovy new file mode 100644 index 0000000..a49c388 --- /dev/null +++ b/src/test/groovy/net/fabricmc/loom/EmptyBuildMojangFunctionalTest.groovy @@ -0,0 +1,50 @@ +package net.fabricmc.loom + +import org.gradle.testkit.runner.GradleRunner +import org.junit.Rule +import org.junit.rules.TemporaryFolder +import spock.lang.Specification +import spock.lang.Unroll + +import static net.fabricmc.loom.BuildUtils.* +import static org.gradle.testkit.runner.TaskOutcome.SUCCESS + +/** + * Created by Mitchell Skaggs on 6/10/2019. + */ +class EmptyBuildMojangFunctionalTest extends Specification { + @Rule + TemporaryFolder testProjectDir = new TemporaryFolder() + File settingsFile + File buildFile + File propsFile + + def setup() { + settingsFile = testProjectDir.newFile('settings.gradle') + buildFile = testProjectDir.newFile('build.gradle') + propsFile = testProjectDir.newFile('gradle.properties') + } + + @Unroll + def "empty build succeeds using Minecraft #mcVersion"() { + given: + settingsFile << genSettingsFile("empty-build-functional-test") + propsFile << genPropsFile(mcVersion, "nope", loaderVersion, fabricVersion) + buildFile << genBuildFile("minecraft.officialMojangMappings()") + + when: + def result = GradleRunner.create() + .withProjectDir(testProjectDir.root) + .withArguments('build',"--stacktrace") + .withPluginClasspath() + .forwardOutput() + .build() + + then: + result.task(":build").outcome == SUCCESS + + where: + mcVersion | loaderVersion | fabricVersion + '1.16.2' | '0.9.2+build.206' | '0.19.0+build.398-1.16' + } +} diff --git a/src/test/groovy/net/fabricmc/loom/MixinBuildFunctionalTest.groovy b/src/test/groovy/net/fabricmc/loom/MixinBuildFunctionalTest.groovy index 4041919..b183fce 100644 --- a/src/test/groovy/net/fabricmc/loom/MixinBuildFunctionalTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/MixinBuildFunctionalTest.groovy @@ -40,13 +40,7 @@ class MixinBuildFunctionalTest extends Specification { modMixinsJavaFile = testProjectDir.newFile("src/main/java/net/fabricmc/example/mixin/ExampleMixin.java") } - /** - * Why it's ignored: - *

- * When doing mixin annotation processing, a {@link ServiceLoader} is used to find implementations of {@link org.spongepowered.tools.obfuscation.service.IObfuscationService}. The classpath isn't passed to the build properly in this case, causing the Fabric-specific {@link net.fabricmc.loom.mixin.ObfuscationServiceFabric} to not be loaded. This causes the mixin to fail to compile because it doesn't know how to be reobfuscated. - */ @Unroll - @Ignore("fails because the annotation processor classpath doesn't include fabric-mixin-compile-extensions, so it doesn't know how to remap anything") def "mixin build succeeds using Minecraft #mcVersion"() { given: settingsFile << genSettingsFile("mixin-build-functional-test") @@ -69,9 +63,7 @@ class MixinBuildFunctionalTest extends Specification { result.task(":build").outcome == SUCCESS where: - mcVersion | yarnVersion | loaderVersion | fabricVersion - '1.14' | '1.14+build.21' | '0.4.8+build.155' | '0.3.0+build.184' - '1.14.1' | '1.14.1+build.10' | '0.4.8+build.155' | '0.3.0+build.184' - '1.14.2' | '1.14.2+build.7' | '0.4.8+build.155' | '0.3.0+build.184' + mcVersion | yarnVersion | loaderVersion | fabricVersion + '1.14' | '1.14+build.21' | '0.4.8+build.155' | '0.3.0+build.184' } } diff --git a/src/test/groovy/net/fabricmc/loom/SimpleBuildFunctionalTest.groovy b/src/test/groovy/net/fabricmc/loom/SimpleBuildFunctionalTest.groovy index 784a2de..b1182d9 100644 --- a/src/test/groovy/net/fabricmc/loom/SimpleBuildFunctionalTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/SimpleBuildFunctionalTest.groovy @@ -58,7 +58,5 @@ class SimpleBuildFunctionalTest extends Specification { mcVersion | yarnVersion | loaderVersion | fabricVersion '19w45a' | '19w45a+build.2:v2' | '0.6.2+build.166' | '0.4.9+build.258-1.15' '1.14' | '1.14+build.21' | '0.4.8+build.155' | '0.3.0+build.184' - '1.14.1' | '1.14.1+build.10' | '0.4.8+build.155' | '0.3.0+build.184' - '1.14.2' | '1.14.2+build.7' | '0.4.8+build.155' | '0.3.0+build.184' } }