]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Log test name before and after execution with timeout and exec time 74/3174/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 30 Aug 2019 06:53:56 +0000 (09:53 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Fri, 30 Aug 2019 06:53:56 +0000 (09:53 +0300)
gitlab #367

Change-Id: I3ff6b1da4e773987bfc1d83fee9cef3f302a3d5e

bundles/org.simantics.db.testing/src/org/simantics/db/testing/base/SCLScriptTestBase.java
bundles/org.simantics.db.testing/src/org/simantics/db/testing/cases/FreshDatabaseTest.java
bundles/org.simantics.db.testing/src/org/simantics/db/testing/cases/FreshWorkspaceTest.java
bundles/org.simantics.db.testing/src/org/simantics/db/testing/common/TestBase.java
bundles/org.simantics/src/org/simantics/SimanticsPlatform.java

index 1ea9e6a546d0e77a6469e4bef55d69478e2adeb3..459be8d4a62228c70c52430c143c0459242706db 100644 (file)
@@ -81,8 +81,10 @@ public class SCLScriptTestBase extends FreshDatabaseTest {
 
         String testName = resolveTestName();
         TestRunnable runnable = testRunnables.get(testName);
+        long start = System.nanoTime(); 
 
         if (timeout > -1) {
+            LOGGER.info("Running test {} with a timeout of {} seconds", testName, timeout); //$NON-NLS-1$
             Timer timer = new Timer();
             timer.schedule(new TimerTask() {
 
@@ -104,14 +106,19 @@ public class SCLScriptTestBase extends FreshDatabaseTest {
             }, timeout*1000);
             try {
                 runnable.run();
+                long end = System.nanoTime();
+                LOGGER.info("Completed test {} execution in {} seconds", testName, String.format("%.3f", (end-start)*1e-9)); //$NON-NLS-1$
             } catch (Exception e) {
                 LOGGER.error("Failed to run test {} runnable {}", testName, runnable, e);
             } finally {
                 timer.cancel();
             }
         } else {
+            LOGGER.info("Running test {} without timeout", testName); //$NON-NLS-1$
             try {
                 runnable.run();
+                long end = System.nanoTime();
+                LOGGER.info("Completed test {} execution in {} seconds", testName, String.format("%.3f", (end-start)*1e-9)); //$NON-NLS-1$
             } catch (Exception e) {
                 LOGGER.error("Failed to run test {} runnable {}", testName, runnable, e);
             }
index 53ddfb04fc0a1ceaa26c88586bfb684f5427c50a..9ad9faf77a4bc3e2e85c69cd2172ddcd4b27df8f 100644 (file)
@@ -1,4 +1,3 @@
-package org.simantics.db.testing.cases;
 /*******************************************************************************
  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
  * in Industry THTH ry.
@@ -10,7 +9,7 @@ package org.simantics.db.testing.cases;
  * Contributors:
  *     VTT Technical Research Centre of Finland - initial API and implementation
  *******************************************************************************/
-
+package org.simantics.db.testing.cases;
 
 import org.junit.After;
 import org.junit.Before;
@@ -25,7 +24,6 @@ import org.simantics.db.testing.common.Tests;
 public class FreshDatabaseTest extends TestBase {
 
     public void configure(TestSettings settings) {
-
     }
 
     @Before
index 0de0785646f8865d4e020504e0e797ef7a19021a..bc46815502c25952aa6a1815af9cbb0528e41b88 100644 (file)
@@ -8,23 +8,22 @@ import org.simantics.db.testing.common.Tests;
 import org.simantics.db.testing.impl.Configuration;
 
 public class FreshWorkspaceTest extends TestBase {
-       
+
        public void configure(TestSettings settins) {
        }
-       
+
        @Before
        public void setUp() throws Exception {
-               
                TestBase.printStart(this);
                configure(TestSettings.getInstanceUnsafe());
                state = Tests.freshWorkspace(Configuration.get().coreDir, initialWorkspaceFiles);
                super.setUp();
        }
-       
-    @After
-    public void tearDown() throws Exception {
-       
-       Tests.shutdown(state);
-       super.tearDown();
-    }
+
+       @After
+       public void tearDown() throws Exception {
+               Tests.shutdown(state);
+               super.tearDown();
+       }
+
 }
index 73e6ff8f13b47377064af2f7a2041aefe5da829b..d08caea4c4574a705d6ff49d5588c5f03555e47a 100644 (file)
@@ -58,7 +58,7 @@ public abstract class TestBase {
     static boolean printStart = true;
     public static final ArrayList<String> initialWorkspaceFiles = FileUtils.createFileFilter(Platform.getLocation().toFile(), null);
     public static void printStart(Object t) {
-        if(printStart) LOGGER.info("Test is {}", t.getClass().getName());
+        if(printStart) LOGGER.info("Test class is {}", t.getClass().getName());
     }
     protected static void setPrintStart(boolean value) {
         printStart = value;
index 7839ce70db31de7b0de4dc80d6725e8dc603b505..c0a85cd1ac1c06343b7a9bfb516b2efb84eb80fc 100644 (file)
@@ -678,10 +678,11 @@ public class SimanticsPlatform implements LifecycleListener {
     }
 
     public void resetDatabase(IProgressMonitor monitor) throws PlatformException {
+        // TODO: fix this to use Path APIs
         File dbLocation = Platform.getLocation().append("db").toFile();
         if(!dbLocation.exists()) return;
         try { // Load driver
-            Driver driver = Manager.getDriver("procore");
+            Driver driver = Manager.getDriver("acorn");
             Management management = driver.getManagement(dbLocation.getAbsolutePath(), null);
             management.delete();
         } catch (DatabaseException e) {