diff --git a/gclc.system/src/main/java/net/bigeon/gclc/system/ExecSystemCommand.java b/gclc.system/src/main/java/net/bigeon/gclc/system/ExecSystemCommand.java index b29521a..8707664 100644 --- a/gclc.system/src/main/java/net/bigeon/gclc/system/ExecSystemCommand.java +++ b/gclc.system/src/main/java/net/bigeon/gclc/system/ExecSystemCommand.java @@ -101,7 +101,7 @@ public class ExecSystemCommand extends Command { try (BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os))) { while (th.isAlive()) { final String user = in.prompt(); - // Avoid interruption being sent to process. + // Forward to process if not empty. if (!user.isEmpty()) { writer.write(user + EOL); } diff --git a/gclc.system/src/test/java/net/bigeon/gclc/system/ExecSystemCommandTest.java b/gclc.system/src/test/java/net/bigeon/gclc/system/ExecSystemCommandTest.java index 11538f2..9488d11 100644 --- a/gclc.system/src/test/java/net/bigeon/gclc/system/ExecSystemCommandTest.java +++ b/gclc.system/src/test/java/net/bigeon/gclc/system/ExecSystemCommandTest.java @@ -79,4 +79,26 @@ public class ExecSystemCommandTest { } } + /** Test the execution of the command. + * + * @throws CommandRunException if the command fails */ + @Test + public void testLongExecute() throws CommandRunException { + final ConsoleOutput out = SinkOutput.INSTANCE; + final ConsoleInput in = EmptyInput.INSTANCE; + + final ExecSystemCommand cmd = new ExecSystemCommand(); + if (System.getProperty("os.name").contains("indows")) { + cmd.execute(out, in, "cmd", "/C", "dir", "/s"); + } else if (System.getProperty("os.name").contains("inux")) { + cmd.execute(out, in, "ls", "-R"); + } + try { + cmd.execute(out, in, "inexistent"); + fail("Able to execute inexistent command in system"); + } catch (final CommandRunException e) { + // ok + } + } + }