adds a verbose mode to the cli test output; closes #728

This commit is contained in:
hneemann 2021-04-30 18:30:09 +02:00
parent a63a455c22
commit 9eb1b23073
3 changed files with 23 additions and 1 deletions

View File

@ -28,6 +28,7 @@ public class CommandLineTester {
private List<Circuit.TestCase> testCases;
private int testsPassed;
private boolean allowMissingInputs;
private boolean verbose;
/**
* Creates a new instance.
@ -90,6 +91,10 @@ public class CommandLineTester {
else
message += " (" + tr.failedPercent() + "%)";
out.println(message);
if (verbose)
out.println(tr.getValueTable());
errorCount++;
}
errorDetector.check();
@ -115,6 +120,17 @@ public class CommandLineTester {
return this;
}
/**
* Sets verbose mode
*
* @param verbose true if verbose mode is set
* @return this for chained calls
*/
public CommandLineTester setVerbose(boolean verbose) {
this.verbose = verbose;
return this;
}
/**
* The test command
*/
@ -122,6 +138,7 @@ public class CommandLineTester {
private final Argument<String> circ;
private final Argument<String> tests;
private final Argument<Boolean> allowMissingInputs;
private final Argument<Boolean> verbose;
private int testsPassed;
/**
@ -132,12 +149,15 @@ public class CommandLineTester {
circ = addArgument(new Argument<>("circ", "", false));
tests = addArgument(new Argument<>("tests", "", true));
allowMissingInputs = addArgument(new Argument<>("allowMissingInputs", false, true));
verbose = addArgument(new Argument<>("verbose", false, true));
}
@Override
protected void execute() throws CLIException {
try {
CommandLineTester clt = new CommandLineTester(new File(circ.get())).setAllowMissingInputs(allowMissingInputs.get());
CommandLineTester clt = new CommandLineTester(new File(circ.get()))
.setVerbose(verbose.get())
.setAllowMissingInputs(allowMissingInputs.get());
if (tests.isSet())
clt.useTestCasesFrom(new File(tests.get()));
int errors = clt.execute(System.out);

View File

@ -1748,6 +1748,7 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
Testfall definiert sind. Dies kann sinnvoll sein, wenn es mehrere mögliche Lösungen gibt, die von
verschiedenen Eingängen abhängig sein können.
</string>
<string name="cli_help_test_verbose">Wenn gesetzt, wird im Fehlerfall die Wertetabelle ausgegeben.</string>
<string name="cli_thereAreTestFailures">Es sind Tests fehlgeschlagen.</string>
<string name="cli_errorExecutingTests">Es ist ein Fehler bei der Ausführung der Tests aufgetreten.</string>

View File

@ -1735,6 +1735,7 @@
defined in the test case. This can be useful if there are several possible solutions which may
depend on different inputs.
</string>
<string name="cli_help_test_verbose">If set, the value table is output in case of an error.</string>
<string name="cli_thereAreTestFailures">Tests have failed.</string>
<string name="cli_errorExecutingTests">An error has occurred during the execution of the tests.</string>