diff options
author | shedaniel <daniel@shedaniel.me> | 2021-06-17 23:44:48 +0800 |
---|---|---|
committer | shedaniel <daniel@shedaniel.me> | 2021-06-17 23:44:48 +0800 |
commit | 24a515270a87c92c52192fdf03baedfe84639545 (patch) | |
tree | 438a4083f0a5b21543ad02f5879e85b8903e12d4 /src/test/groovy/net | |
parent | ce3c96ca869975ad443026b92130764ac3135384 (diff) | |
parent | 147af48879c725f422b99ea15a9e6f3ce1a496f3 (diff) | |
download | architectury-loom-24a515270a87c92c52192fdf03baedfe84639545.tar.gz architectury-loom-24a515270a87c92c52192fdf03baedfe84639545.tar.bz2 architectury-loom-24a515270a87c92c52192fdf03baedfe84639545.zip |
Merge remote-tracking branch 'FabricMC/dev/0.9' into dev/0.9
# Conflicts:
# build.gradle
# src/main/java/net/fabricmc/loom/LoomGradleExtension.java
# src/main/java/net/fabricmc/loom/configuration/CompileConfiguration.java
# src/main/java/net/fabricmc/loom/configuration/providers/MinecraftProvider.java
# src/main/java/net/fabricmc/loom/configuration/providers/mappings/MappingsProvider.java
# src/main/java/net/fabricmc/loom/configuration/providers/mappings/MojangMappingsDependency.java
# src/main/java/net/fabricmc/loom/configuration/providers/minecraft/MinecraftMappedProvider.java
# src/main/java/net/fabricmc/loom/task/GenerateSourcesTask.java
# src/main/java/net/fabricmc/loom/util/SourceRemapper.java
Diffstat (limited to 'src/test/groovy/net')
-rw-r--r-- | src/test/groovy/net/fabricmc/loom/test/integration/DependencyResolutionManagementTest.groovy (renamed from src/test/groovy/net/fabricmc/loom/test/integration/dependencyResolutionManagement.groovy) | 0 | ||||
-rw-r--r-- | src/test/groovy/net/fabricmc/loom/test/integration/ParchmentTest.groovy | 52 | ||||
-rw-r--r-- | src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/IntermediaryMappingLayerTest.groovy | 43 | ||||
-rw-r--r-- | src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/LayeredMappingSpecBuilderTest.groovy | 118 | ||||
-rw-r--r-- | src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/LayeredMappingsSpecification.groovy | 121 | ||||
-rw-r--r-- | src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/LayeredMappingsTestConstants.groovy | 47 | ||||
-rw-r--r-- | src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/MojangMappingLayerTest.groovy | 49 | ||||
-rw-r--r-- | src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/ParchmentMappingLayerTest.groovy | 74 |
8 files changed, 504 insertions, 0 deletions
diff --git a/src/test/groovy/net/fabricmc/loom/test/integration/dependencyResolutionManagement.groovy b/src/test/groovy/net/fabricmc/loom/test/integration/DependencyResolutionManagementTest.groovy index a8b27336..a8b27336 100644 --- a/src/test/groovy/net/fabricmc/loom/test/integration/dependencyResolutionManagement.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/integration/DependencyResolutionManagementTest.groovy diff --git a/src/test/groovy/net/fabricmc/loom/test/integration/ParchmentTest.groovy b/src/test/groovy/net/fabricmc/loom/test/integration/ParchmentTest.groovy new file mode 100644 index 00000000..836ba58a --- /dev/null +++ b/src/test/groovy/net/fabricmc/loom/test/integration/ParchmentTest.groovy @@ -0,0 +1,52 @@ +/* + * This file is part of fabric-loom, licensed under the MIT License (MIT). + * + * Copyright (c) 2016, 2017, 2018 FabricMC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package net.fabricmc.loom.test.integration + +import net.fabricmc.loom.test.util.ProjectTestTrait +import spock.lang.Specification +import spock.lang.Unroll + +import static org.gradle.testkit.runner.TaskOutcome.SUCCESS + +class ParchmentTest extends Specification implements ProjectTestTrait { + @Override + String name() { + "parchment" + } + + @Unroll + def "parchment #gradle"() { + when: + def result = create("build", gradle) + + then: + result.task(":build").outcome == SUCCESS + + where: + gradle | _ + DEFAULT_GRADLE | _ + PRE_RELEASE_GRADLE | _ + } +} diff --git a/src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/IntermediaryMappingLayerTest.groovy b/src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/IntermediaryMappingLayerTest.groovy new file mode 100644 index 00000000..3184ceb9 --- /dev/null +++ b/src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/IntermediaryMappingLayerTest.groovy @@ -0,0 +1,43 @@ +/* + * This file is part of fabric-loom, licensed under the MIT License (MIT). + * + * Copyright (c) 2016, 2017, 2018 FabricMC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package net.fabricmc.loom.test.unit.layeredmappings + +import net.fabricmc.loom.configuration.providers.mappings.intermediary.IntermediaryMappingsSpec + +class IntermediaryMappingLayerTest extends LayeredMappingsSpecification { + def "Read intermediary mappings" () { + setup: + mockMappingsProvider.intermediaryTinyFile() >> extractFileFromZip(downloadFile(INTERMEDIARY_1_17_URL, "intermediary.jar"), "mappings/mappings.tiny") + when: + def mappings = getSingleMapping(new IntermediaryMappingsSpec()) + def tiny = getTiny(mappings) + then: + mappings.srcNamespace == "official" + mappings.dstNamespaces == ["intermediary", "named"] + mappings.classes.size() == 6107 + mappings.getClass("abc").getDstName(0) == "net/minecraft/class_3191" + mappings.getClass("abc").getDstName(1) == "net/minecraft/class_3191" + } +} diff --git a/src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/LayeredMappingSpecBuilderTest.groovy b/src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/LayeredMappingSpecBuilderTest.groovy new file mode 100644 index 00000000..035ac11e --- /dev/null +++ b/src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/LayeredMappingSpecBuilderTest.groovy @@ -0,0 +1,118 @@ +/* + * This file is part of fabric-loom, licensed under the MIT License (MIT). + * + * Copyright (c) 2016, 2017, 2018 FabricMC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package net.fabricmc.loom.test.unit.layeredmappings + +import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingSpec +import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingSpecBuilder +import net.fabricmc.loom.configuration.providers.mappings.intermediary.IntermediaryMappingsSpec +import net.fabricmc.loom.configuration.providers.mappings.mojmap.MojangMappingsSpec +import net.fabricmc.loom.configuration.providers.mappings.parchment.ParchmentMappingsSpec +import org.gradle.api.Action +import org.gradle.util.ConfigureUtil +import spock.lang.Specification + +class LayeredMappingSpecBuilderTest extends Specification { + def "simple mojmap" () { + when: + def spec = layered() { + officalMojangMappings() + } + def layers = spec.layers() + then: + spec.version == "layered+hash.961" + layers.size() == 2 + layers[0].class == IntermediaryMappingsSpec + layers[1].class == MojangMappingsSpec + } + + def "simple mojmap with parchment" () { + when: + def spec = layered() { + officalMojangMappings() + parchment("I like cake") + } + def layers = spec.layers() + def parchment = layers[2] as ParchmentMappingsSpec + then: + spec.version == "layered+hash.863714404" + layers.size() == 3 + layers[0].class == IntermediaryMappingsSpec + layers[1].class == MojangMappingsSpec + layers[2].class == ParchmentMappingsSpec + parchment.mavenNotation() == "I like cake" + parchment.removePrefix() == true + } + + def "simple mojmap with parchment keep prefix" () { + when: + def spec = layered() { + officalMojangMappings() + parchment("I like cake") { + it.removePrefix = false + } + } + def layers = spec.layers() + def parchment = layers[2] as ParchmentMappingsSpec + then: + spec.version == "layered+hash.863714410" + layers.size() == 3 + layers[0].class == IntermediaryMappingsSpec + layers[1].class == MojangMappingsSpec + layers[2].class == ParchmentMappingsSpec + parchment.mavenNotation() == "I like cake" + parchment.removePrefix() == false + } + + def "simple mojmap with parchment keep prefix alternate hash" () { + when: + def spec = layered() { + officalMojangMappings() + parchment("I really like cake") { + it.removePrefix = false + } + } + def layers = spec.layers() + def parchment = layers[2] as ParchmentMappingsSpec + then: + spec.version == "layered+hash.1144465487" + layers.size() == 3 + layers[0].class == IntermediaryMappingsSpec + layers[1].class == MojangMappingsSpec + layers[2].class == ParchmentMappingsSpec + parchment.mavenNotation() == "I really like cake" + parchment.removePrefix() == false + } + + // Gradle does this big of magic behind the scenes + LayeredMappingSpec layered(@DelegatesTo(LayeredMappingSpecBuilder) Closure cl) { + return layeredAction(ConfigureUtil.configureUsing(cl)) + } + + LayeredMappingSpec layeredAction(Action<LayeredMappingSpecBuilder> action) { + LayeredMappingSpecBuilder builder = new LayeredMappingSpecBuilder() + action.execute(builder) + return builder.build() + } +} diff --git a/src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/LayeredMappingsSpecification.groovy b/src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/LayeredMappingsSpecification.groovy new file mode 100644 index 00000000..8fa26b34 --- /dev/null +++ b/src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/LayeredMappingsSpecification.groovy @@ -0,0 +1,121 @@ +/* + * This file is part of fabric-loom, licensed under the MIT License (MIT). + * + * Copyright (c) 2016, 2017, 2018 FabricMC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package net.fabricmc.loom.test.unit.layeredmappings + +import groovy.transform.CompileStatic +import net.fabricmc.loom.configuration.providers.MinecraftProvider +import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingSpec +import net.fabricmc.loom.configuration.providers.mappings.LayeredMappingsProcessor +import net.fabricmc.loom.configuration.providers.mappings.MappingContext +import net.fabricmc.loom.configuration.providers.mappings.MappingLayer +import net.fabricmc.loom.configuration.providers.mappings.MappingsProvider +import net.fabricmc.loom.configuration.providers.mappings.MappingsSpec +import net.fabricmc.mappingio.format.Tiny2Writer +import net.fabricmc.mappingio.tree.MappingTree +import net.fabricmc.mappingio.tree.MemoryMappingTree +import org.gradle.api.logging.Logger +import spock.lang.Specification + +import java.util.zip.ZipFile + +abstract class LayeredMappingsSpecification extends Specification implements LayeredMappingsTestConstants { + Logger mockLogger = Mock(Logger) + MappingsProvider mockMappingsProvider = Mock(MappingsProvider) + MinecraftProvider mockMinecraftProvider = Mock(MinecraftProvider) + + MappingContext mappingContext = new TestMappingContext() + + File tempDir = File.createTempDir() + + Map<String, File> mavenFiles = [:] + + def withMavenFile(String mavenNotation, File file) { + mavenFiles.put(mavenNotation, file) + } + + File downloadFile(String url, String name) { + File dst = new File(tempDir, name) + dst.parentFile.mkdirs() + dst << new URL(url).newInputStream() + return dst + } + + File extractFileFromZip(File zipFile, String name) { + File dst = new File(tempDir, name) + dst.parentFile.mkdirs() + + new ZipFile(zipFile).withCloseable { + dst << it.getInputStream(it.getEntry(name)) + } + return dst + } + + MemoryMappingTree getSingleMapping(MappingsSpec<? extends MappingLayer> spec) { + MemoryMappingTree mappingTree = new MemoryMappingTree() + spec.createLayer(mappingContext).visit(mappingTree) + return mappingTree + } + + MemoryMappingTree getLayeredMappings(MappingsSpec<? extends MappingLayer>... specs) { + LayeredMappingSpec spec = new LayeredMappingSpec(specs.toList()) + LayeredMappingsProcessor processor = new LayeredMappingsProcessor(spec) + return processor.getMappings(mappingContext) + } + + String getTiny(MemoryMappingTree mappingTree) { + def sw = new StringWriter() + mappingTree.accept(new Tiny2Writer(sw, false)) + return sw.toString() + } + + @CompileStatic + class TestMappingContext implements MappingContext { + @Override + File mavenFile(String mavenNotation) { + assert mavenFiles.containsKey(mavenNotation) + return mavenFiles.get(mavenNotation) + } + + @Override + MappingsProvider mappingsProvider() { + return mockMappingsProvider + } + + @Override + MinecraftProvider minecraftProvider() { + return mockMinecraftProvider + } + + @Override + File workingDirectory(String name) { + return new File(tempDir, name) + } + + @Override + Logger getLogger() { + return mockLogger + } + } +} diff --git a/src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/LayeredMappingsTestConstants.groovy b/src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/LayeredMappingsTestConstants.groovy new file mode 100644 index 00000000..1827ccd6 --- /dev/null +++ b/src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/LayeredMappingsTestConstants.groovy @@ -0,0 +1,47 @@ +/* + * This file is part of fabric-loom, licensed under the MIT License (MIT). + * + * Copyright (c) 2016, 2017, 2018 FabricMC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package net.fabricmc.loom.test.unit.layeredmappings + +import net.fabricmc.loom.configuration.providers.minecraft.MinecraftVersionMeta + +interface LayeredMappingsTestConstants { + public static final String INTERMEDIARY_1_17_URL = "https://maven.fabricmc.net/net/fabricmc/intermediary/1.17/intermediary-1.17-v2.jar" + public static final String INTERMEDIARY_1_16_5_URL = "https://maven.fabricmc.net/net/fabricmc/intermediary/1.16.5/intermediary-1.16.5-v2.jar" + + public static final Map<String, MinecraftVersionMeta.Download> DOWNLOADS_1_17 = [ + client_mappings:new MinecraftVersionMeta.Download(null, "227d16f520848747a59bef6f490ae19dc290a804", 6431705, "https://launcher.mojang.com/v1/objects/227d16f520848747a59bef6f490ae19dc290a804/client.txt"), + server_mappings:new MinecraftVersionMeta.Download(null, "84d80036e14bc5c7894a4fad9dd9f367d3000334", 4948536, "https://launcher.mojang.com/v1/objects/84d80036e14bc5c7894a4fad9dd9f367d3000334/server.txt") + ] + public static final MinecraftVersionMeta VERSION_META_1_17 = new MinecraftVersionMeta(null, null, null, 0, DOWNLOADS_1_17, null, null, null, null, 0, null, null, null) + + public static final Map<String, MinecraftVersionMeta.Download> DOWNLOADS_1_16_5 = [ + client_mappings:new MinecraftVersionMeta.Download(null, "e3dfb0001e1079a1af72ee21517330edf52e6192", 5746047, "https://launcher.mojang.com/v1/objects/e3dfb0001e1079a1af72ee21517330edf52e6192/client.txt"), + server_mappings:new MinecraftVersionMeta.Download(null, "81d5c793695d8cde63afddb40dde88e3a88132ac", 4400926, "https://launcher.mojang.com/v1/objects/81d5c793695d8cde63afddb40dde88e3a88132ac/server.txt") + ] + public static final MinecraftVersionMeta VERSION_META_1_16_5 = new MinecraftVersionMeta(null, null, null, 0, DOWNLOADS_1_16_5, null, null, null, null, 0, null, null, null) + + public static final String PARCHMENT_NOTATION = "org.parchmentmc.data:parchment-1.16.5:20210608-SNAPSHOT@zip" + public static final String PARCHMENT_URL = "https://ldtteam.jfrog.io/artifactory/parchmentmc-snapshots/org/parchmentmc/data/parchment-1.16.5/20210608-SNAPSHOT/parchment-1.16.5-20210608-SNAPSHOT.zip" +}
\ No newline at end of file diff --git a/src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/MojangMappingLayerTest.groovy b/src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/MojangMappingLayerTest.groovy new file mode 100644 index 00000000..28e058dd --- /dev/null +++ b/src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/MojangMappingLayerTest.groovy @@ -0,0 +1,49 @@ +/* + * This file is part of fabric-loom, licensed under the MIT License (MIT). + * + * Copyright (c) 2016, 2017, 2018 FabricMC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package net.fabricmc.loom.test.unit.layeredmappings + +import net.fabricmc.loom.configuration.providers.mappings.intermediary.IntermediaryMappingsSpec +import net.fabricmc.loom.configuration.providers.mappings.mojmap.MojangMappingsSpec + +class MojangMappingLayerTest extends LayeredMappingsSpecification { + def "Read mojang mappings" () { + setup: + mockMappingsProvider.intermediaryTinyFile() >> extractFileFromZip(downloadFile(INTERMEDIARY_1_17_URL, "intermediary.jar"), "mappings/mappings.tiny") + mockMinecraftProvider.getVersionInfo() >> VERSION_META_1_17 + when: + def mappings = getLayeredMappings( + new IntermediaryMappingsSpec(), + new MojangMappingsSpec() + ) + def tiny = getTiny(mappings) + then: + mappings.srcNamespace == "named" + mappings.dstNamespaces == ["intermediary", "official"] + mappings.classes.size() == 6113 + mappings.classes[0].srcName.hashCode() == 1869546970 // MojMap name, just check the hash + mappings.classes[0].getDstName(0) == "net/minecraft/class_2354" + mappings.classes[0].methods[0].args.size() == 0 // No Args + } +} diff --git a/src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/ParchmentMappingLayerTest.groovy b/src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/ParchmentMappingLayerTest.groovy new file mode 100644 index 00000000..597e17f6 --- /dev/null +++ b/src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/ParchmentMappingLayerTest.groovy @@ -0,0 +1,74 @@ +/* + * This file is part of fabric-loom, licensed under the MIT License (MIT). + * + * Copyright (c) 2016, 2017, 2018 FabricMC + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package net.fabricmc.loom.test.unit.layeredmappings + +import net.fabricmc.loom.configuration.providers.mappings.intermediary.IntermediaryMappingsSpec +import net.fabricmc.loom.configuration.providers.mappings.mojmap.MojangMappingsSpec +import net.fabricmc.loom.configuration.providers.mappings.parchment.ParchmentMappingsSpec +import net.fabricmc.loom.configuration.providers.minecraft.MinecraftVersionMeta + +class ParchmentMappingLayerTest extends LayeredMappingsSpecification { + def "Read parchment mappings" () { + setup: + mockMappingsProvider.intermediaryTinyFile() >> extractFileFromZip(downloadFile(INTERMEDIARY_1_16_5_URL, "intermediary.jar"), "mappings/mappings.tiny") + mockMinecraftProvider.getVersionInfo() >> VERSION_META_1_16_5 + when: + withMavenFile(PARCHMENT_NOTATION, downloadFile(PARCHMENT_URL, "parchment.zip")) + def mappings = getLayeredMappings( + new IntermediaryMappingsSpec(), + new MojangMappingsSpec(), + new ParchmentMappingsSpec(PARCHMENT_NOTATION, false) + ) + def tiny = getTiny(mappings) + then: + mappings.srcNamespace == "named" + mappings.dstNamespaces == ["intermediary", "official"] + mappings.classes.size() == 5747 + mappings.classes[0].srcName.hashCode() == -1112444138 // MojMap name, just check the hash + mappings.classes[0].getDstName(0) == "net/minecraft/class_2573" + mappings.classes[0].methods[0].args[0].srcName == "pStack" + } + + def "Read parchment mappings remove prefix" () { + setup: + mockMappingsProvider.intermediaryTinyFile() >> extractFileFromZip(downloadFile(INTERMEDIARY_1_16_5_URL, "intermediary.jar"), "mappings/mappings.tiny") + mockMinecraftProvider.getVersionInfo() >> VERSION_META_1_16_5 + when: + withMavenFile(PARCHMENT_NOTATION, downloadFile(PARCHMENT_URL, "parchment.zip")) + def mappings = getLayeredMappings( + new IntermediaryMappingsSpec(), + new MojangMappingsSpec(), + new ParchmentMappingsSpec(PARCHMENT_NOTATION, true) + ) + def tiny = getTiny(mappings) + then: + mappings.srcNamespace == "named" + mappings.dstNamespaces == ["intermediary", "official"] + mappings.classes.size() == 5747 + mappings.classes[0].srcName.hashCode() == -1112444138 // MojMap name, just check the hash + mappings.classes[0].getDstName(0) == "net/minecraft/class_2573" + mappings.classes[0].methods[0].args[0].srcName == "stack" + } +} |