diff options
author | shedaniel <daniel@shedaniel.me> | 2021-09-11 04:54:58 +0800 |
---|---|---|
committer | shedaniel <daniel@shedaniel.me> | 2021-09-11 04:54:58 +0800 |
commit | aa4f1b107f7e554f751b588d1cccc935a8efbf63 (patch) | |
tree | a88fe782b3c7361cdb1c0aded0ff8828b0d8745e /src/test/groovy/net/fabricmc/loom | |
parent | d06081d560f3f75e7a9e558828a2ff72cdcde6d2 (diff) | |
download | architectury-loom-aa4f1b107f7e554f751b588d1cccc935a8efbf63.tar.gz architectury-loom-aa4f1b107f7e554f751b588d1cccc935a8efbf63.tar.bz2 architectury-loom-aa4f1b107f7e554f751b588d1cccc935a8efbf63.zip |
Fix merge conflicts
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'src/test/groovy/net/fabricmc/loom')
3 files changed, 66 insertions, 22 deletions
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 fc7c016d..41993e61 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 @@ -25,23 +25,22 @@ package net.fabricmc.loom.test.integration.forge import net.fabricmc.loom.test.util.ArchiveAssertionsTrait -import net.fabricmc.loom.test.util.ProjectTestTrait +import net.fabricmc.loom.test.util.GradleProjectTestTrait import spock.lang.Specification import static org.gradle.testkit.runner.TaskOutcome.SUCCESS -class Aw2AtTest extends Specification implements ProjectTestTrait, ArchiveAssertionsTrait { - @Override - String name() { - "forge/aw2At" - } - +class Aw2AtTest extends Specification implements GradleProjectTestTrait, ArchiveAssertionsTrait { def build() { - when: - def result = create("build", DEFAULT_GRADLE) - then: - result.task(":build").outcome == SUCCESS - getArchiveEntry("fabric-example-mod-1.0.0.jar", "META-INF/accesstransformer.cfg") == expected().replaceAll('\r', '') + setup: + def gradle = gradleProject(project: "forge/aw2At", version: version) + + 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', '') } String expected() { 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 bdd9a5aa..4c40846b 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 @@ -25,23 +25,22 @@ package net.fabricmc.loom.test.integration.forge import net.fabricmc.loom.test.util.ArchiveAssertionsTrait -import net.fabricmc.loom.test.util.ProjectTestTrait +import net.fabricmc.loom.test.util.GradleProjectTestTrait import spock.lang.Specification import static org.gradle.testkit.runner.TaskOutcome.SUCCESS -class LegacyAw2AtTest extends Specification implements ProjectTestTrait, ArchiveAssertionsTrait { - @Override - String name() { - "forge/legacyAw2At" - } - +class LegacyAw2AtTest extends Specification implements GradleProjectTestTrait, ArchiveAssertionsTrait { def build() { + setup: + def gradle = gradleProject(project: "forge/legacyAw2At", version: version) + when: - def result = create("build", DEFAULT_GRADLE) + 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', '') + result.task(":build").outcome == SUCCESS + getArchiveEntry("fabric-example-mod-1.0.0.jar", "META-INF/accesstransformer.cfg") == expected().replaceAll('\r', '') } String expected() { diff --git a/src/test/groovy/net/fabricmc/loom/test/util/ArchiveAssertionsTrait.groovy b/src/test/groovy/net/fabricmc/loom/test/util/ArchiveAssertionsTrait.groovy new file mode 100644 index 00000000..4ba008c1 --- /dev/null +++ b/src/test/groovy/net/fabricmc/loom/test/util/ArchiveAssertionsTrait.groovy @@ -0,0 +1,46 @@ +/* + * 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 + } +} |