Author: plenyi(a)redhat.com
Date: 2010-10-18 03:37:15 -0400 (Mon, 18 Oct 2010)
New Revision: 13889
Modified:
branches/community/Seam_2_2/src/test/ftest/build.xml
Log:
JBQA-3275: Fixed bugs regarding relative paths, failure counting and other minor fixes in
the Groovy script.
Modified: branches/community/Seam_2_2/src/test/ftest/build.xml
===================================================================
--- branches/community/Seam_2_2/src/test/ftest/build.xml 2010-10-16 05:42:05 UTC (rev
13888)
+++ branches/community/Seam_2_2/src/test/ftest/build.xml 2010-10-18 07:37:15 UTC (rev
13889)
@@ -396,6 +396,7 @@
<echo message="Rewriting ftest output xml files." />
<groovy>
<arg value="@{container}" />
+ <arg value="${seam.dir}" />
<classpath>
<pathelement location="../../../lib/ftest/xmlunit.jar" />
</classpath>
@@ -404,7 +405,8 @@
import org.custommonkey.xmlunit.XMLUnit
import groovy.xml.StreamingMarkupBuilder
- def container = args[0];
+ String container = args[0];
+ String seamHome = args[1];
def slurper = new XmlSlurper();
def builder = new StreamingMarkupBuilder();
builder.encoding = "UTF-8";
@@ -415,8 +417,9 @@
replace 'SKIP' with 'FAIL'
insert child '<exception
class="java.lang.Error"><message><![CDATA[Deployment in error.]
]></message><full-stacktrace><![CDATA[ ]
]></full-stacktrace></exception>'
*/
- def xmlFile = new
File("../../../test-output/testng-results.xml");
- ant.echo 'Checking
"../../../test-output/testng-results.xml"';
+ String xmlFilePath = seamHome +
"/test-output/testng-results.xml";
+ File xmlFile = new File(xmlFilePath);
+ ant.echo 'Checking: ' + xmlFilePath;
assert xmlFile.exists() && xmlFile.isFile();
def root = slurper.parse(xmlFile);
@@ -428,14 +431,15 @@
it.appendNode { exception(class:'java.lang.Error') {
message("Deployment in error.") } }
}
- def writer = new
FileWriter("../../../test-output/testng-results-edit.xml");
+ String xmlFileEditPath = seamHome +
"/test-output/testng-results-edit.xml";
+ def writer = new FileWriter(xmlFileEditPath);
writer << "<testng-results>";
writer << builder.bind(root.getBody());
writer << "</testng-results>";
writer.close();
- ant.delete(file:'../../../test-output/testng-results.xml');
-
ant.move(file:'../../../test-output/testng-results-edit.xml',tofile:'../../../test-output/testng-results.xml');
+ ant.delete(file:xmlFilePath);
+ ant.move(file:xmlFileEditPath,tofile:xmlFilePath);
/*
for each ${SEAM}/${EXAMPLE} example/
@@ -443,13 +447,11 @@
remove elements containing '@' - beforeMethod and
afterMethod failures incorrectly counted as testcases
replace '<skipped />' with '<failure
message="Test skipped." type="java.lang.Error" />'
*/
- def testOutDir = new File("../../../test-output");
+ File testOutDir = new File(seamHome + "/test-output");
assert testOutDir.exists() && testOutDir.isDirectory();
testOutDir.eachDir { dir ->
ant.echo "Checking " + dir.getName();
- String exampleName;
- String xmlFilePath;
- String xmlFileEditPath;
+ String exampleName = null;
dir.eachFile { f ->
if (f.isFile() && f.getName().matches(".*_" +
container + ".*\\.xml")) {
@@ -457,20 +459,24 @@
xmlFilePath = f.getAbsolutePath();
xmlFileEditPath = xmlFilePath.substring(0, xmlFilePath.length() -
4) + "-edit.xml";
xmlFile = new File(xmlFilePath);
- ant.echo "DEBUG Parsing file " + xmlFile.getName();
if (xmlFile.exists() && xmlFile.isFile()) {
root = slurper.parse(xmlFile);
def tsName = root.attributes().get("name");
def tsTime = root.attributes().get("time");
def tsTests = root.attributes().get("tests");
+ def tsFailures = root.attributes().get("failures");
+ def tsErrors = root.attributes().get("errors");
serviceMethods = root.testcase.findAll {
it.@name.toString().contains("(a)") }
serviceMethods.each { it.replaceNode {} }
- root.testcase.skipped.replaceNode { node ->
failure(message:'Test skipped.',type:'java.lang.Error.') }
+ root.testcase.skipped.replaceNode { node ->
+ failure(message:'Test
skipped.',type:'java.lang.Error.');
+ tsErrors++;
+ }
writer = new FileWriter(xmlFileEditPath);
writer << "<" + "?xml
version=\"1.0\" encoding=\"UTF-8\" ?" + ">";
- writer << '<testsuite name="' + tsName +
'" failures="0" tests="' + tsTests + '"
time="' + tsTime + '" errors="' + tsTests +
'">';
+ writer << '<testsuite name="' + tsName +
'" failures="' + tsFailures + '" tests="' + tsTests +
'" time="' + tsTime + '" errors="' + tsErrors +
'">';
writer << builder.bind(root.getBody());
writer << "</testsuite>";
writer.close();
@@ -478,9 +484,6 @@
ant.delete(file:xmlFilePath);
ant.move(file:xmlFileEditPath,tofile:xmlFilePath);
}
- else {
- println dir.getName() + "does not contain any xml file
with test results (Looking for " + xmlFilePath + "). Skipping this
directory."
- }
}
}
}
Show replies by date