Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typos and mvn command in e2e README.adoc #674

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions e2e/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@

Testing shell features within unit tests is not always enough to have a full coverage as shell
applications has been traditionally been difficult to test as there is too many moving parts.
While it is relative easy to test parts of a java code in your `spring-shell` app, knowing those
will actualy execute with as run in a hosting environment is totally different topic. As
spring-shell` application can be run on a different environment either a simple `spring-boot` app
While it is relatively easy to test parts of a java code in your `spring-shell` app, knowing those
will actually execute with as run in a hosting environment is a totally different topic. As
`spring-shell` applications can be run on a different environment either a simple `spring-boot` app
via java runtime environment or via `graalvm` build binary many things can simply go wrong.

`spring-shell-e2e` is a node module which uses `node-pty` and `xterm.js` to run your
shell application whether you run shell in any ways as it just assumes a command runs
a shell application. Relationship between `node-pty` and `xterm.js` is that _pty_ environment
is providing underlying host capabilities running shell applications and _xterm_ having
a knowledge to translate all shell command sequinces to a representive text.
a knowledge to translate all shell command sequences to a representative text.

[NOTE]
====
We chose to use javascript space for e2e framework as it provides a good set of
libraries to work with various environments and is much more close to native
environment what we could do from a java space.
libraries to work with various environments and is much more close to native a
environment than what we could do from a java space.
====

`spring-shell-e2e-tests` is simply using `spring-shell-e2e` to implement _e2e_ tests and
runs both _fatjar_ and _native_ built apps.

`spring-shell-e2e` is work-in-progress so it's not yet published into _npmjs_.
`spring-shell-e2e` is work-in-progress, so it's not yet published into _npmjs_.

Generic workflow to run `spring-shell-e2e-tests` is:

====
[source, bash]
----
spring-shell
$ ./mvnw clean package -DskipTests
$ ./gradlew build -x test

spring-shell/e2e/spring-shell-e2e
$ npm install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
import org.springframework.context.annotation.Bean;
import org.springframework.shell.MethodTargetRegistrar;
import org.springframework.shell.boot.SpringShellProperties.Help;
import org.springframework.shell.command.CommandCatalog;
import org.springframework.shell.command.CommandCatalogCustomizer;
import org.springframework.shell.command.catalog.CommandCatalog;
import org.springframework.shell.command.catalog.CommandCatalogCustomizer;
import org.springframework.shell.command.CommandRegistration;
import org.springframework.shell.command.CommandRegistration.BuilderSupplier;
import org.springframework.shell.command.CommandRegistration.OptionNameModifier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.shell.command.CommandExecution;
import org.springframework.shell.command.execution.CommandExecution;
import org.springframework.shell.exit.ExitCodeExceptionProvider;
import org.springframework.shell.exit.ExitCodeMappings;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.shell.command.CommandCatalog;
import org.springframework.shell.command.catalog.CommandCatalog;
import org.springframework.shell.config.UserConfigPathProvider;
import org.springframework.util.StringUtils;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver;
import org.springframework.shell.command.ArgumentHeaderMethodArgumentResolver;
import org.springframework.shell.command.CommandContextMethodArgumentResolver;
import org.springframework.shell.command.CommandExecution.CommandExecutionHandlerMethodArgumentResolvers;
import org.springframework.shell.command.execution.CommandExecution.CommandExecutionHandlerMethodArgumentResolvers;
import org.springframework.shell.completion.CompletionResolver;
import org.springframework.shell.completion.RegistrationOptionsCompletionResolver;
import org.springframework.shell.config.ShellConversionServiceSupplier;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import org.springframework.shell.ResultHandler;
import org.springframework.shell.ResultHandlerService;
import org.springframework.shell.Shell;
import org.springframework.shell.command.CommandCatalog;
import org.springframework.shell.command.catalog.CommandCatalog;
import org.springframework.shell.config.ShellConversionServiceSupplier;
import org.springframework.shell.context.ShellContext;
import org.springframework.shell.exit.ExitCodeMappings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.shell.MethodTargetRegistrar;
import org.springframework.shell.command.CommandCatalog;
import org.springframework.shell.command.catalog.CommandCatalog;
import org.springframework.shell.command.CommandRegistration;
import org.springframework.shell.standard.CommandValueProvider;
import org.springframework.shell.standard.EnumValueProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.shell.command.CommandCatalog;
import org.springframework.shell.command.catalog.CommandCatalog;
import org.springframework.shell.command.CommandRegistration;
import org.springframework.shell.command.CommandResolver;
import org.springframework.shell.command.CommandRegistration.Builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.shell.command.CommandCatalog;
import org.springframework.shell.command.catalog.CommandCatalog;
import org.springframework.shell.config.UserConfigPathProvider;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.shell.command.CommandExecution.CommandExecutionHandlerMethodArgumentResolvers;
import org.springframework.shell.command.execution.CommandExecution.CommandExecutionHandlerMethodArgumentResolvers;
import org.springframework.shell.completion.CompletionResolver;
import org.springframework.shell.config.ShellConversionServiceSupplier;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.shell.Shell;
import org.springframework.shell.command.CommandExecution.CommandExecutionHandlerMethodArgumentResolvers;
import org.springframework.shell.command.execution.CommandExecution.CommandExecutionHandlerMethodArgumentResolvers;
import org.springframework.shell.completion.CompletionResolver;
import org.springframework.shell.context.ShellContext;
import org.springframework.shell.jline.InteractiveShellRunner;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package org.springframework.shell;

import org.springframework.shell.command.CommandCatalog;
import org.springframework.shell.command.catalog.CommandCatalog;

/**
* Strategy interface for registering commands.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.DefaultConversionService;
import org.springframework.shell.command.CommandAlias;
import org.springframework.shell.command.CommandCatalog;
import org.springframework.shell.command.catalog.CommandCatalog;
import org.springframework.shell.command.CommandExceptionResolver;
import org.springframework.shell.command.CommandExecution;
import org.springframework.shell.command.CommandExecution.CommandExecutionException;
import org.springframework.shell.command.CommandExecution.CommandExecutionHandlerMethodArgumentResolvers;
import org.springframework.shell.command.execution.CommandExecution;
import org.springframework.shell.command.execution.CommandExecution.CommandExecutionException;
import org.springframework.shell.command.execution.CommandExecution.CommandExecutionHandlerMethodArgumentResolvers;
import org.springframework.shell.command.CommandHandlingResult;
import org.springframework.shell.command.CommandOption;
import org.springframework.shell.command.CommandRegistration;
Expand All @@ -58,6 +58,8 @@
* @author Eric Bottard
* @author Janne Valkealahti
*/

// Shit goes down here
public class Shell {

private final static Logger log = LoggerFactory.getLogger(Shell.class);
Expand Down Expand Up @@ -171,7 +173,7 @@ else if (result instanceof Exception) {
throw (Exception) result;
}
if (handlingResultNonInt instanceof CommandExecution.CommandParserExceptionsException) {
throw (CommandExecution.CommandParserExceptionsException) handlingResultNonInt;
throw handlingResultNonInt;
}
else if (processExceptionNonInt != null && processExceptionNonInt.exitCode() != null
&& exitCodeExceptionProvider != null) {
Expand All @@ -196,7 +198,7 @@ protected Object evaluate(Input input) {
}

List<String> words = input.words();
String line = words.stream().collect(Collectors.joining(" ")).trim();
String line = String.join(" ", words).trim();
String command = findLongestCommand(line, false);

if (command == null) {
Expand Down Expand Up @@ -230,14 +232,18 @@ protected Object evaluate(Input input) {
}

Thread commandThread = Thread.currentThread();
Object sh = Signals.register("INT", () -> commandThread.interrupt());
Object interruptionSignalHandler = Signals.register("INT", commandThread::interrupt);

CommandExecution execution = CommandExecution.of(
argumentResolvers != null ? argumentResolvers.getResolvers() : null, validator, terminal,
conversionService, commandRegistry);

List<CommandExceptionResolver> commandExceptionResolvers = commandRegistration.get().getExceptionResolvers();

return evaluateAndCatch(words, interruptionSignalHandler, execution, commandExceptionResolvers);
}

private Object evaluateAndCatch(List<String> words, Object interruptionSignalHandler, CommandExecution execution, List<CommandExceptionResolver> commandExceptionResolvers) {
Object evaluate = null;
Exception e = null;
try {
Expand All @@ -249,20 +255,21 @@ protected Object evaluate(Input input) {
}
return ute.getCause();
}
catch (CommandExecutionException e1) {
if (e1.getCause() instanceof Exception e11) {
e = e11;
catch (CommandExecutionException commandExecutionException) {
if (commandExecutionException.getCause() instanceof Exception causeException) {
e = causeException;
}
else {
return e1.getCause();
return commandExecutionException.getCause();
}
}
catch (Exception e2) {
e = e2;
catch (Exception exception) {
e = exception;
}
finally {
Signals.unregister("INT", sh);
Signals.unregister("INT", interruptionSignalHandler);
}

if (e != null && !(e instanceof ExitRequest)) {
try {
CommandHandlingResult processException = processException(commandExceptionResolvers, e);
Expand All @@ -284,6 +291,7 @@ protected Object evaluate(Input input) {
if (e != null) {
evaluate = e;
}

return evaluate;
}

Expand Down Expand Up @@ -447,7 +455,7 @@ private CompletionProposal toCommandProposal(String command, CommandRegistration
private String findLongestCommand(String prefix, boolean filterHidden) {
Map<String, CommandRegistration> registrations = commandRegistry.getRegistrations();
if (filterHidden) {
registrations = Utils.removeHiddenCommands(registrations);
Utils.removeHiddenCommands(registrations);
}
String result = registrations.keySet().stream()
.filter(command -> prefix.equals(command) || prefix.startsWith(command + " "))
Expand Down
Loading