mirror of
https://github.com/ethauvin/bld.git
synced 2025-04-26 08:37:11 -07:00
Fixed handling of @filename in all tools
This commit is contained in:
parent
0ad964ea4d
commit
002844861b
11 changed files with 297 additions and 188 deletions
|
@ -15,24 +15,7 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||
|
||||
public class TestJlinkOperation {
|
||||
@Test
|
||||
void testNoArguments() {
|
||||
var jlink = new JlinkOperation();
|
||||
assertThrows(ExitStatusException.class, jlink::execute);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDisablePlugin() {
|
||||
var jlink = new JlinkOperation()
|
||||
.disablePlugin("vm")
|
||||
.disablePlugin("system-modules")
|
||||
.listPlugins();
|
||||
assertDoesNotThrow(jlink::execute);
|
||||
|
||||
assertTrue(jlink.toolArgs().containsAll(List.of("vm", "system-modules")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOptions() {
|
||||
void testArguments() {
|
||||
var args = new HashMap<String, String>();
|
||||
args.put("--add-modules", "module-1,module-2");
|
||||
args.put("--bind-services", null);
|
||||
|
@ -78,9 +61,40 @@ public class TestJlinkOperation {
|
|||
assertEquals("name-2=module-2", options.get("--launcher"), "incorrect launcher");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testDisablePlugin() {
|
||||
var jlink = new JlinkOperation()
|
||||
.disablePlugin("vm")
|
||||
.disablePlugin("system-modules")
|
||||
.listPlugins();
|
||||
assertDoesNotThrow(jlink::execute);
|
||||
|
||||
assertTrue(jlink.toolArgs().containsAll(List.of("vm", "system-modules")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void testHelp() {
|
||||
var jlink = new JlinkOperation().addArgs("--help");
|
||||
assertDoesNotThrow(jlink::execute);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNoArguments() {
|
||||
var jlink = new JlinkOperation();
|
||||
assertTrue(jlink.jlinkOptions().isEmpty(), "jlink options not empty");
|
||||
assertTrue(jlink.options().isEmpty(), "options not empty");
|
||||
assertThrows(ExitStatusException.class, jlink::execute);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOptions() {
|
||||
var jlink = new JlinkOperation().options("src/test/resources/options_verbose.txt");
|
||||
assertDoesNotThrow(jlink::execute);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testVersion() {
|
||||
var jlink = new JlinkOperation().addArgs("--version");
|
||||
var jlink = new JlinkOperation().addArgs("--verbose", "--version");
|
||||
assertDoesNotThrow(jlink::execute);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,13 +16,7 @@ import static org.junit.jupiter.api.Assertions.*;
|
|||
|
||||
public class TestJmodOperation {
|
||||
@Test
|
||||
void testNoArguments() {
|
||||
var jmod = new JmodOperation();
|
||||
assertThrows(ExitStatusException.class, jmod::execute);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOptions() {
|
||||
void testArguments() {
|
||||
var args = new HashMap<String, String>();
|
||||
args.put("--class-path", "classpath");
|
||||
args.put("--cmds", "cmds");
|
||||
|
@ -43,7 +37,6 @@ public class TestJmodOperation {
|
|||
args.put("--module-version", "module-version");
|
||||
args.put("--target-platform", "target-platform");
|
||||
args.put("--warn-if-resolved", "deprecated");
|
||||
args.put("@filename", null);
|
||||
|
||||
var options = new JmodOptions()
|
||||
.classpath(args.get("--class-path"))
|
||||
|
@ -56,7 +49,6 @@ public class TestJmodOperation {
|
|||
.dryRun(true)
|
||||
.exclude(new JmodOptions.FilePattern(JmodOptions.FilePatternType.GLOB, "glob"),
|
||||
new JmodOptions.FilePattern(JmodOptions.FilePatternType.REGEX, "regex"))
|
||||
.filename("filename")
|
||||
.hashModules(args.get("--hash-modules"))
|
||||
.headerFiles(args.get("--header-files"))
|
||||
.legalNotices(args.get("--legal-notices"))
|
||||
|
@ -76,6 +68,29 @@ public class TestJmodOperation {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testHelp() {
|
||||
var jmod = new JmodOperation()
|
||||
.operationMode(JmodOperation.OperationMode.HASH)
|
||||
.jmodFile("foo")
|
||||
.addArgs("--help-extra");
|
||||
assertDoesNotThrow(jmod::execute);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNoArguments() {
|
||||
var jmod = new JmodOperation();
|
||||
assertTrue(jmod.options().isEmpty(), "options not empty");
|
||||
assertTrue(jmod.jmodOptions().isEmpty(), "jmod options not empty");
|
||||
assertThrows(ExitStatusException.class, jmod::execute);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOptions() {
|
||||
var jpackage = new JpackageOperation().options("src/test/resources/options_version.txt");
|
||||
assertDoesNotThrow(jpackage::execute);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testVersion() {
|
||||
var jmod = new JmodOperation()
|
||||
|
|
|
@ -15,44 +15,9 @@ import java.util.HashMap;
|
|||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class TestJpackageOperation {
|
||||
@Test
|
||||
void testCreatePackage() throws Exception {
|
||||
var tmpdir = Files.createTempDirectory("bld-jpackage-test").toFile();
|
||||
tmpdir.deleteOnExit();
|
||||
|
||||
var options = new JpackageOptions()
|
||||
.input("lib/bld")
|
||||
.name("bld")
|
||||
.mainJar("bld-wrapper.jar")
|
||||
.javaOptions("--enable-preview")
|
||||
.dest(tmpdir.getAbsolutePath())
|
||||
.verbose(true);
|
||||
|
||||
var os = System.getProperty("os.version");
|
||||
if (os.endsWith("MANJARO")) {
|
||||
options.type(JpackageOptions.PackageType.DEB);
|
||||
}
|
||||
|
||||
var jpackage = new JpackageOperation().jpackageOptions(options);
|
||||
jpackage.execute();
|
||||
|
||||
var files = tmpdir.listFiles();
|
||||
assertNotNull(files, "files should not be null");
|
||||
assertTrue(files.length > 0, "No files found");
|
||||
|
||||
assertTrue(files[0].getName().matches("bld.*\\.[A-Za-z]{3}"), "Package not found");
|
||||
|
||||
FileUtils.deleteDirectory(tmpdir);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNoArguments() {
|
||||
var jpackage = new JpackageOperation();
|
||||
assertThrows(ExitStatusException.class, jpackage::execute);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOptions() {
|
||||
void testArguments() {
|
||||
var args = new HashMap<String, String>();
|
||||
args.put("--about-url", "about-url");
|
||||
args.put("--add-launcher", "name=path");
|
||||
|
@ -95,7 +60,7 @@ public class TestJpackageOperation {
|
|||
args.put("--main-class", "main-class");
|
||||
args.put("--main-jar", "main-jar");
|
||||
args.put("--module", "module");
|
||||
args.put("--module-path", "module-path-1,module-path-2");
|
||||
args.put("--module-path", "module-path-1:module-path-2");
|
||||
args.put("--name", "name");
|
||||
args.put("--resource-dir", "resource-dir");
|
||||
args.put("--runtime-image", "runtime-image");
|
||||
|
@ -114,7 +79,6 @@ public class TestJpackageOperation {
|
|||
args.put("--win-shortcut-prompt", null);
|
||||
args.put("--win-update-url", "win-update-url");
|
||||
args.put("--win-upgrade-uuid", "win-upgrade-uuid");
|
||||
args.put("@filename", null);
|
||||
|
||||
var options = new JpackageOptions()
|
||||
.aboutUrl(args.get("--about-url"))
|
||||
|
@ -176,8 +140,7 @@ public class TestJpackageOperation {
|
|||
.winShortcut(true)
|
||||
.winShortcutPrompt(true)
|
||||
.winUpdateUrl(args.get("--win-update-url"))
|
||||
.winUpgradeUuid(args.get("--win-upgrade-uuid"))
|
||||
.filename("filename");
|
||||
.winUpgradeUuid(args.get("--win-upgrade-uuid"));
|
||||
|
||||
assertEquals(options.size(), args.size(), "Wrong number of arguments");
|
||||
|
||||
|
@ -188,9 +151,59 @@ public class TestJpackageOperation {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
void testCreatePackage() throws Exception {
|
||||
var tmpdir = Files.createTempDirectory("bld-jpackage-test").toFile();
|
||||
tmpdir.deleteOnExit();
|
||||
|
||||
var options = new JpackageOptions()
|
||||
.input("lib/bld")
|
||||
.name("bld")
|
||||
.mainJar("bld-wrapper.jar")
|
||||
.javaOptions("--enable-preview")
|
||||
.dest(tmpdir.getAbsolutePath())
|
||||
.verbose(true);
|
||||
|
||||
var os = System.getProperty("os.version");
|
||||
if (os.endsWith("MANJARO")) {
|
||||
options.type(JpackageOptions.PackageType.DEB);
|
||||
}
|
||||
|
||||
var jpackage = new JpackageOperation().jpackageOptions(options);
|
||||
jpackage.execute();
|
||||
|
||||
var files = tmpdir.listFiles();
|
||||
assertNotNull(files, "files should not be null");
|
||||
assertTrue(files.length > 0, "No files found");
|
||||
|
||||
assertTrue(files[0].getName().matches("bld.*\\.[A-Za-z]{3}"), "Package not found");
|
||||
|
||||
FileUtils.deleteDirectory(tmpdir);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testHelp() {
|
||||
var jpackage = new JpackageOperation().addArgs("--help");
|
||||
assertDoesNotThrow(jpackage::execute);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testNoArguments() {
|
||||
var jpackage = new JpackageOperation();
|
||||
assertTrue(jpackage.options().isEmpty(), "options not empty");
|
||||
assertTrue(jpackage.jpackageOptions().isEmpty(), "jpackage options not empty");
|
||||
assertThrows(ExitStatusException.class, jpackage::execute);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testOptions() {
|
||||
var jpackage = new JpackageOperation().options("src/test/resources/options_verbose.txt");
|
||||
assertDoesNotThrow(jpackage::execute);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testVersion() {
|
||||
var jpackage = new JpackageOperation().addArgs("--version");
|
||||
var jpackage = new JpackageOperation().addArgs("--verbose", "--version");
|
||||
assertDoesNotThrow(jpackage::execute);
|
||||
}
|
||||
}
|
||||
|
|
1
src/test/resources/options_verbose.txt
Normal file
1
src/test/resources/options_verbose.txt
Normal file
|
@ -0,0 +1 @@
|
|||
--verbose --version
|
1
src/test/resources/options_version.txt
Normal file
1
src/test/resources/options_version.txt
Normal file
|
@ -0,0 +1 @@
|
|||
--version
|
Loading…
Add table
Add a link
Reference in a new issue