Skip to content

Commit

Permalink
Fix command line arguments being squashed
Browse files Browse the repository at this point in the history
(cherry picked from commit 854912e)
  • Loading branch information
MaciejDromin authored and gsmet committed Jan 23, 2024
1 parent 8bd951a commit 02ea779
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,16 @@ default BuildCommandArgs prependExecutable(ArrayDeque<String> args) {

default void paramsToQuarkusArgs(List<String> params, ArrayDeque<String> args) {
if (!params.isEmpty()) {
args.add("-Dquarkus.args='" + String.join(" ", params) + "'");
args.add("-Dquarkus.args=" + String.join(" ", wrapWithDoubleQuotes(params)));
}
}

default List<String> wrapWithDoubleQuotes(List<String> stringsToWrap) {
return stringsToWrap.stream()
.map("\"%s\""::formatted)
.toList();
}

default List<String> flattenMappedProperties(Map<String, String> props) {
List<String> result = new ArrayList<>();
props.entrySet().forEach(x -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ public void testDevOptions() throws Exception {
Assertions.assertFalse(result.stdout.contains("-Dsuspend"),
"gradle command should not specify '-Dsuspend'\n" + result);

Assertions.assertTrue(result.stdout.contains("-Dquarkus.args='arg1 arg2'"),
"gradle command should not specify -Dquarkus.args='arg1 arg2'\n" + result);
Assertions.assertTrue(result.stdout.contains("-Dquarkus.args=\"arg1\" \"arg2\""),
"gradle command should not specify -Dquarkus.args=\"arg1\" \"arg2\"\n" + result);

// 4 TEST MODE: test --clean --debug --suspend --offline
result = CliDriver.execute(project, "test", "-e", "--dry-run",
Expand All @@ -366,6 +366,13 @@ public void testDevOptions() throws Exception {
"Expected OK return code. Result:\n" + result);
Assertions.assertTrue(result.stdout.contains("Run current project in test mode"), result.toString());
Assertions.assertTrue(result.stdout.contains("--tests FooTest"), result.toString());

// 6 TEST MODE: Two word argument
result = CliDriver.execute(project, "dev", "-e", "--dry-run",
"--no-suspend", "--debug-host=0.0.0.0", "--debug-port=8008", "--debug-mode=connect", "--", "arg1 arg2");

Assertions.assertTrue(result.stdout.contains("-Dquarkus.args=\"arg1 arg2\""),
"mvn command should not specify -Dquarkus.args=\"arg1 arg2\"\n" + result);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ public void testDevTestOptions() throws Exception {
Assertions.assertFalse(result.stdout.contains("-Dsuspend"),
"mvn command should not specify '-Dsuspend'\n" + result);

Assertions.assertTrue(result.stdout.contains("-Dquarkus.args='arg1 arg2'"),
"mvn command should not specify -Dquarkus.args='arg1 arg2'\n" + result);
Assertions.assertTrue(result.stdout.contains("-Dquarkus.args=\"arg1\" \"arg2\""),
"mvn command should not specify -Dquarkus.args=\"arg1\" \"arg2\"\n" + result);

// 4 TEST MODE: test --clean --debug --suspend --offline
result = CliDriver.execute(project, "test", "-e", "--dry-run",
Expand All @@ -291,6 +291,13 @@ public void testDevTestOptions() throws Exception {
"Expected OK return code. Result:\n" + result);
Assertions.assertTrue(result.stdout.contains("Run current project in test mode"), result.toString());
Assertions.assertTrue(result.stdout.contains("-Dtest=FooTest"), result.toString());

// 6 TEST MODE: Two word argument
result = CliDriver.execute(project, "dev", "-e", "--dry-run",
"--no-suspend", "--debug-host=0.0.0.0", "--debug-port=8008", "--debug-mode=connect", "--", "arg1 arg2");

Assertions.assertTrue(result.stdout.contains("-Dquarkus.args=\"arg1 arg2\""),
"mvn command should not specify -Dquarkus.args=\"arg1 arg2\"\n" + result);
}

@Test
Expand Down

0 comments on commit 02ea779

Please sign in to comment.