diff options
author | shedaniel <daniel@shedaniel.me> | 2021-09-12 03:06:21 +0800 |
---|---|---|
committer | shedaniel <daniel@shedaniel.me> | 2021-09-12 03:06:21 +0800 |
commit | aad95823844eb8319d3b25b6c8da34a715061c7a (patch) | |
tree | 37901a34daea849a14d7e0c38f3a2d4e1f32d678 /src/test/groovy/net/fabricmc/loom | |
parent | 43dda4a6c8336180478b66b8c821e1535f65d970 (diff) | |
download | architectury-loom-aad95823844eb8319d3b25b6c8da34a715061c7a.tar.gz architectury-loom-aad95823844eb8319d3b25b6c8da34a715061c7a.tar.bz2 architectury-loom-aad95823844eb8319d3b25b6c8da34a715061c7a.zip |
Fix some tests
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'src/test/groovy/net/fabricmc/loom')
5 files changed, 16 insertions, 61 deletions
diff --git a/src/test/groovy/net/fabricmc/loom/test/integration/FabricAPITest.groovy b/src/test/groovy/net/fabricmc/loom/test/integration/FabricAPITest.groovy index cbefa2e0..a477d456 100644 --- a/src/test/groovy/net/fabricmc/loom/test/integration/FabricAPITest.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/integration/FabricAPITest.groovy @@ -51,6 +51,7 @@ class FabricAPITest extends Specification implements GradleProjectTestTrait { // Set the version to something constant gradle.buildGradle.text = gradle.buildGradle.text.replace('Globals.baseVersion + "+" + (ENV.GITHUB_RUN_NUMBER ? "" : "local-") + getBranch()', "\"$API_VERSION\"") + .replace('id "fabric-loom"', 'id "dev.architectury.loom"') def server = ServerRunner.create(gradle.projectDir, "1.17.1") .withMod(gradle.getOutputFile("fabric-api-${API_VERSION}.jar")) diff --git a/src/test/groovy/net/fabricmc/loom/test/integration/forge/Aw2AtTest.groovy b/src/test/groovy/net/fabricmc/loom/test/integration/forge/Aw2AtTest.groovy index 41993e61..734616f1 100644 --- a/src/test/groovy/net/fabricmc/loom/test/integration/forge/Aw2AtTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/integration/forge/Aw2AtTest.groovy @@ -24,26 +24,26 @@ package net.fabricmc.loom.test.integration.forge -import net.fabricmc.loom.test.util.ArchiveAssertionsTrait import net.fabricmc.loom.test.util.GradleProjectTestTrait import spock.lang.Specification +import static net.fabricmc.loom.test.LoomTestConstants.* import static org.gradle.testkit.runner.TaskOutcome.SUCCESS -class Aw2AtTest extends Specification implements GradleProjectTestTrait, ArchiveAssertionsTrait { +class Aw2AtTest extends Specification implements GradleProjectTestTrait { def build() { setup: - def gradle = gradleProject(project: "forge/aw2At", version: version) + def gradle = gradleProject(project: "forge/aw2At", version: DEFAULT_GRADLE) when: def result = gradle.run(task: "build") then: result.task(":build").outcome == SUCCESS - getArchiveEntry("fabric-example-mod-1.0.0.jar", "META-INF/accesstransformer.cfg") == expected().replaceAll('\r', '') + gradle.getOutputZipEntry("fabric-example-mod-1.0.0.jar", "META-INF/accesstransformer.cfg") == expected(gradle).replaceAll('\r', '') } String expected() { - return new File(testProjectDir, "expected.accesstransformer.cfg").text + return new File(gradle.projectDir, "expected.accesstransformer.cfg").text } } diff --git a/src/test/groovy/net/fabricmc/loom/test/integration/forge/LegacyAw2AtTest.groovy b/src/test/groovy/net/fabricmc/loom/test/integration/forge/LegacyAw2AtTest.groovy index 4c40846b..ab5f2c0f 100644 --- a/src/test/groovy/net/fabricmc/loom/test/integration/forge/LegacyAw2AtTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/integration/forge/LegacyAw2AtTest.groovy @@ -24,26 +24,26 @@ package net.fabricmc.loom.test.integration.forge -import net.fabricmc.loom.test.util.ArchiveAssertionsTrait import net.fabricmc.loom.test.util.GradleProjectTestTrait import spock.lang.Specification +import static net.fabricmc.loom.test.LoomTestConstants.* import static org.gradle.testkit.runner.TaskOutcome.SUCCESS -class LegacyAw2AtTest extends Specification implements GradleProjectTestTrait, ArchiveAssertionsTrait { +class LegacyAw2AtTest extends Specification implements GradleProjectTestTrait { def build() { setup: - def gradle = gradleProject(project: "forge/legacyAw2At", version: version) + def gradle = gradleProject(project: "forge/legacyAw2At", version: DEFAULT_GRADLE) when: def result = gradle.run(task: "build") then: result.task(":build").outcome == SUCCESS - getArchiveEntry("fabric-example-mod-1.0.0.jar", "META-INF/accesstransformer.cfg") == expected().replaceAll('\r', '') + gradle.getOutputZipEntry("fabric-example-mod-1.0.0.jar", "META-INF/accesstransformer.cfg") == expected(gradle).replaceAll('\r', '') } - String expected() { - return new File(testProjectDir, "expected.accesstransformer.cfg").text + String expected(gradle) { + return new File(gradle.projectDir, "expected.accesstransformer.cfg").text } } 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 index f0537a2f..cfcb8a2e 100644 --- a/src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/LayeredMappingSpecBuilderTest.groovy +++ b/src/test/groovy/net/fabricmc/loom/test/unit/layeredmappings/LayeredMappingSpecBuilderTest.groovy @@ -40,7 +40,7 @@ class LayeredMappingSpecBuilderTest extends LayeredMappingsSpecification { } def layers = spec.layers() then: - spec.getVersion(mappingContext) == "layered+hash.2198.minecraft.null" + spec.getVersion() == "layered+hash.2198" layers.size() == 2 layers[0].class == IntermediaryMappingsSpec layers[1].class == MojangMappingsSpec @@ -55,7 +55,7 @@ class LayeredMappingSpecBuilderTest extends LayeredMappingsSpecification { def layers = spec.layers() def parchment = layers[2] as ParchmentMappingsSpec then: - spec.getVersion(mappingContext) == "layered+hash.863752751.minecraft.null" + spec.getVersion() == "layered+hash.863752751" layers.size() == 3 layers[0].class == IntermediaryMappingsSpec layers[1].class == MojangMappingsSpec @@ -75,7 +75,7 @@ class LayeredMappingSpecBuilderTest extends LayeredMappingsSpecification { def layers = spec.layers() def parchment = layers[2] as ParchmentMappingsSpec then: - spec.getVersion(mappingContext) == "layered+hash.863752757.minecraft.null" + spec.getVersion() == "layered+hash.863752757" layers.size() == 3 layers[0].class == IntermediaryMappingsSpec layers[1].class == MojangMappingsSpec @@ -95,7 +95,7 @@ class LayeredMappingSpecBuilderTest extends LayeredMappingsSpecification { def layers = spec.layers() def parchment = layers[2] as ParchmentMappingsSpec then: - spec.getVersion(mappingContext) == "layered+hash.1144427140.minecraft.null" + spec.getVersion() == "layered+hash.1144427140" layers.size() == 3 layers[0].class == IntermediaryMappingsSpec layers[1].class == MojangMappingsSpec diff --git a/src/test/groovy/net/fabricmc/loom/test/util/ArchiveAssertionsTrait.groovy b/src/test/groovy/net/fabricmc/loom/test/util/ArchiveAssertionsTrait.groovy deleted file mode 100644 index 4ba008c1..00000000 --- a/src/test/groovy/net/fabricmc/loom/test/util/ArchiveAssertionsTrait.groovy +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of fabric-loom, licensed under the MIT License (MIT). - * - * Copyright (c) 2016-2021 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.util - -import org.zeroturnaround.zip.ZipUtil - -trait ArchiveAssertionsTrait { - String getArchiveEntry(String name, String entry, String project = "") { - def file = getOutputFile(name, project) - - def bytes = ZipUtil.unpackEntry(file, entry) - - if (bytes == null) { - throw new FileNotFoundException("Could not find ${entry} in ${name}") - } - - new String(bytes as byte[]) - } - - boolean hasArchiveEntry(String name, String entry, String project = "") { - def file = getOutputFile(name, project) - ZipUtil.unpackEntry(file, entry) != null - } -} |