Skip to content

Commit 9d4a320

Browse files
authored
Merge pull request #159 from bci-oss/bugfix/fix-unit-tests
Fix the unit tests to not pollute the console with expected exception…
2 parents 39ceb35 + 5d4f8e2 commit 9d4a320

File tree

2 files changed

+96
-77
lines changed

2 files changed

+96
-77
lines changed

tools/bamm-cli/src/main/java/io/openmanufacturing/sds/BammCli.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,32 @@ public class BammCli extends AbstractCommand {
3636

3737
public static final String COMMAND_NAME = "bamm";
3838

39-
private final CommandLine commandLine = new CommandLine( this );
39+
private final CommandLine commandLine = new CommandLine( this )
40+
.addSubcommand( new AspectCommand() )
41+
.setCaseInsensitiveEnumValuesAllowed( true );
4042

4143
@CommandLine.Option( names = { "--version" }, description = "Show current version" )
4244
private boolean version;
4345

44-
public void run( final String... argv ) throws Exception {
45-
main( argv );
46+
int run( final String... argv ) {
47+
return commandLine.execute( argv );
4648
}
4749

48-
public static void main( final String[] argv ) throws Exception {
50+
int runWithExceptionHandler( final CommandLine.IExecutionExceptionHandler exceptionHandler, final String... argv ) {
51+
final CommandLine.IExecutionExceptionHandler oldHandler = commandLine.getExecutionExceptionHandler();
52+
try {
53+
commandLine.setExecutionExceptionHandler( exceptionHandler );
54+
return commandLine.execute( argv );
55+
} finally {
56+
commandLine.setExecutionExceptionHandler( oldHandler );
57+
}
58+
}
59+
60+
public static void main( final String[] argv ) {
4961
AnsiConsole.systemInstall();
5062

5163
final BammCli command = new BammCli();
52-
final CommandLine commandLine = command.commandLine
53-
.addSubcommand( new AspectCommand() )
54-
.setCaseInsensitiveEnumValuesAllowed( true );
55-
56-
final int exitCode = commandLine.execute( argv );
64+
final int exitCode = command.commandLine.execute( argv );
5765
AnsiConsole.systemUninstall();
5866
System.exit( exitCode );
5967
}

0 commit comments

Comments
 (0)