]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Add inclusion filter to modelled STS tests
authorjsimomaa <jani.simomaa@gmail.com>
Thu, 15 Jun 2017 06:27:10 +0000 (09:27 +0300)
committerjsimomaa <jani.simomaa@gmail.com>
Thu, 15 Jun 2017 07:06:39 +0000 (10:06 +0300)
refs #7305

Change-Id: Iad8b19ceddaad0c493a2b8a8b5d267ab0abb0a8a

bundles/org.simantics.tests.modelled/META-INF/MANIFEST.MF
bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/junit/v2/ModelledSTSRunner.java
bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/junit/v2/ModelledSTSSuiteRunner.java
bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/utils/ModelledSTSTest.java

index 8f182947930bb09a6d637bf373bc9e0bdc1d8fc3..4cbcec294d7fcb3e1855994e398decc065ad105a 100644 (file)
@@ -10,7 +10,8 @@ Require-Bundle: org.simantics.tests.modelled.ontology,
  org.junit,
  org.simantics.modeling;bundle-version="1.1.1",
  org.slf4j.api,
- org.simantics.db.testing
+ org.simantics.db.testing,
+ org.simantics.debug.browser;bundle-version="1.0.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.8
 Bundle-ActivationPolicy: lazy
 Export-Package: org.simantics.tests.modelled,
index 29628cec061e8b4ef5117da84d45947524cd3893..31077a080d75d8e2c18352dab1a2dbdc264d70f4 100644 (file)
@@ -19,6 +19,7 @@ import org.simantics.tests.modelled.utils.STSSuiteTestCollector;
 
 public class ModelledSTSRunner extends ParentRunner<ModelledSTSSuiteRunner> {
 
+    public static final String INCLUSION_FILTER = "org.simantics.tests.modelled.singleTestIncludeFilter";
     public static final String EXCLUSION_FILTER = "org.simantics.tests.modelled.excludeFilter";
     
     private final List<ModelledSTSSuiteRunner> children;
@@ -28,6 +29,8 @@ public class ModelledSTSRunner extends ParentRunner<ModelledSTSSuiteRunner> {
         try {
             initialize0();
             Collection<ModelledSTSSuite> suites = STSSuiteTestCollector.collectTests();
+            
+            // Filter exclusions
             String exclusionFilter = System.getProperty(EXCLUSION_FILTER);
             Collection<ModelledSTSSuite> filtered;
             if (exclusionFilter != null) {
@@ -36,7 +39,18 @@ public class ModelledSTSRunner extends ParentRunner<ModelledSTSSuiteRunner> {
             } else {
                 filtered = suites;
             }
+            // Filter inclusions
+//            String inclusionFilter = System.getProperty(INCLUSION_FILTER);
+//            Collection<ModelledSTSSuite> included;
+//            if (inclusionFilter != null) {
+//                String[] filters = inclusionFilter.split(",");
+//                included = filtered.stream().filter(s -> startsWithAny(s, filters)).collect(Collectors.toList());
+//            } else {
+//                included = filtered;
+//            }
+            
             // Sort by priority
+//            List<ModelledSTSSuite> sorted = included.stream().sorted((o1, o2) -> Integer.compare(o1.getPriority(), o2.getPriority())).collect(Collectors.toList());
             List<ModelledSTSSuite> sorted = filtered.stream().sorted((o1, o2) -> Integer.compare(o1.getPriority(), o2.getPriority())).collect(Collectors.toList());
             
             
@@ -96,11 +110,13 @@ public class ModelledSTSRunner extends ParentRunner<ModelledSTSSuiteRunner> {
 
     private void initialize0() throws Exception {
         AcornTests.newSimanticsWorkspace(null, null);
+        org.simantics.debug.browser.internal.Activator.getDefault().startDebugServer();
         initialize();
     }
 
     private void deinitialize0() throws Exception {
         deinitialize();
+        org.simantics.debug.browser.internal.Activator.getDefault().stopDebugServer();
         Simantics.shutdown(new NullProgressMonitor());
     }
 }
index 11931d824c3990c432aece73020949d1bb058491..ac42653e57d5536ce776cfd47092413b3ca8ef86 100644 (file)
@@ -25,11 +25,40 @@ public class ModelledSTSSuiteRunner extends ParentRunner<ModelledSTSTestRunner>
         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 = false;
+            if (exclusionFilter != null) {
+                String[] filters = exclusionFilter.split(",");
+                if (!startsWithAny(test, filters)) {
+                    add = true;
+                }
+            }
+            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();
@@ -61,7 +90,8 @@ public class ModelledSTSSuiteRunner extends ParentRunner<ModelledSTSTestRunner>
                 }
                 notifier.fireTestStarted(description);
                 List<CommandSessionVariable> 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 (Throwable e) {
                 notifier.fireTestFailure(new Failure(description, e));
index 33e4c25e2fc6b2f121bd3e6264a1ede8b3f09068..c0ed9b191420604d49cfc73edd636d9f00928920 100644 (file)
@@ -94,6 +94,7 @@ public class ModelledSTSTest {
     
     public List<CommandSessionVariable> run(List<CommandSessionVariable> vars) throws IOException {
         ModuleRepository repo = new ModuleRepository(SCLOsgi.SOURCE_REPOSITORY);
+        CommandSession session = null;
         try {
             repo.setAdvisor(new ModuleCompilationOptionsAdvisor() {
                 
@@ -113,7 +114,7 @@ public class ModelledSTSTest {
             });
             
             SCLReportingHandler handler = (SCLReportingHandler) SCLContext.getCurrent().get(SCLReportingHandler.REPORTING_HANDLER);
-            CommandSession session = new CommandSession(repo, handler);
+            session = new CommandSession(repo, handler);
             
             for (CommandSessionVariable var : vars)
                 session.setVariable(var.getName(), var.getType(), var.getValue());