made tests less verbose

This commit is contained in:
hneemann 2017-06-24 09:58:25 +02:00
parent 3b8b5e463a
commit 8ce338e39c
3 changed files with 36 additions and 48 deletions

View File

@ -19,11 +19,11 @@ public class FileScanner {
public int scan(File path) throws Exception { public int scan(File path) throws Exception {
errors = new ArrayList<>(); errors = new ArrayList<>();
int count = scanIntern(path); int count = scanIntern(path);
System.out.println("tested "+count+" examples"); System.out.println("tested " + count + " examples");
if (errors.isEmpty()) if (errors.isEmpty())
return count; return count;
System.err.println("errors:"); System.err.println("errors: " + errors.size());
for (Error e : errors) { for (Error e : errors) {
System.err.println("----> error in: " + e.f); System.err.println("----> error in: " + e.f);
e.e.printStackTrace(); e.e.printStackTrace();

View File

@ -30,7 +30,6 @@ public class Test74xx extends TestCase {
} }
private void check(File dig) throws PinException, NodeException, ElementNotFoundException, IOException { private void check(File dig) throws PinException, NodeException, ElementNotFoundException, IOException {
System.out.println(dig);
Circuit circuit = new ToBreakRunner(dig).getCircuit(); Circuit circuit = new ToBreakRunner(dig).getCircuit();
assertTrue("is not DIL", circuit.getAttributes().get(Keys.IS_DIL)); assertTrue("is not DIL", circuit.getAttributes().get(Keys.IS_DIL));
assertTrue("is not locked", circuit.getAttributes().get(Keys.LOCKED_MODE)); assertTrue("is not locked", circuit.getAttributes().get(Keys.LOCKED_MODE));

View File

@ -50,52 +50,41 @@ public class TestExamples extends TestCase {
* @param dig the model file * @param dig the model file
*/ */
private void check(File dig) throws Exception { private void check(File dig) throws Exception {
boolean hasTest = false; boolean shouldFail = dig.getName().endsWith("Error.dig");
ToBreakRunner br = null;
try { try {
boolean shouldFail = dig.getName().endsWith("Error.dig"); br = new ToBreakRunner(dig);
ToBreakRunner br = null; } catch (Exception e) {
try { if (shouldFail) {
br = new ToBreakRunner(dig); return;
} catch (Exception e) { } else
if (shouldFail) { throw e;
hasTest = true;
return;
} else
throw e;
}
try {
for (VisualElement el : br.getCircuit().getElements())
if (el.equalsDescription(TestCaseElement.TESTCASEDESCRIPTION)) {
hasTest = true;
String label = el.getElementAttributes().getCleanLabel();
TestData td = el.getElementAttributes().get(TestCaseElement.TESTDATA);
Model model = new ModelCreator(br.getCircuit(), br.getLibrary()).createModel(false);
TestResult tr = new TestResult(td).create(model);
if (label.contains("Failing"))
assertFalse(dig.getName() + ":" + label, tr.allPassed());
else
assertTrue(dig.getName() + ":" + label, tr.allPassed());
testCasesInFiles++;
}
} catch (Exception e) {
if (shouldFail) {
hasTest = true;
return;
} else
throw e;
}
assertFalse("File should fail but doesn't!", shouldFail);
} finally {
System.out.print("tested " + dig);
if (!hasTest) System.out.println(" -- no test cases");
else System.out.println();
} }
try {
for (VisualElement el : br.getCircuit().getElements())
if (el.equalsDescription(TestCaseElement.TESTCASEDESCRIPTION)) {
String label = el.getElementAttributes().getCleanLabel();
TestData td = el.getElementAttributes().get(TestCaseElement.TESTDATA);
Model model = new ModelCreator(br.getCircuit(), br.getLibrary()).createModel(false);
TestResult tr = new TestResult(td).create(model);
if (label.contains("Failing"))
assertFalse(dig.getName() + ":" + label, tr.allPassed());
else
assertTrue(dig.getName() + ":" + label, tr.allPassed());
testCasesInFiles++;
}
} catch (Exception e) {
if (shouldFail) {
return;
} else
throw e;
}
assertFalse("File should fail but doesn't!", shouldFail);
} }
} }