@@ -275,7 +275,6 @@ public static OutputAnalyzer execute(List<String> command) throws Exception {
275275 * @throws Exception
276276 */
277277 public static OutputAnalyzer execute (String ... command ) throws Exception {
278-
279278 ProcessBuilder pb = new ProcessBuilder (command );
280279 System .out .println ("[COMMAND]\n " + Utils .getCommandLine (pb ));
281280
@@ -284,14 +283,19 @@ public static OutputAnalyzer execute(String... command) throws Exception {
284283 long pid = p .pid ();
285284 OutputAnalyzer output = new OutputAnalyzer (p );
286285
287- String stdoutLogFile = String .format ("docker-stdout-%d.log" , pid );
286+ int max = MAX_LINES_TO_COPY_FOR_CHILD_STDOUT ;
287+ String stdout = output .getStdout ();
288+ String stdoutLimited = limitLines (stdout , max );
288289 System .out .println ("[ELAPSED: " + (System .currentTimeMillis () - started ) + " ms]" );
289290 System .out .println ("[STDERR]\n " + output .getStderr ());
290- System .out .println ("[STDOUT]\n " +
291- trimLines (output .getStdout (),MAX_LINES_TO_COPY_FOR_CHILD_STDOUT ));
292- System .out .printf ("Child process STDOUT is trimmed to %d lines \n " ,
293- MAX_LINES_TO_COPY_FOR_CHILD_STDOUT );
294- writeOutputToFile (output .getStdout (), stdoutLogFile );
291+ System .out .println ("[STDOUT]\n " + stdoutLimited );
292+ if (stdout != stdoutLimited ) {
293+ System .out .printf ("Child process STDOUT is limited to %d lines\n " ,
294+ max );
295+ }
296+
297+ String stdoutLogFile = String .format ("docker-stdout-%d.log" , pid );
298+ writeOutputToFile (stdout , stdoutLogFile );
295299 System .out .println ("Full child process STDOUT was saved to " + stdoutLogFile );
296300
297301 return output ;
@@ -305,7 +309,7 @@ private static void writeOutputToFile(String output, String fileName) throws Exc
305309 }
306310
307311
308- private static String trimLines (String buffer , int nrOfLines ) {
312+ private static String limitLines (String buffer , int nrOfLines ) {
309313 List <String > l = Arrays .asList (buffer .split ("\\ R" ));
310314 if (l .size () < nrOfLines ) {
311315 return buffer ;
0 commit comments