chia7712 commented on PR #15489:
URL: https://github.com/apache/kafka/pull/15489#issuecomment-2023109755

   @Owen-CH-Leung The `printUsageAndExit` call `exit(1)` so `KRAFT` and 
`CO_KRAFT` will stop the JVM. `ZK` can capture the exit code to throw exception 
so it does not terminate the JVM.
   
   Hence, a simple solution is - set dumb exit procedure for `testPrintHelp`. 
For example:
   ```java
       @ClusterTest
       public void testPrintHelp() {
           Exit.setExitProcedure((statusCode, message) -> { });
           try {
               String out = ToolsTestUtils.captureStandardErr(() -> 
GetOffsetShell.mainNoExit("--help"));
               assertTrue(out.startsWith(GetOffsetShell.USAGE_TEXT));
           } finally {
               Exit.resetExitProcedure();
           }
       }
   ``` 
   WDYT?
   


-- 
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.

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to