diff --git a/src/main/java/org/utplsql/cli/RunCommand.java b/src/main/java/org/utplsql/cli/RunCommand.java index 13d461a..f242291 100644 --- a/src/main/java/org/utplsql/cli/RunCommand.java +++ b/src/main/java/org/utplsql/cli/RunCommand.java @@ -13,6 +13,7 @@ import org.utplsql.api.reporter.Reporter; import org.utplsql.api.reporter.ReporterFactory; import org.utplsql.cli.exception.DatabaseConnectionFailed; +import org.utplsql.cli.exception.ReporterTimeoutException; import org.utplsql.cli.log.StringBlockFormatter; import javax.sql.DataSource; @@ -201,19 +202,21 @@ public int run() { getReporterManager().startReporterGatherers(executorService, dataSource, returnCode); executorService.shutdown(); - executorService.awaitTermination(timeoutInMinutes, TimeUnit.MINUTES); + if ( !executorService.awaitTermination(timeoutInMinutes, TimeUnit.MINUTES) ) { + throw new ReporterTimeoutException(timeoutInMinutes); + } logger.info("--------------------------------------"); logger.info("All tests done."); return returnCode[0]; } - catch ( DatabaseNotCompatibleException | UtPLSQLNotInstalledException | DatabaseConnectionFailed e ) { + catch ( DatabaseNotCompatibleException | UtPLSQLNotInstalledException | DatabaseConnectionFailed | ReporterTimeoutException e ) { System.out.println(e.getMessage()); } catch (Exception e) { e.printStackTrace(); } - return 1; + return Cli.DEFAULT_ERROR_CODE; } private ArrayList getObjectList(String includeObjects) { diff --git a/src/main/java/org/utplsql/cli/exception/ReporterTimeoutException.java b/src/main/java/org/utplsql/cli/exception/ReporterTimeoutException.java new file mode 100644 index 0000000..39ce2b1 --- /dev/null +++ b/src/main/java/org/utplsql/cli/exception/ReporterTimeoutException.java @@ -0,0 +1,15 @@ +package org.utplsql.cli.exception; + +public class ReporterTimeoutException extends Exception { + + private final int timeOutInMinutes; + + public ReporterTimeoutException( int timeoutInMinutes ) { + super("Timeout while waiting for reporters to finish for " + timeoutInMinutes + " minutes"); + this.timeOutInMinutes = timeoutInMinutes; + } + + public int getTimeOutInMinutes() { + return timeOutInMinutes; + } +}