From: Alexandre Montplaisir Date: Wed, 29 Jul 2015 21:07:14 +0000 (-0400) Subject: Echo the commands being executed X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=dd1cba3f3d1d7e05ccb6a1f055454a7abb9eafb3;p=lttng-ust-java-tests.git Echo the commands being executed Signed-off-by: Alexandre Montplaisir --- diff --git a/src/test/java/org/lttng/ust/agent/utils/LttngSession.java b/src/test/java/org/lttng/ust/agent/utils/LttngSession.java index 9c77f59..8869ef5 100644 --- a/src/test/java/org/lttng/ust/agent/utils/LttngSession.java +++ b/src/test/java/org/lttng/ust/agent/utils/LttngSession.java @@ -28,6 +28,7 @@ import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.Arrays; import java.util.List; +import java.util.StringJoiner; import java.util.UUID; import java.util.stream.Collectors; @@ -245,12 +246,20 @@ public class LttngSession implements AutoCloseable { private static boolean executeCommand(List command) { try { + /* "echo" the command to stdout */ + StringJoiner sj = new StringJoiner(" ", "$ ", ""); + command.stream().forEach(sj::add); + System.out.println(sj.toString()); + ProcessBuilder builder = new ProcessBuilder(command); builder.redirectErrorStream(true); builder.redirectOutput(Redirect.INHERIT); Process p = builder.start(); int ret = p.waitFor(); + + System.out.println("(returned from command)"); + return (ret == 0); } catch (IOException | InterruptedException e) { diff --git a/src/test/java/org/lttng/ust/agent/utils/MiscTestUtils.java b/src/test/java/org/lttng/ust/agent/utils/MiscTestUtils.java index 3aac32c..fe71736 100644 --- a/src/test/java/org/lttng/ust/agent/utils/MiscTestUtils.java +++ b/src/test/java/org/lttng/ust/agent/utils/MiscTestUtils.java @@ -24,6 +24,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.Arrays; import java.util.List; +import java.util.StringJoiner; import org.lttng.ust.agent.jul.LttngLogHandler; import org.lttng.ust.agent.log4j.LttngLogAppender; @@ -131,6 +132,11 @@ public final class MiscTestUtils { static List getOutputFromCommand(boolean print, List command) { try { + /* "echo" the command to stdout */ + StringJoiner sj = new StringJoiner(" ", "$ ", ""); + command.stream().forEach(sj::add); + System.out.println(sj.toString()); + Path tempFile = Files.createTempFile("test-output", null); ProcessBuilder builder = new ProcessBuilder(command); @@ -145,9 +151,12 @@ public final class MiscTestUtils { if (print) { /* Also print the output to the console */ - lines.stream().forEach(s -> System.out.println(s)); + lines.stream().forEach(System.out::println); + } else { + System.out.println("(output silenced)"); } + System.out.println("(returned from command)"); return lines; } catch (IOException | InterruptedException e) {