Skip to content

Commit

Permalink
Added run operation test
Browse files Browse the repository at this point in the history
  • Loading branch information
gbevin committed Aug 26, 2024
1 parent fd1429f commit 2b827a9
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion src/test/java/rife/bld/operations/TestRunOperation.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ public static void main(String[] arguments)

FileUtils.writeString("""
module pkg {
requires java.desktop;
}
""", source_file2);

var build_main = new File(tmp, "buildMain");

var compile_operation = new CompileOperation()
Expand Down Expand Up @@ -257,4 +257,42 @@ void testFromProject()
FileUtils.deleteDirectory(tmp);
}
}

@Test
void testFromProjectModule()
throws Exception {
var tmp = Files.createTempDirectory("test").toFile();
try {
var create_operation = new CreateAppOperation()
.workDirectory(tmp)
.packageName("com.example")
.projectName("myapp")
.downloadDependencies(true);
create_operation.execute();

var source_module_info = new File(create_operation.project().srcMainJavaDirectory(), "module-info.java");
FileUtils.writeString("""
module com.example {
}
""", source_module_info);

new CompileOperation()
.fromProject(create_operation.project()).execute();

var check_result = new StringBuilder();
new RunOperation()
.fromProject(create_operation.project())
.modulePath(create_operation.project().buildMainDirectory().getAbsolutePath())
.module("com.example")
.outputProcessor(s -> {
check_result.append(s);
return true;
})
.execute();
assertEquals("Hello World!", check_result.toString());

} finally {
FileUtils.deleteDirectory(tmp);
}
}
}

0 comments on commit 2b827a9

Please sign in to comment.