aboutsummaryrefslogtreecommitdiff
path: root/src/functionalTest/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/functionalTest/java')
-rw-r--r--src/functionalTest/java/ch/fhnw/thga/gradleplugins/CompileFregeTaskFunctionalTest.java16
-rw-r--r--src/functionalTest/java/ch/fhnw/thga/gradleplugins/ReplFregeTaskFunctionalTest.java80
-rw-r--r--src/functionalTest/java/ch/fhnw/thga/gradleplugins/SharedFunctionalTestLogic.java28
3 files changed, 109 insertions, 15 deletions
diff --git a/src/functionalTest/java/ch/fhnw/thga/gradleplugins/CompileFregeTaskFunctionalTest.java b/src/functionalTest/java/ch/fhnw/thga/gradleplugins/CompileFregeTaskFunctionalTest.java
index 31e6d05..90a459c 100644
--- a/src/functionalTest/java/ch/fhnw/thga/gradleplugins/CompileFregeTaskFunctionalTest.java
+++ b/src/functionalTest/java/ch/fhnw/thga/gradleplugins/CompileFregeTaskFunctionalTest.java
@@ -8,6 +8,7 @@ import static ch.fhnw.thga.gradleplugins.SharedFunctionalTestLogic.runGradleTask
import static ch.fhnw.thga.gradleplugins.SharedFunctionalTestLogic.NEW_LINE;
import static ch.fhnw.thga.gradleplugins.SharedFunctionalTestLogic.MINIMAL_BUILD_FILE_CONFIG;
import static ch.fhnw.thga.gradleplugins.SharedFunctionalTestLogic.COMPLETION_FR;
+import static ch.fhnw.thga.gradleplugins.SharedFunctionalTestLogic.assertFileExists;
import static org.gradle.testkit.runner.TaskOutcome.FAILED;
import static org.gradle.testkit.runner.TaskOutcome.FROM_CACHE;
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS;
@@ -31,17 +32,6 @@ import ch.fhnw.thga.gradleplugins.fregeproject.FregeSourceFile;
public class CompileFregeTaskFunctionalTest
{
- private static final boolean assertFileExists(
- File testProjectDir,
- String relativeFilePath)
- {
- return testProjectDir
- .toPath()
- .resolve(relativeFilePath)
- .toFile()
- .exists();
- }
-
@Nested
@IndicativeSentencesGeneration(
separator = " -> ",
@@ -159,11 +149,11 @@ public class CompileFregeTaskFunctionalTest
);
assertFileExists(
testProjectDir,
- "build/classes/main/frege/ch/fhnw/thga/Completion.java"
+ "build/frege/ch/fhnw/thga/Completion.java"
);
assertFileExists(
testProjectDir,
- "build/classes/main/frege/ch/fhnw/thga/Completion.class"
+ "build/frege/ch/fhnw/thga/Completion.class"
);
}
@Test
diff --git a/src/functionalTest/java/ch/fhnw/thga/gradleplugins/ReplFregeTaskFunctionalTest.java b/src/functionalTest/java/ch/fhnw/thga/gradleplugins/ReplFregeTaskFunctionalTest.java
index 979d1d4..52bfbff 100644
--- a/src/functionalTest/java/ch/fhnw/thga/gradleplugins/ReplFregeTaskFunctionalTest.java
+++ b/src/functionalTest/java/ch/fhnw/thga/gradleplugins/ReplFregeTaskFunctionalTest.java
@@ -1,15 +1,18 @@
package ch.fhnw.thga.gradleplugins;
+import static ch.fhnw.thga.gradleplugins.FregeExtension.DEFAULT_RELATIVE_SOURCE_DIR;
import static ch.fhnw.thga.gradleplugins.FregePlugin.REPL_FREGE_TASK_NAME;
import static ch.fhnw.thga.gradleplugins.SharedFunctionalTestLogic.COMPLETION_FR;
import static ch.fhnw.thga.gradleplugins.SharedFunctionalTestLogic.MINIMAL_BUILD_FILE_CONFIG;
+import static ch.fhnw.thga.gradleplugins.SharedFunctionalTestLogic.NEW_LINE;
+import static ch.fhnw.thga.gradleplugins.SharedFunctionalTestLogic.assertFileDoesNotExist;
+import static ch.fhnw.thga.gradleplugins.SharedFunctionalTestLogic.assertFileExists;
import static ch.fhnw.thga.gradleplugins.SharedFunctionalTestLogic.createFregeSection;
import static ch.fhnw.thga.gradleplugins.SharedFunctionalTestLogic.runAndFailGradleTask;
import static ch.fhnw.thga.gradleplugins.SharedFunctionalTestLogic.runGradleTask;
import static org.gradle.testkit.runner.TaskOutcome.FAILED;
import static org.gradle.testkit.runner.TaskOutcome.SUCCESS;
import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
@@ -24,6 +27,7 @@ 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.FregeSourceFile;
public class ReplFregeTaskFunctionalTest
{
@@ -64,7 +68,79 @@ public class ReplFregeTaskFunctionalTest
result.task(":" + REPL_FREGE_TASK_NAME).getOutcome());
assertTrue(result.getOutput().contains("java -cp"));
assertTrue(result.getOutput().contains("frege3.25.84.jar"));
- assertFalse(result.getOutput().contains("Completion.class"));
+ assertTrue(result.getOutput().contains(COMPLETION_FR.getFregeModulePath()));
+ assertFileDoesNotExist(
+ testProjectDir,
+ "build/classes/main/frege/ch/fhnw/thga/Completion.java"
+ );
+ assertFileDoesNotExist(
+ testProjectDir,
+ "build/classes/main/frege/ch/fhnw/thga/Completion.class"
+ );
+ }
+
+ @Test
+ void given_dependent_frege_files_with_command_line_repl_module_option(
+ @TempDir File testProjectDir)
+ throws Exception
+ {
+ String frobCode = String.join(
+ NEW_LINE,
+ "module ch.fhnw.thga.Frob where",
+ NEW_LINE,
+ NEW_LINE,
+ "import ch.fhnw.thga.Completion (complete)",
+ NEW_LINE,
+ "frob i = complete $ i + i",
+ NEW_LINE
+ );
+ FregeSourceFile frob_FR = new FregeSourceFile(
+ String.format(
+ "%s/%s",
+ DEFAULT_RELATIVE_SOURCE_DIR,
+ "ch/fhnw/thga/Frob.fr"
+ ),
+ frobCode);
+ Project project = FregeProjectBuilder
+ .builder()
+ .projectRoot(testProjectDir)
+ .buildFile(MINIMAL_BUILD_FILE_CONFIG)
+ .fregeSourceFiles(() -> Stream.of(COMPLETION_FR, frob_FR))
+ .build();
+
+ BuildResult result = runGradleTask(
+ testProjectDir,
+ REPL_FREGE_TASK_NAME,
+ "--replModule=ch.fhnw.thga.Frob"
+ );
+
+ assertTrue(
+ project
+ .getTasks()
+ .getByName(REPL_FREGE_TASK_NAME)
+ instanceof ReplFregeTask);
+ assertEquals(
+ SUCCESS,
+ result.task(":" + REPL_FREGE_TASK_NAME).getOutcome());
+ assertTrue(result.getOutput().contains("java -cp"));
+ assertTrue(result.getOutput().contains("frege3.25.84.jar"));
+ assertTrue(result.getOutput().contains(frob_FR.getFregeModulePath()));
+ assertFileExists(
+ testProjectDir,
+ "build/classes/main/frege/ch/fhnw/thga/Completion.java"
+ );
+ assertFileExists(
+ testProjectDir,
+ "build/classes/main/frege/ch/fhnw/thga/Completion.class"
+ );
+ assertFileDoesNotExist(
+ testProjectDir,
+ "build/classes/main/frege/ch/fhnw/thga/Frob.java"
+ );
+ assertFileDoesNotExist(
+ testProjectDir,
+ "build/classes/main/frege/ch/fhnw/thga/Frob.class"
+ );
}
}
diff --git a/src/functionalTest/java/ch/fhnw/thga/gradleplugins/SharedFunctionalTestLogic.java b/src/functionalTest/java/ch/fhnw/thga/gradleplugins/SharedFunctionalTestLogic.java
index 51fa256..f935b28 100644
--- a/src/functionalTest/java/ch/fhnw/thga/gradleplugins/SharedFunctionalTestLogic.java
+++ b/src/functionalTest/java/ch/fhnw/thga/gradleplugins/SharedFunctionalTestLogic.java
@@ -3,6 +3,8 @@ package ch.fhnw.thga.gradleplugins;
import static ch.fhnw.thga.gradleplugins.FregePlugin.FREGE_EXTENSION_NAME;
import static ch.fhnw.thga.gradleplugins.FregePlugin.FREGE_PLUGIN_ID;
import static ch.fhnw.thga.gradleplugins.GradleBuildFileConversionTest.createPluginsSection;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static ch.fhnw.thga.gradleplugins.FregeExtension.DEFAULT_RELATIVE_SOURCE_DIR;
import java.io.BufferedWriter;
@@ -44,6 +46,32 @@ public class SharedFunctionalTestLogic
NEW_LINE
)
);
+
+ public static final boolean fileExists(
+ File testProjectDir,
+ String relativeFilePath)
+ {
+ return testProjectDir
+ .toPath()
+ .resolve(relativeFilePath)
+ .toFile()
+ .exists();
+ }
+
+ public static final void assertFileExists(
+ File testProjectDir,
+ String relativeFilePath)
+ {
+ assertTrue(fileExists(testProjectDir, relativeFilePath));
+ }
+
+
+ public static final void assertFileDoesNotExist(
+ File testProjectDir,
+ String relativeFilePath)
+ {
+ assertFalse(fileExists(testProjectDir, relativeFilePath));
+ }
static String createFregeSection(FregeDTO fregeDTO)
{