You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ka...@apache.org on 2012/06/07 17:17:15 UTC

svn commit: r1347667 - in /db/derby/code/trunk: build.xml java/testing/org/apache/derbyTesting/junit/BaseTestCase.java

Author: kahatlen
Date: Thu Jun  7 15:17:15 2012
New Revision: 1347667

URL: http://svn.apache.org/viewvc?rev=1347667&view=rev
Log:
DERBY-5801: Sub-processes should write EMMA coverage data to separate files

Modified:
    db/derby/code/trunk/build.xml
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java

Modified: db/derby/code/trunk/build.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/build.xml?rev=1347667&r1=1347666&r2=1347667&view=diff
==============================================================================
--- db/derby/code/trunk/build.xml (original)
+++ db/derby/code/trunk/build.xml Thu Jun  7 15:17:15 2012
@@ -2739,7 +2739,7 @@ you should not have to do this.
                     <pathelement path="${derby.storeless.src.dir}" />
                     <pathelement path="${derby.tools.src.dir}" />
                 </sourcepath>
-                <infileset dir="junit_${derby.junit.timestamp}" includes="coverage.em,coverage.ec" />
+                <infileset dir="junit_${derby.junit.timestamp}" includes="coverage.em,coverage*.ec" />
                 <!-- Three reports: txt, xml and html -->
                 <txt outfile="junit_${derby.junit.timestamp}/coverage.txt"/>
                 <xml outfile="junit_${derby.junit.timestamp}/coverage.xml"/>

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java?rev=1347667&r1=1347666&r2=1347667&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/BaseTestCase.java Thu Jun  7 15:17:15 2012
@@ -559,6 +559,13 @@ public abstract class BaseTestCase
             cmdlist.add("-Xmx32M");
         }
 
+        if (runsWithEmma()) {
+            // DERBY-5801: If many processes write to the same file, it may
+            // end up corrupted. Let each process have its own file to which
+            // it writes coverage data.
+            cmdlist.add("-Demma.coverage.out.file=" + getEmmaOutFile());
+        }
+
 	    cmdlist.add("-classpath");
 	    cmdlist.add(getSystemProperty("java.class.path"));
 	    for (int i =0; i < cmd.length;i++) {
@@ -724,6 +731,22 @@ public abstract class BaseTestCase
         return getSystemProperty("java.class.path").indexOf("emma.jar") != -1;
     }
 
+    /**
+     * Counter used by {@link #getEmmaOutFile()} to produce unique file names.
+     */
+    private static int emmaCount = 0;
+
+    /**
+     * Get a unique file object that can be used by sub-processes to store
+     * EMMA code coverage data. Each separate sub-process should have its
+     * own file in order to prevent corruption of the coverage data.
+     *
+     * @return a file to which a sub-process can write code coverage data
+     */
+    private static synchronized File getEmmaOutFile() {
+        return new File(currentDirectory(),
+                "coverage-" + (++emmaCount) + ".ec");
+    }
 
     /**
      * Returns the major version of the class specification version supported