From 03b741c862d6537d19a5d82e39b05221fa4fa46c Mon Sep 17 00:00:00 2001 From: Akos Hajdu Date: Mon, 28 Sep 2020 13:38:35 +0200 Subject: [PATCH] Add non-zero exit code for exceptions in CLI tools, fixes #88 --- build.gradle.kts | 2 +- .../src/main/java/hu/bme/mit/theta/cfa/cli/CfaCli.java | 6 +++--- .../src/main/java/hu/bme/mit/theta/sts/cli/StsCli.java | 6 +++--- .../src/main/java/hu/bme/mit/theta/xsts/cli/XstsCli.java | 6 +++--- .../src/main/java/hu/bme/mit/theta/xta/cli/XtaCli.java | 1 + 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 690154b7b0..992ffc29b2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -10,7 +10,7 @@ buildscript { allprojects { group = "hu.bme.mit.inf.theta" - version = "2.5.1" + version = "2.6.0" apply(from = rootDir.resolve("gradle/shared-with-buildSrc/mirrors.gradle.kts")) } diff --git a/subprojects/cfa-cli/src/main/java/hu/bme/mit/theta/cfa/cli/CfaCli.java b/subprojects/cfa-cli/src/main/java/hu/bme/mit/theta/cfa/cli/CfaCli.java index 27baa9d4c9..3386c46d94 100644 --- a/subprojects/cfa-cli/src/main/java/hu/bme/mit/theta/cfa/cli/CfaCli.java +++ b/subprojects/cfa-cli/src/main/java/hu/bme/mit/theta/cfa/cli/CfaCli.java @@ -191,9 +191,7 @@ private void run() { } } catch (final Throwable ex) { printError(ex); - } - if (benchmarkMode) { - writer.newRow(); + System.exit(1); } } @@ -248,6 +246,7 @@ private void printResult(final SafetyResult status, final long totalTimeMs } else { writer.cell(""); } + writer.newRow(); } } @@ -255,6 +254,7 @@ private void printError(final Throwable ex) { final String message = ex.getMessage() == null ? "" : ex.getMessage(); if (benchmarkMode) { writer.cell("[EX] " + ex.getClass().getSimpleName() + ": " + message); + writer.newRow(); } else { logger.write(Level.RESULT, "%s occurred, message: %s%n", ex.getClass().getSimpleName(), message); if (stacktrace) { diff --git a/subprojects/sts-cli/src/main/java/hu/bme/mit/theta/sts/cli/StsCli.java b/subprojects/sts-cli/src/main/java/hu/bme/mit/theta/sts/cli/StsCli.java index 31a60502d0..c13a75927f 100644 --- a/subprojects/sts-cli/src/main/java/hu/bme/mit/theta/sts/cli/StsCli.java +++ b/subprojects/sts-cli/src/main/java/hu/bme/mit/theta/sts/cli/StsCli.java @@ -153,9 +153,7 @@ private void run() { } } catch (final Throwable ex) { printError(ex); - } - if (benchmarkMode) { - writer.newRow(); + System.exit(1); } } @@ -221,6 +219,7 @@ private void printResult(final SafetyResult status, final STS sts, final l } writer.cell(sts.getVars().size()); writer.cell(ExprUtils.nodeCountSize(BoolExprs.And(sts.getInit(), sts.getTrans()))); + writer.newRow(); } } @@ -228,6 +227,7 @@ private void printError(final Throwable ex) { final String message = ex.getMessage() == null ? "" : ex.getMessage(); if (benchmarkMode) { writer.cell("[EX] " + ex.getClass().getSimpleName() + ": " + message); + writer.newRow(); } else { logger.write(Level.RESULT, "%s occurred, message: %s%n", ex.getClass().getSimpleName(), message); if (stacktrace) { diff --git a/subprojects/xsts-cli/src/main/java/hu/bme/mit/theta/xsts/cli/XstsCli.java b/subprojects/xsts-cli/src/main/java/hu/bme/mit/theta/xsts/cli/XstsCli.java index f205a69780..431c60e43f 100644 --- a/subprojects/xsts-cli/src/main/java/hu/bme/mit/theta/xsts/cli/XstsCli.java +++ b/subprojects/xsts-cli/src/main/java/hu/bme/mit/theta/xsts/cli/XstsCli.java @@ -139,9 +139,7 @@ private void run() { } } catch (final Throwable ex) { printError(ex); - } - if (benchmarkMode) { - writer.newRow(); + System.exit(1); } } @@ -201,6 +199,7 @@ private void printResult(final SafetyResult status, final XSTS sts, final writer.cell(""); } writer.cell(sts.getVars().size()); + writer.newRow(); } } @@ -208,6 +207,7 @@ private void printError(final Throwable ex) { final String message = ex.getMessage() == null ? "" : ex.getMessage(); if (benchmarkMode) { writer.cell("[EX] " + ex.getClass().getSimpleName() + ": " + message); + writer.newRow(); } else { logger.write(Logger.Level.RESULT, "%s occurred, message: %s%n", ex.getClass().getSimpleName(), message); if (stacktrace) { diff --git a/subprojects/xta-cli/src/main/java/hu/bme/mit/theta/xta/cli/XtaCli.java b/subprojects/xta-cli/src/main/java/hu/bme/mit/theta/xta/cli/XtaCli.java index 1558fdf2e0..93ca52f75b 100644 --- a/subprojects/xta-cli/src/main/java/hu/bme/mit/theta/xta/cli/XtaCli.java +++ b/subprojects/xta-cli/src/main/java/hu/bme/mit/theta/xta/cli/XtaCli.java @@ -113,6 +113,7 @@ private void run() { } } catch (final Throwable ex) { printError(ex); + System.exit(1); } }