Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gbevin committed Jan 22, 2025
1 parent ca7fa0c commit 9362a60
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/test/java/rife/bld/operations/TestJUnitOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import java.io.File;
import java.nio.file.Files;
import java.util.List;
import java.util.Map;
import java.util.function.Function;

import static org.junit.jupiter.api.Assertions.*;
Expand All @@ -25,6 +26,7 @@ void testInstantiation() {
assertTrue(operation.workDirectory().exists());
assertTrue(operation.workDirectory().isDirectory());
assertTrue(operation.workDirectory().canWrite());
assertTrue(operation.environment().isEmpty());
assertEquals("java", operation.javaTool());
assertTrue(operation.javaOptions().isEmpty());
assertTrue(operation.classpath().isEmpty());
Expand All @@ -37,6 +39,7 @@ void testInstantiation() {
@Test
void testPopulation()
throws Exception {
var environment = Map.of("env1", "val1", "env2", "val2", "env3", "val3");
var work_directory = Files.createTempDirectory("test").toFile();
try {
var java_tool = "javatool";
Expand All @@ -53,6 +56,7 @@ void testPopulation()
var operation1 = new JUnitOperation();
operation1
.workDirectory(work_directory)
.environment(environment)
.javaTool(java_tool)
.javaOptions(List.of(test_java_option1, test_java_option2))
.testToolOptions(List.of(test_tool_option1, test_tool_option2))
Expand All @@ -62,6 +66,7 @@ void testPopulation()
.errorProcessor(test_error_consumer);

assertEquals(work_directory, operation1.workDirectory());
assertEquals(environment, operation1.environment());
assertEquals(java_tool, operation1.javaTool());
assertTrue(operation1.javaOptions().contains(test_java_option1));
assertTrue(operation1.javaOptions().contains(test_java_option2));
Expand All @@ -75,6 +80,7 @@ void testPopulation()

var operation2 = new JUnitOperation();
operation2.workDirectory(work_directory);
operation2.environment(environment);
operation2.javaTool(java_tool);
operation2.javaOptions().add(test_java_option1);
operation2.javaOptions().add(test_java_option2);
Expand All @@ -87,6 +93,7 @@ void testPopulation()
operation2.errorProcessor(test_error_consumer);

assertEquals(work_directory, operation2.workDirectory());
assertEquals(environment, operation2.environment());
assertEquals(java_tool, operation2.javaTool());
assertTrue(operation2.javaOptions().contains(test_java_option1));
assertTrue(operation2.javaOptions().contains(test_java_option2));
Expand Down Expand Up @@ -124,7 +131,7 @@ void testExecute()
public class Source1 {
public final String name_;
public Source1() {
name_ = "source1";
name_ = System.getenv("execute_name");
}
public static void main(String[] arguments)
Expand Down Expand Up @@ -156,6 +163,7 @@ public static void main(String[] arguments)

var output = new StringBuilder();
var test_operation = new JUnitOperation()
.environment(Map.of("execute_name", "source1"))
.mainClass("Source2")
.classpath(List.of(build_main.getAbsolutePath(), build_test.getAbsolutePath()))
.outputProcessor(s -> {
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/rife/bld/operations/TestRunOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void testExecuteModule()
public class Source1 {
public final String name_;
public Source1() {
name_ = "source1";
name_ = System.getenv("execute_name");
}
public static void main(String[] arguments)
Expand Down Expand Up @@ -222,6 +222,7 @@ public static void main(String[] arguments)

var output = new StringBuilder();
var run_operation = new RunOperation()
.environment(Map.of("execute_name", "source1"))
.module("pkg")
.modulePath(new File(destination_dir, destination_name).getAbsolutePath())
.outputProcessor(s -> {
Expand Down

0 comments on commit 9362a60

Please sign in to comment.