mirror of
https://github.com/ethauvin/bld.git
synced 2025-04-25 08:17:11 -07:00
Added run operation test
This commit is contained in:
parent
fd1429f2d3
commit
2b827a9a6f
1 changed files with 39 additions and 1 deletions
|
@ -191,9 +191,9 @@ public class TestRunOperation {
|
||||||
|
|
||||||
FileUtils.writeString("""
|
FileUtils.writeString("""
|
||||||
module pkg {
|
module pkg {
|
||||||
requires java.desktop;
|
|
||||||
}
|
}
|
||||||
""", source_file2);
|
""", source_file2);
|
||||||
|
|
||||||
var build_main = new File(tmp, "buildMain");
|
var build_main = new File(tmp, "buildMain");
|
||||||
|
|
||||||
var compile_operation = new CompileOperation()
|
var compile_operation = new CompileOperation()
|
||||||
|
@ -257,4 +257,42 @@ public class TestRunOperation {
|
||||||
FileUtils.deleteDirectory(tmp);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue