X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.tests.modelled%2Fsrc%2Forg%2Fsimantics%2Ftests%2Fmodelled%2Fjunit%2Fv2%2FModelledSTSSuiteRunner.java;h=0bfb1f1ceaf02ab61476398c4075e2dead9e165b;hp=5b7a8ef0ac3d5b352052476055bd160b7c58531b;hb=3e8cd4aef089a228d7f2e141f2b2159f820a4266;hpb=1ec0193a5a5b8f368b03adb24acd762838ddf8ea diff --git a/bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/junit/v2/ModelledSTSSuiteRunner.java b/bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/junit/v2/ModelledSTSSuiteRunner.java index 5b7a8ef0a..0bfb1f1ce 100644 --- a/bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/junit/v2/ModelledSTSSuiteRunner.java +++ b/bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/junit/v2/ModelledSTSSuiteRunner.java @@ -1,6 +1,7 @@ package org.simantics.tests.modelled.junit.v2; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -18,17 +19,46 @@ public class ModelledSTSSuiteRunner extends ParentRunner private final ModelledSTSSuite suite; private final List children; - private Map> storedVariables; + private Map> storedVariables = new HashMap<>(); public ModelledSTSSuiteRunner(ModelledSTSSuite suite) throws InitializationError { super(ModelledSTSSuiteRunner.class); this.suite = suite; this.children = new ArrayList<>(suite.getChildren().size()); + + // Do possible filtering + // Filter exclusions + String exclusionFilter = System.getProperty(ModelledSTSRunner.EXCLUSION_FILTER); + // Filter inclusions + String inclusionFilter = System.getProperty(ModelledSTSRunner.INCLUSION_FILTER); for (ModelledSTSTest test : suite.getSortedChildren()) { - children.add(new ModelledSTSTestRunner(test)); + boolean add = true; + if (exclusionFilter != null) { + String[] filters = exclusionFilter.split(","); + if (startsWithAny(test, filters)) { + add = false; + } + } + if (inclusionFilter != null) { + String[] filters = inclusionFilter.split(","); + if (!startsWithAny(test, filters)) { + add = false; + } + } + if (add) + children.add(new ModelledSTSTestRunner(test)); } } + private static boolean startsWithAny(ModelledSTSTest test, String[] filters) { + for (String filter : filters) { + if (test.getName().contains(filter)) { + return true; + } + } + return false; + } + @Override protected String getName() { return suite.getName(); @@ -58,10 +88,12 @@ public class ModelledSTSSuiteRunner extends ParentRunner variables.addAll(storedVars); } } + notifier.fireTestStarted(description); List newVars = child.runWithVars(variables); - storedVariables.put(child.getTest().getName(), newVars); +// TODO: FIX THIS BY NOT ADDING ALL VARIABLES TO MEMORY (CAN BE HUGE) +// storedVariables.put(child.getTest().getName(), newVars); notifier.fireTestFinished(description); - } catch (Exception e) { + } catch (Throwable e) { notifier.fireTestFailure(new Failure(description, e)); } }