Skip to content
Snippets Groups Projects
Commit 90799a6e authored by david_williams's avatar david_williams
Browse files

[172361] WTP 2.0 build page didn't reflect compile error in I200701311715 build

parent 9fd3a5aa
No related branches found
No related tags found
No related merge requests found
......@@ -5,10 +5,11 @@ import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.Writer;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.StringTokenizer;
......@@ -16,24 +17,36 @@ import java.util.Vector;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerFactoryConfigurationError;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Text;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
* This class was original based on TestResultsGenerator.java
* from the org.eclilpse.build.tools project in the basebuilder.
* This class was original based on TestResultsGenerator.java from the
* org.eclilpse.build.tools project in the basebuilder.
*
*/
public class ResultsSummaryGenerator extends Task {
private static final String WARNING_SEVERITY = "WARNING";
private static final String ERROR_SEVERITY = "ERROR";
private static final String ForbiddenReferenceID = "ForbiddenReference";
......@@ -41,7 +54,7 @@ public class ResultsSummaryGenerator extends Task {
private static final int DEFAULT_READING_SIZE = 8192;
private String EOL = System.getProperty("line.separator");
static final String elementName = "testsuite";
static final String testResultsToken = "%testresults%";
static final String compileLogsToken = "%compilelogs%";
......@@ -157,6 +170,7 @@ public class ResultsSummaryGenerator extends Task {
public void execute() {
try {
anErrorTracker = new ErrorTracker();
platformDescription = new Vector();
platformTemplateString = new Vector();
......@@ -201,32 +215,130 @@ public class ResultsSummaryGenerator extends Task {
else {
writeDropIndexFile();
}
}
catch (Exception e) {
throw new BuildException(e);
}
}
public void parseCompileLogs() {
private void parseCompileLogs() throws TransformerFactoryConfigurationError, IOException, TransformerException {
totalErrors = 0;
totalAccess = 0;
totalWarnings = 0;
rowCount = 0;
totaldiscouragedAccessWarningCount = 0;
totalforbiddenAccessWarningCount = 0;
StringBuffer replaceString = new StringBuffer();
processCompileLogsDirectory(compileLogsDirectoryName, replaceString);
writeFormattedTotals(replaceString);
writeCompileSummaryTotalsAsXML(compileLogsDirectoryName);
if (replaceString.length() == 0) {
replaceString.append("None");
}
testResultsTemplateString = replace(testResultsTemplateString, compileLogsToken, String.valueOf(replaceString));
}
/**
* @param mainSummaryName
* @throws TransformerException
* @throws IOException
* @throws TransformerFactoryConfigurationError
*/
private void writeCompileSummaryTotalsAsXML(String mainSummaryName) throws TransformerFactoryConfigurationError, IOException, TransformerException {
String outputFileName = mainSummaryName + "Summary" + ".xml";
// debug
System.out.println("dropDirectoryName: " + dropDirectoryName);
System.out.println("outputFileName: " + outputFileName);
//File fileDir = new File(dropDirectoryName);
File file = new File(outputFileName);
file.createNewFile();
Node rootNode = createNewDOM("compileSummary");
addSummaryNodeTo(rootNode, "totalBundles", rowCount);
addSummaryNodeTo(rootNode, "totalErrors", totalErrors);
addSummaryNodeTo(rootNode, "totalWarnings", totalWarnings);
addSummaryNodeTo(rootNode, "totalAccess", totalAccess);
addSummaryNodeTo(rootNode, "totaldiscouragedAccessWarningCount", totaldiscouragedAccessWarningCount);
addSummaryNodeTo(rootNode, "totalforbiddenAccessWarningCount", totalforbiddenAccessWarningCount);
serialize(rootNode, file);
}
protected void serialize(Node rootNode, File outputFile) throws TransformerFactoryConfigurationError, IOException, TransformerException {
// JAXP transformation
Document sourceDocument = rootNode.getOwnerDocument();
Source domSource = new DOMSource(sourceDocument);
Transformer serializer = TransformerFactory.newInstance().newTransformer();
try {
serializer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); //$NON-NLS-1$ //$NON-NLS-2$
}
catch (IllegalArgumentException e) {
// unsupported properties, so we'll just ignore
}
Writer outputWriter = null;
try {
outputWriter = new FileWriter(outputFile);
serializer.transform(domSource, new StreamResult(outputWriter));
}
finally {
if (outputWriter != null) {
outputWriter.close();
}
}
}
/**
* <summaryItem>
* <name>someName</name>
* <value>8</value>
* </summaryItem>
* @param dom
*/
private void addSummaryNodeTo(Node rootNode, String itemName, int intdata) {
Document dom = rootNode.getOwnerDocument();
Element summaryElement = dom.createElement("summaryItem");
Element nameElement = dom.createElement("name");
Element valueElement = dom.createElement("value");
summaryElement.appendChild(nameElement);
summaryElement.appendChild(valueElement);
Text name = dom.createTextNode(itemName);
Text value = dom.createTextNode(String.valueOf(intdata));
nameElement.appendChild(name);
valueElement.appendChild(value);
rootNode.appendChild(summaryElement);
}
private Node createNewDOM(String rootElementName) {
Document document = null;
Node rootNode = null;
try {
document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
}
catch (ParserConfigurationException e) {
log("exception creating document: " + e.getMessage()); //$NON-NLS-1$
}
catch (FactoryConfigurationError e) {
log("exception creating document: " + e.getMessage()); //$NON-NLS-1$
}
if (document != null) {
rootNode = document.appendChild(document.createElement(rootElementName));
}
return rootNode;
}
private void processCompileLogsDirectory(String directoryName, StringBuffer buffer) {
if (buffer == null) {
throw new RuntimeException("write buffer can not be null");
}
}
File sourceDirectory = new File(directoryName);
......@@ -244,14 +356,14 @@ public class ResultsSummaryGenerator extends Task {
}
}
}
/**
*
*/
private void writeFormattedTotals(StringBuffer buffer) {
if (buffer == null) {
throw new RuntimeException("write buffer can not be null");
}
......@@ -268,24 +380,11 @@ public class ResultsSummaryGenerator extends Task {
}
//
System.out.println("totalErrors: " + totalErrors); // ,
//log("totalErrors: " + totalErrors, Project.MSG_INFO);
buffer.append("<tr CLASS=\"" + rowtype + " " + "bold" + "\">" + EOL + "<td>" + EOL)
.append("TOTALS (" + rowCount + ")")
.append("</td><td CLASS=\"numeric\">")
.append(totalErrors)
.append("</td><td CLASS=\"numeric\">")
.append(totalAccess)
.append("(")
.append(totalforbiddenAccessWarningCount)
.append("/")
.append(totaldiscouragedAccessWarningCount)
.append(")")
.append("</td><td CLASS=\"numeric\">")
.append(totalWarnings)
.append("</td>" + EOL + "</tr>" + EOL);
// log("totalErrors: " + totalErrors, Project.MSG_INFO);
buffer.append("<tr CLASS=\"" + rowtype + " " + "bold" + "\">" + EOL + "<td>" + EOL).append("TOTALS (" + rowCount + ")").append("</td><td CLASS=\"numeric\">").append(totalErrors).append("</td><td CLASS=\"numeric\">").append(totalAccess).append("(").append(totalforbiddenAccessWarningCount).append("/").append(totaldiscouragedAccessWarningCount).append(")").append("</td><td CLASS=\"numeric\">").append(totalWarnings).append("</td>" + EOL + "</tr>" + EOL);
}
private void readCompileLog(String log, StringBuffer buffer) {
......@@ -427,9 +526,9 @@ public class ResultsSummaryGenerator extends Task {
int amountRead = -1;
do {
int amountRequested = Math.max(stream.available(), DEFAULT_READING_SIZE); // read
// at
// least
// 8K
// at
// least
// 8K
// resize contents if needed
if (contentsLength + amountRequested > contents.length) {
......@@ -750,10 +849,10 @@ public class ResultsSummaryGenerator extends Task {
}
private void writeFile(String outputFileName, String contents) {
FileOutputStream outputStream = null;
FileWriter outputWriter = null;
try {
outputStream = new FileOutputStream(outputFileName);
outputStream.write(contents.getBytes());
outputWriter = new FileWriter(outputFileName);
outputWriter.write(contents);
}
catch (FileNotFoundException e) {
System.out.println("File not found exception writing: " + outputFileName);
......@@ -762,12 +861,12 @@ public class ResultsSummaryGenerator extends Task {
System.out.println("IOException writing: " + outputFileName);
}
finally {
if (outputStream != null) {
if (outputWriter != null) {
try {
outputStream.close();
outputWriter.close();
}
catch (IOException e) {
// ignore
System.out.println("IOException closing: " + outputFileName);
}
}
}
......@@ -816,9 +915,9 @@ public class ResultsSummaryGenerator extends Task {
private void formatCompileErrorRow(String fileName, int errorCount, int warningCount, int forbiddenAccessWarningCount, int discouragedAccessWarningCount, StringBuffer buffer) {
int accessRuleWarningCount = forbiddenAccessWarningCount + discouragedAccessWarningCount;
totalErrors=totalErrors + errorCount;
totalAccess=totalAccess + accessRuleWarningCount;
totalWarnings=totalWarnings + warningCount;
totalErrors = totalErrors + errorCount;
totalAccess = totalAccess + accessRuleWarningCount;
totalWarnings = totalWarnings + warningCount;
totalforbiddenAccessWarningCount = totalforbiddenAccessWarningCount + forbiddenAccessWarningCount;
totaldiscouragedAccessWarningCount = totaldiscouragedAccessWarningCount + discouragedAccessWarningCount;
rowCount = rowCount + 1;
......@@ -833,70 +932,47 @@ public class ResultsSummaryGenerator extends Task {
String shortName = fileName.substring(pos + getHrefCompileLogsTargetPath().length());
String displayName = shortName;
String stripString = "/plugins/";
pos = displayName.indexOf(stripString);
if (pos != -1) {
displayName = displayName.substring(pos + stripString.length());
}
// we assume there's always a slash preceeding filename
pos = displayName.lastIndexOf('/');
if (pos != -1) {
displayName = displayName.substring(0, pos);
}
// if there's any remaining slashes ... it is one or more
// subdirectories of where jars are, so we need to
// if there's any remaining slashes ... it is one or more
// subdirectories of where jars are, so we need to
// save before we strip off version numbers
String remaining = null;
pos = displayName.indexOf('/');
if (pos != -1) {
remaining = displayName.substring(pos);
displayName = displayName.substring(0,pos);
}
displayName = displayName.substring(0, pos);
}
displayName = stripOffVersionNumber(displayName);
if (remaining != null) {
displayName = displayName + remaining;
}
String rowtype = "normaltable";
if (errorCount > 0) {
rowtype="errortable";
rowtype = "errortable";
}
else if (warningCount > 0) {
rowtype = "warningtable";
if (warningCount > 15) {
rowtype="extraWarningTable";
rowtype = "extraWarningTable";
}
}
buffer.append("<tr CLASS=\"" + rowtype + "\">" + EOL + "<td>" + EOL)
.append("<a href=")
.append("\"")
.append(getHrefCompileLogsTargetPath())
.append(shortName)
.append("\" type='text/plain' ").append(">")
.append(displayName).append("</a>")
.append("</td><td CLASS=\"numeric\">")
.append("<a href=").append("\"")
.append(getHrefCompileLogsTargetPath())
.append(shortName).append("#ERRORS")
.append("\" type='text/plain' ").append(">")
.append(errorCount)
.append("</a>").append("</td><td CLASS=\"numeric\">")
.append("<a href=").append("\"")
.append(getHrefCompileLogsTargetPath()).append(shortName)
.append("#ACCESSRULES_WARNINGS")
.append("\" type='text/plain' ").append(">")
.append(accessRuleWarningCount).append("</a>")
.append("(").append(forbiddenAccessWarningCount).append("/").append(discouragedAccessWarningCount).append(")")
.append("</td><td CLASS=\"numeric\">")
.append("<a href=").append("\"").append(getHrefCompileLogsTargetPath()).append(shortName).append("#OTHER_WARNINGS")
.append("\" type='text/plain' ").append(">")
.append(warningCount)
.append("</a>").append("</td>" + EOL + "</tr>" + EOL);
buffer.append("<tr CLASS=\"" + rowtype + "\">" + EOL + "<td>" + EOL).append("<a href=").append("\"").append(getHrefCompileLogsTargetPath()).append(shortName).append("\" type='text/plain' ").append(">").append(displayName).append("</a>").append("</td><td CLASS=\"numeric\">").append("<a href=").append("\"").append(getHrefCompileLogsTargetPath()).append(shortName).append("#ERRORS").append("\" type='text/plain' ").append(">").append(errorCount).append("</a>").append("</td><td CLASS=\"numeric\">").append("<a href=").append("\"").append(getHrefCompileLogsTargetPath()).append(shortName).append("#ACCESSRULES_WARNINGS").append("\" type='text/plain' ").append(">").append(accessRuleWarningCount).append("</a>").append("(").append(forbiddenAccessWarningCount).append("/").append(discouragedAccessWarningCount).append(")").append("</td><td CLASS=\"numeric\">").append("<a href=").append("\"").append(getHrefCompileLogsTargetPath()).append(shortName).append("#OTHER_WARNINGS").append(
"\" type='text/plain' ").append(">").append(warningCount).append("</a>").append("</td>" + EOL + "</tr>" + EOL);
}
/**
......@@ -907,9 +983,10 @@ public class ResultsSummaryGenerator extends Task {
String result = displayName;
nameParser.parse(result);
result = nameParser.getProjectString();
// debug and test
//System.out.println("project: " + result + " version: " + nameParser.getVersionString());
// System.out.println("project: " + result + " version: " +
// nameParser.getVersionString());
return result;
}
......
<?php
function count_pattern($directory, $filenameFilter, $pattern)
{
$count = 0;
$dir = dir($directory);
while ($anEntry = $dir->read())
{
if ($anEntry != "." && $anEntry != "..")
{
$anEntry = $directory."/".$anEntry;
if (is_dir($anEntry))
{
$count += count_pattern($anEntry, $filenameFilter, $pattern);
}
else
{
if (stristr($anEntry, $filenameFilter))
{
$handle = @fopen($anEntry, "r");
if (FALSE !== $handle) {
$size = filesize($anEntry);
$content = fread($handle, $size);
fclose($handle);
$count += substr_count($content, $pattern);
}
}
}
}
}
return $count;
}
function parse_testResults($filename)
{
......@@ -69,115 +38,7 @@ function parse_testResults($filename)
}
}
}
function parse_compileResults($filename)
{
$compileErrors = 0;
$compileAccessWarnings = 0;
$compileOtherWarnings = 0;
if (is_file($filename)) {
//echo "$filename<br />";
$handle = @fopen($filename, "r");
if ($handle)
{
$size = filesize($filename);
//echo "size: $size<br />";
$content = fread($handle, $size);
fclose($handle);
//echo "$content";
$compileStart = strpos($content, "<table id=tabledata");
$compileEnd = strpos($content, "</table", $compileStart);
$compileInfo = substr($content, $compileStart, $compileEnd - $compileStart);
//echo "compileInfo: $compileInfo<br />";
$rowStart = strpos($compileInfo, "<tr>");
$rowStart = strpos($compileInfo, "<tr>");
$start = $rowStart+4;
while ($rowStart !== false)
{
$start += 4;
$rowStop = strpos($compileInfo, "</tr>", $rowStart);
//if ($rowStop !== false)
//{
$row = substr($compileInfo, $rowStart, $rowStop - $rowStart);
//echo "$row";
//while ($cellStart !== false)
//{
// this parsing logic got a bit more complicated in M5_33 basebuild, as the
// a whole different structure was used.
// we'll try to quick fix this, but need our own index task
$cellStart = strpos($row, "#ERROR");
$cellStart = strpos($row, ">", $cellStart);
$cellStart = $cellStart + 1;
$cellStop = strpos($row, "<", $cellStart);
if ($cellStop !== false)
{
$cell = substr($row, $cellStart, $cellStop - $cellStart);
if (is_numeric($cell))
{
$compileErrors += $cell;
}
$cellStart = strpos($row, "#ACCESSRULES_WARNINGS");
$cellStart = strpos($row, ">", $cellStart);
$cellStart = $cellStart + 1;
$cellStop = strpos($row, "<", $cellStart);
$cell = substr($row, $cellStart, $cellStop - $cellStart);
if (is_numeric($cell))
{
$compileAccessWarnings += $cell;
}
$cellStart = strpos($row, "#OTHER_WARNINGS");
$cellStart = strpos($row, ">", $cellStart);
$cellStart = $cellStart + 1;
$cellStop = strpos($row, "<", $cellStart);
$cell = substr($row, $cellStart, $cellStop - $cellStart);
if (is_numeric($cell))
{
$compileOtherWarnings += $cell;
}
}
// look for next row.
//$cellStart = strpos($row, "<tr", $cellStop);
//}
//}
$rowStart = strpos($compileInfo, "<tr>", $rowStop);
}
}
}
$results = array($compileErrors, $compileAccessWarnings, $compileOtherWarnings);
return $results;
}
function parse($filename, $key)
{
if (!is_readable($filename))
{
return 0;
}
$value;
$handle = @fopen($filename, "r");
if (!$handle)
{
return 0;
}
$size = filesize($filename);
$content = fread($handle, $size);
fclose($handle);
$start = strpos($content, $key);
while ($start !== false)
{
$start += strlen($key);
$stop = strpos($content, "\"", $start);
if ($stop !== false)
{
$value += substr($content, $start, $stop - $start);
}
$start = strpos($content, $key, $stop);
}
return $value;
}
?>
......
......@@ -13,12 +13,34 @@
//error_reporting (E_ERROR | E_WARNING | E_PARSE | E_NOTICE );
include 'report2.php';
$testResults = parse_testResults("testResults.php");
list ($junitFailures) = $testResults;
$compileResults = parse_compileResults("compileResults.php");
list ($compileErrors, $compileAccessWarnings, $compileOtherWarnings) = $compileResults;
$testCompileResults = parse_compileResults("testCompileResults.php");
list ($testCompileErrors, $testCompileAccessWarnings, $testCompileOtherWarnings) = $testCompileResults;
$filename = "compilelogsSummary.xml";
$prefix = "code_";
$compileSummary = simplexml_load_file($filename);
foreach ($compileSummary->summaryItem as $summaryItem) {
$name = $summaryItem->name;
$value = $summaryItem->value;
$code= "\$" . $prefix . $name . " = " . $value . ";";
//echo "<br />code: " . $code;
eval($code);
}
$filename = "testcompilelogsSummary.xml";
$prefix = "test_";
$compileSummary = simplexml_load_file($filename);
foreach ($compileSummary->summaryItem as $summaryItem) {
$name = $summaryItem->name;
$value = $summaryItem->value;
$code= "\$" . $prefix . $name . " = " . $value . ";";
//echo "<br />code: " . $code;
eval($code);
}
?>
......@@ -53,16 +75,16 @@ echo "<img src=\"http://download.eclipse.org/webtools/downloads/junit_err.gif\"/
<br> <a href="compileResults.php">Compile logs: Code Bundles</a>
<?php
echo "<img src=\"http://download.eclipse.org/webtools/downloads/compile_err.gif\"/><font color=red>$compileErrors</font>&nbsp;";
echo "<img src=\"http://download.eclipse.org/webtools/downloads/compile_warn.gif\"/><font color=orange>$compileAccessWarnings</font>&nbsp;";
echo "<img src=\"http://download.eclipse.org/webtools/downloads/compile_warn.gif\"/><font color=orange>$compileOtherWarnings</font>&nbsp;";
echo "&nbsp;&nbsp;($code_totalBundles)&nbsp;&nbsp;";
echo "<img src=\"http://download.eclipse.org/webtools/downloads/compile_err.gif\"/><font color=red>$code_totalErrors</font>&nbsp;";
echo "<img src=\"http://download.eclipse.org/webtools/downloads/compile_warn.gif\"/><font color=orange>$code_totalWarnings</font>&nbsp;";
?>
<br> <a href="testCompileResults.php">Compile logs: Test Bundles</a>
<?php
echo "<img src=\"http://download.eclipse.org/webtools/downloads/compile_err.gif\"/><font color=red>$testCompileErrors</font>&nbsp;";
echo "<img src=\"http://download.eclipse.org/webtools/downloads/compile_warn.gif\"/><font color=orange>$testCompileAccessWarnings</font>&nbsp;";
echo "<img src=\"http://download.eclipse.org/webtools/downloads/compile_warn.gif\"/><font color=orange>$testCompileOtherWarnings</font>&nbsp;";
echo "&nbsp;&nbsp;($test_totalBundles)&nbsp;&nbsp;";
echo "<img src=\"http://download.eclipse.org/webtools/downloads/compile_err.gif\"/><font color=red>$test_totalErrors</font>&nbsp;";
echo "<img src=\"http://download.eclipse.org/webtools/downloads/compile_warn.gif\"/><font color=orange>$test_totalWarnings</font>&nbsp;";
?>
<br>
<br>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment