From f7366f1b18cdb142c8940f6ad48141f757ea4dde Mon Sep 17 00:00:00 2001
From: davidely <davidely@localhost>
Date: Mon, 16 Jul 2007 17:22:23 +0000
Subject: [PATCH] Added ability to perform a coveragediff against an svn revision other than BASE. This will be used to perform a coveragdiff between two consecutive svn revisions, i.e. after a commit.
---
opends/build.xml | 15 ++++++++++++++-
opends/src/build-tools/org/opends/build/tools/CoverageDiff.java | 41 +++++++++++++++++++++++++++++++++++------
2 files changed, 49 insertions(+), 7 deletions(-)
diff --git a/opends/build.xml b/opends/build.xml
index 43a0b9c..6b5b0f6 100644
--- a/opends/build.xml
+++ b/opends/build.xml
@@ -1125,6 +1125,18 @@
<isset property="test.diff.disable" />
</condition>
+ <!-- The SVN revision to perform the diff against when calculating
+ the coverage diff. It can be a revision number, a timestamp,
+ or a revision keyword (BASE, COMMITTED, and PREV make the
+ most sense). The primary use case for this setting is to do
+ a coverage diff against the previous revision when there are
+ no changes in the working copy. It defaults to BASE. -->
+ <condition property="test.diff.from.revision" value="BASE">
+ <not>
+ <isset property="test.diff.from.revision" />
+ </not>
+ </condition>
+
<mkdir dir="${cvgdiff.report.dir}" />
<taskdef name="coveragediff" classname="org.opends.build.tools.CoverageDiff">
<classpath>
@@ -1144,7 +1156,8 @@
outputpath="${cvgdiff.report.dir}"
diffpath="${test.diff.srcpath}"
enabled="${test.diff.enabled}"
- verbose="${test.diff.verbose}" />
+ verbose="${test.diff.verbose}"
+ fromrevision="${test.diff.from.revision}" />
</target>
diff --git a/opends/src/build-tools/org/opends/build/tools/CoverageDiff.java b/opends/src/build-tools/org/opends/build/tools/CoverageDiff.java
index b55da4f..37b9ff4 100644
--- a/opends/src/build-tools/org/opends/build/tools/CoverageDiff.java
+++ b/opends/src/build-tools/org/opends/build/tools/CoverageDiff.java
@@ -38,11 +38,14 @@
import org.apache.tools.ant.BuildException;
import org.tmatesoft.svn.core.SVNException;
+import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
import org.tmatesoft.svn.core.wc.SVNDiffClient;
import org.tmatesoft.svn.core.wc.SVNRevision;
+import org.tmatesoft.svn.core.wc.SVNWCUtil;
public class CoverageDiff extends Task {
+ private static final String EOL = System.getProperty("line.separator");
private boolean verbose = false;
private boolean enabled = true;
@@ -109,6 +112,14 @@
private File outputPath;
private String diffPath;
+ // The SVN revision to perform the diff against when calculating
+ // the coverage diff. It can be a revision number, a timestamp,
+ // or a revision keyword (BASE, COMMITTED, and PREV make the
+ // most sense). The primary use case for this setting is to do
+ // a coverage diff against the previous revision when there are
+ // no changes in the working copy. It defaults to BASE.
+ private String fromRevision;
+
public void setEmmaDataPath(String file)
{
emmaDataPath = new File(file);
@@ -134,6 +145,11 @@
enabled = bol.toLowerCase().equals("true");
}
+ public void setFromRevision(String fromRevision)
+ {
+ this.fromRevision = fromRevision;
+ }
+
public void execute() throws BuildException {
try {
innerExecute();
@@ -157,12 +173,19 @@
{
throw new BuildException("outputPath attribute is not set. It must be set to a valid directory where the report will be generated");
}
+ if(fromRevision == null)
+ {
+ throw new BuildException("fromRevision attribute is not set. It must be set to the revision from which the diff is generated (e.g. BASE).");
+ }
if(!enabled)
{
return;
}
+ // So we can go over http:// and https:// when diff'ing against previous versions
+ DAVRepositoryFactory.setup();
+
IReportDataView emmaDataView = null;
try
{
@@ -182,6 +205,7 @@
catch(IOException ie)
{
System.out.println("ERROR: An error occurred while processing diff output: " + ie.toString() + " Quitting...");
+ ie.printStackTrace();
return;
}
System.out.println("Coverage diff completed in " + (System.currentTimeMillis() - start) + " ms.");
@@ -276,10 +300,13 @@
SVNDiffClient svnClient = new SVNDiffClient(null, null);
- File diffFile = File.createTempFile("coverage", "diff");
- diffFile.deleteOnExit();
+ File diffFile = new File(outputPath, "svn.diff");
- svnClient.doDiff(workspaceRoot, SVNRevision.BASE, workspaceRoot,
+ // Most often this will be 'BASE' but it could also be 'PREVIOUS'
+ SVNRevision baseRevision = SVNRevision.parse(fromRevision);
+ System.out.println("Doing coverage diff from revision: " + baseRevision.toString());
+
+ svnClient.doDiff(workspaceRoot, baseRevision, workspaceRoot,
SVNRevision.WORKING, true, false,
new FileOutputStream(diffFile));
@@ -503,7 +530,7 @@
revisionStr = secondFileLine.substring(secondFileLine.lastIndexOf("("));
}
- if(firstFileLine.endsWith("(revision 0)") &&
+ if(firstFileLine.endsWith("(revision 0)") ||
secondFileLine.endsWith("(revision 0)"))
{
workingCopyFlag = "+";
@@ -512,7 +539,9 @@
if(workingCopyFlag == null || otherCopyFlag == null)
{
- throw new IOException("Error occurred while parsing diff output");
+ throw new IOException("Error occurred while parsing diff output." + EOL +
+ "firstFileLine= '" + firstFileLine + "'" + EOL +
+ "secondFileLine= '" + secondFileLine + "'");
}
else
{
@@ -593,7 +622,7 @@
}
else
{
- html.addH(2, "Coverage Information Not Available", null);
+ html.addH(2, "Coverage Information Not Available (e.g. file is not in src/, is not java, is an interface, or was deleted)", null);
}
if(srcTable != null)
--
Gitblit v1.10.0