Echo the commands being executed
authorAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Wed, 29 Jul 2015 21:07:14 +0000 (17:07 -0400)
committerAlexandre Montplaisir <alexmonthy@voxpopuli.im>
Wed, 29 Jul 2015 22:45:27 +0000 (18:45 -0400)
Signed-off-by: Alexandre Montplaisir <alexmonthy@voxpopuli.im>
src/test/java/org/lttng/ust/agent/utils/LttngSession.java
src/test/java/org/lttng/ust/agent/utils/MiscTestUtils.java

index 9c77f59b8395ca8e7bdd41d58aa1afa8daaa9302..8869ef5da8c901acac2de140b3ee63772d394aa2 100644 (file)
@@ -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<String> 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) {
index 3aac32c00d1627641f9fa59dd7a6012e1d22d236..fe717367e9996668f94e2a882a50334c2237bf91 100644 (file)
@@ -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<String> getOutputFromCommand(boolean print, List<String> 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) {
This page took 0.023983 seconds and 4 git commands to generate.