diff options
| author | Thibault Gagnaux <tgagnaux@gmail.com> | 2022-02-09 21:37:28 +0100 |
|---|---|---|
| committer | Thibault Gagnaux <tgagnaux@gmail.com> | 2022-02-09 21:37:28 +0100 |
| commit | 0aa4dd065ee78f9acc88b39625cc4a9b47f6c944 (patch) | |
| tree | 11cc097399a8304fa76260493347d384e987f669 /src/functionalTest/java/ch/fhnw/thga/gradleplugins/SetupFregeTaskFunctionalTest.java | |
| parent | 43ee2210fa07f42a13ac6879ae167db6d2729742 (diff) | |
| download | frege-gradle-plugin-0aa4dd065ee78f9acc88b39625cc4a9b47f6c944.tar.gz frege-gradle-plugin-0aa4dd065ee78f9acc88b39625cc4a9b47f6c944.tar.bz2 frege-gradle-plugin-0aa4dd065ee78f9acc88b39625cc4a9b47f6c944.zip | |
refactor: continues with staged builder refactoring
Diffstat (limited to 'src/functionalTest/java/ch/fhnw/thga/gradleplugins/SetupFregeTaskFunctionalTest.java')
| -rw-r--r-- | src/functionalTest/java/ch/fhnw/thga/gradleplugins/SetupFregeTaskFunctionalTest.java | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/src/functionalTest/java/ch/fhnw/thga/gradleplugins/SetupFregeTaskFunctionalTest.java b/src/functionalTest/java/ch/fhnw/thga/gradleplugins/SetupFregeTaskFunctionalTest.java new file mode 100644 index 0000000..825c555 --- /dev/null +++ b/src/functionalTest/java/ch/fhnw/thga/gradleplugins/SetupFregeTaskFunctionalTest.java @@ -0,0 +1,102 @@ +package ch.fhnw.thga.gradleplugins; + +import static ch.fhnw.thga.gradleplugins.FregeExtension.DEFAULT_RELATIVE_COMPILER_DOWNLOAD_DIR; +import static ch.fhnw.thga.gradleplugins.FregePlugin.SETUP_FREGE_TASK_NAME; +import static ch.fhnw.thga.gradleplugins.SharedFunctionalTestLogic.createFregeSection; +import static ch.fhnw.thga.gradleplugins.SharedFunctionalTestLogic.runGradleTask; +import static org.gradle.testkit.runner.TaskOutcome.SUCCESS; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.File; +import java.nio.file.Paths; + +import org.gradle.api.Project; +import org.gradle.testkit.runner.BuildResult; +import org.junit.jupiter.api.DisplayNameGenerator; +import org.junit.jupiter.api.IndicativeSentencesGeneration; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import ch.fhnw.thga.gradleplugins.fregeproject.FregeProjectBuilder; +import ch.fhnw.thga.gradleplugins.fregeproject.ProjectRoot; + +class SetupFregeTaskFunctionalTest +{ + private static FregeDTOBuilder FREGE_BUILDER = FregeDTOBuilder.builder(); + private static ProjectRoot FREGE_PROJECT_BUILDER = FregeProjectBuilder.builder(); + + @Nested + @IndicativeSentencesGeneration(separator = " -> ", generator = DisplayNameGenerator.ReplaceUnderscores.class) + class Setup_frege_task_works { + @Test + void given_minimal_build_file_config(@TempDir File testProjectDir) throws Exception + { + String minimalBuildFileConfig = createFregeSection( + FREGE_BUILDER + .version("'3.25.84'") + .release("'3.25alpha'") + .build() + ); + + Project project = FREGE_PROJECT_BUILDER + .projectRoot(testProjectDir) + .buildFile(minimalBuildFileConfig) + .useLocalFregeCompiler(false) + .build(); + + BuildResult result = runGradleTask(testProjectDir, SETUP_FREGE_TASK_NAME); + + assertTrue( + project + .getTasks() + .getByName(SETUP_FREGE_TASK_NAME) instanceof SetupFregeTask + ); + assertEquals(SUCCESS, result.task(":" + SETUP_FREGE_TASK_NAME).getOutcome()); + assertTrue( + testProjectDir + .toPath() + .resolve(Paths.get(DEFAULT_RELATIVE_COMPILER_DOWNLOAD_DIR, "frege3.25.84.jar")) + .toFile() + .exists() + ); + } + + @Test + void given_custom_frege_compiler_download_directory_in_build_file_config( + @TempDir File testProjectDir) + throws Exception + { + String buildFileConfigWithCustomDownloadDir = createFregeSection( + FREGE_BUILDER + .version("'3.25.84'") + .release("'3.25alpha'") + .compilerDownloadDir("layout.projectDirectory.dir('dist')") + .build() + ); + + Project project = FREGE_PROJECT_BUILDER + .projectRoot(testProjectDir) + .buildFile(buildFileConfigWithCustomDownloadDir) + .useLocalFregeCompiler(false) + .build(); + + BuildResult result = runGradleTask(testProjectDir, SETUP_FREGE_TASK_NAME); + + assertTrue( + project + .getTasks() + .getByName(SETUP_FREGE_TASK_NAME) instanceof SetupFregeTask + ); + assertEquals(SUCCESS, result.task(":" + SETUP_FREGE_TASK_NAME).getOutcome()); + assertTrue( + testProjectDir + .toPath() + .resolve(Paths.get("dist", "frege3.25.84.jar")) + .toFile() + .exists() + ); + } + } +}
\ No newline at end of file |
