GJL commented on a change in pull request #10804: [FLINK-15488] Obtain the JVM 
and TM param correctly
URL: https://github.com/apache/flink/pull/10804#discussion_r365322482
 
 

 ##########
 File path: 
flink-dist/src/test/java/org/apache/flink/dist/BashJavaUtilsITCase.java
 ##########
 @@ -34,21 +36,30 @@
 
        private static final String RUN_BASH_JAVA_UTILS_CMD_SCRIPT = 
"src/test/bin/runBashJavaUtilsCmd.sh";
 
+       /**
+        * Executes the given shell script wrapper and returns the last line.
+        */
+       private String executeScriptAndFetchLastLine(final String command) 
throws IOException {
+               String[] commands = {RUN_BASH_JAVA_UTILS_CMD_SCRIPT, command};
+               String[] lines = 
executeScript(commands).split(System.lineSeparator());
+               if (lines.length == 0) {
+                       return "";
+               } else {
+                       return lines[lines.length - 1];
+               }
+       }
+
        @Test
        public void testGetTmResourceDynamicConfigs() throws Exception {
-               String[] command = {RUN_BASH_JAVA_UTILS_CMD_SCRIPT,
-                       
BashJavaUtils.Command.GET_TM_RESOURCE_DYNAMIC_CONFIGS.toString()};
-               String result = executeScript(command);
+               String result = 
executeScriptAndFetchLastLine(BashJavaUtils.Command.GET_TM_RESOURCE_DYNAMIC_CONFIGS.toString());
 
                assertNotNull(result);
 
 Review comment:
   Would it be possible to invoke `BashJavaUtils#main` directly, and use 
`System.setOut` to redirect the output to stdout to a different stream?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to