Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
9f253603
Commit
9f253603
authored
Jul 09, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Drop -d option from CLI as it was not POSIX compliant
Closes gh-16663
parent
7536d88e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
27 deletions
+39
-27
CommandRunner.java
...a/org/springframework/boot/cli/command/CommandRunner.java
+3
-3
CommandRunnerIntegrationTests.java
...ework/boot/cli/command/CommandRunnerIntegrationTests.java
+36
-15
CommandRunnerTests.java
.../springframework/boot/cli/command/CommandRunnerTests.java
+0
-9
No files found.
spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java
View file @
9f253603
...
...
@@ -188,9 +188,9 @@ public class CommandRunner implements Iterable<Command> {
List
<
String
>
rtn
=
new
ArrayList
<>(
args
.
length
);
boolean
appArgsDetected
=
false
;
for
(
String
arg
:
args
)
{
// Allow apps to have a -
d
argument
// Allow apps to have a -
-debug
argument
appArgsDetected
|=
"--"
.
equals
(
arg
);
if
(
(
"-d"
.
equals
(
arg
)
||
"--debug"
.
equals
(
arg
)
)
&&
!
appArgsDetected
)
{
if
(
"--debug"
.
equals
(
arg
)
&&
!
appArgsDetected
)
{
continue
;
}
rtn
.
add
(
arg
);
...
...
@@ -284,7 +284,7 @@ public class CommandRunner implements Iterable<Command> {
}
Log
.
info
(
""
);
Log
.
info
(
"Common options:"
);
Log
.
info
(
String
.
format
(
"%n %1$s %2$-15s%n %3$s"
,
"-
d, -
-debug"
,
"Verbose mode"
,
Log
.
info
(
String
.
format
(
"%n %1$s %2$-15s%n %3$s"
,
"--debug"
,
"Verbose mode"
,
"Print additional status information for the command you are running"
));
Log
.
info
(
""
);
Log
.
info
(
""
);
...
...
spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/CommandRunnerIntegrationTests.java
View file @
9f253603
...
...
@@ -16,12 +16,10 @@
package
org
.
springframework
.
boot
.
cli
.
command
;
import
org.junit.jupiter.api.BeforeEach
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.springframework.boot.cli.command.run.RunCommand
;
import
org.springframework.boot.test.system.CapturedOutput
;
import
org.springframework.boot.test.system.OutputCaptureExtension
;
import
org.springframework.boot.cli.command.status.ExitStatus
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
...
@@ -29,26 +27,49 @@ import static org.assertj.core.api.Assertions.assertThat;
* Integration tests for {@link CommandRunner}.
*
* @author Dave Syer
* @author Andy Wilkinson
*/
@ExtendWith
(
OutputCaptureExtension
.
class
)
class
CommandRunnerIntegrationTests
{
@BeforeEach
void
clearDebug
()
{
System
.
clearProperty
(
"debug"
);
}
@Test
void
debug
AddsAutoconfigReport
(
CapturedOutput
capturedOutput
)
{
void
debug
EnabledAndArgumentRemovedWhenNotAnApplicationArgument
(
)
{
CommandRunner
runner
=
new
CommandRunner
(
"spring"
);
runner
.
addCommand
(
new
RunCommand
()
);
// -d counts as "debug" for the spring command, but not for the
// LoggingApplicationListener
runner
.
runAndHandleErrors
(
"run"
,
"samples/app.groovy"
,
"-d
"
);
assertThat
(
capturedOutput
).
contains
(
"Negative matches:
"
);
ArgHandlingCommand
command
=
new
ArgHandlingCommand
(
);
runner
.
addCommand
(
command
);
runner
.
runAndHandleErrors
(
"args"
,
"samples/app.groovy"
,
"--debug"
);
assertThat
(
command
.
args
).
containsExactly
(
"samples/app.groovy
"
);
assertThat
(
System
.
getProperty
(
"debug"
)).
isEqualTo
(
"true
"
);
}
@Test
void
debug
SwitchedOffForAppArgs
(
CapturedOutput
capturedOutput
)
{
void
debug
NotEnabledAndArgumentRetainedWhenAnApplicationArgument
(
)
{
CommandRunner
runner
=
new
CommandRunner
(
"spring"
);
runner
.
addCommand
(
new
RunCommand
());
runner
.
runAndHandleErrors
(
"run"
,
"samples/app.groovy"
,
"--"
,
"-d"
);
assertThat
(
capturedOutput
).
doesNotContain
(
"Negative matches:"
);
ArgHandlingCommand
command
=
new
ArgHandlingCommand
();
runner
.
addCommand
(
command
);
runner
.
runAndHandleErrors
(
"args"
,
"samples/app.groovy"
,
"--"
,
"--debug"
);
assertThat
(
command
.
args
).
containsExactly
(
"samples/app.groovy"
,
"--"
,
"--debug"
);
assertThat
(
System
.
getProperty
(
"debug"
)).
isNull
();
}
static
class
ArgHandlingCommand
extends
AbstractCommand
{
private
String
[]
args
;
ArgHandlingCommand
()
{
super
(
"args"
,
""
);
}
@Override
public
ExitStatus
run
(
String
...
args
)
throws
Exception
{
this
.
args
=
args
;
return
ExitStatus
.
OK
;
}
}
}
spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/CommandRunnerTests.java
View file @
9f253603
...
...
@@ -147,15 +147,6 @@ class CommandRunnerTests {
assertThat
(
this
.
calls
).
containsOnly
(
Call
.
ERROR_MESSAGE
,
Call
.
PRINT_STACK_TRACE
);
}
@Test
void
handlesExceptionWithDashD
()
throws
Exception
{
willThrow
(
new
RuntimeException
()).
given
(
this
.
regularCommand
).
run
();
int
status
=
this
.
commandRunner
.
runAndHandleErrors
(
"command"
,
"-d"
);
assertThat
(
System
.
getProperty
(
"debug"
)).
isEqualTo
(
"true"
);
assertThat
(
status
).
isEqualTo
(
1
);
assertThat
(
this
.
calls
).
containsOnly
(
Call
.
ERROR_MESSAGE
,
Call
.
PRINT_STACK_TRACE
);
}
@Test
void
handlesExceptionWithDashDashDebug
()
throws
Exception
{
willThrow
(
new
RuntimeException
()).
given
(
this
.
regularCommand
).
run
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment