Fixed test suite parsing of Eclipse Plug-in tests.

This commit is contained in:
Ulli Hafner committed 2011-03-22 11:57:54 +01:00
1 parent 314dd5fa4a
commit 08f38dd63f
4 files changed
+11296 -34

No files matched your search

@@ -1,18 +1,18 @@
/*
* The MIT License
*
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Erik Ramfelt, Xavier Le Vourch, Tom Huybrechts, Yahoo!, Inc.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -68,6 +68,8 @@ public final class SuiteResult implements Serializable {
* AFAICT, this is not a required attribute in XML, so the value may be null.
*/
private String timestamp;
/** Optional ID attribute of a test suite. E.g., Eclipse plug-ins tests always have the name 'tests' but a different id. **/
private String id;
/**
* All test cases.
@@ -130,6 +132,7 @@ public final class SuiteResult implements Serializable {
}
this.name = TestObject.safe(name);
this.timestamp = suite.attributeValue("timestamp");
this.id = suite.attributeValue("id");
Element ex = suite.element("error");
if(ex!=null) {
@@ -184,7 +187,7 @@ public final class SuiteResult implements Serializable {
/*package*/ void addCase(CaseResult cr) {
cases.add(cr);
duration += cr.getDuration();
duration += cr.getDuration();
}
@Exported(visibility=9)
@@ -194,7 +197,7 @@ public final class SuiteResult implements Serializable {
@Exported(visibility=9)
public float getDuration() {
return duration;
return duration;
}
/**
@@ -210,7 +213,7 @@ public final class SuiteResult implements Serializable {
/**
* The stderr of this test.
*
*
* @since 1.281
* @see CaseResult#getStderr()
*/
@@ -218,7 +221,7 @@ public final class SuiteResult implements Serializable {
public String getStderr() {
return stderr;
}
/**
* The absolute path to the original test report. OS-dependent.
*/
@@ -235,6 +238,11 @@ public final class SuiteResult implements Serializable {
return timestamp;
}
@Exported(visibility=9)
public String getId() {
return id;
}
@Exported(inline=true,visibility=9)
public List<CaseResult> getCases() {
return cases;
@@ -262,7 +270,7 @@ public final class SuiteResult implements Serializable {
}
return null;
}
public Set<String> getClassNames() {
Set<String> result = new HashSet<String>();
for (CaseResult c : cases) {
@@ -274,7 +282,7 @@ public final class SuiteResult implements Serializable {
/** KLUGE. We have to call this to prevent freeze()
* from calling c.freeze() on all its children,
* because that in turn calls c.getOwner(),
* which requires a non-null parent.
* which requires a non-null parent.
* @param parent
*/
void setParent(hudson.tasks.junit.TestResult parent) {
@@ -1,18 +1,18 @@
/*
* The MIT License
*
*
* Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Daniel Dyer, id:cactusman, Tom Huybrechts, Yahoo!, Inc.
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -85,16 +85,16 @@ public final class TestResult extends MetaTabulatedResult {
private transient int totalTests;
private transient int skippedTests;
private float duration;
/**
* Number of failed/error tests.
*/
private transient List<CaseResult> failedTests;
private final boolean keepLongStdio;
/**
* Creates an empty result.
*/
@@ -117,16 +117,16 @@ public final class TestResult extends MetaTabulatedResult {
this.keepLongStdio = keepLongStdio;
parse(buildTime, results);
}
public TestObject getParent() {
return parent;
}
@Override
public void setParent(TestObject parent) {
this.parent = parent;
}
@Override
public TestResult getTestResult() {
return this;
@@ -180,7 +180,8 @@ public final class TestResult extends MetaTabulatedResult {
for (SuiteResult s : suites) {
// a common problem is that people parse TEST-*.xml as well as TESTS-TestSuite.xml
// see http://www.nabble.com/Problem-with-duplicate-build-execution-td17549182.html for discussion
if(s.getName().equals(sr.getName()) && eq(s.getTimestamp(),sr.getTimestamp()))
if(s.getName().equals(sr.getName()) && eq(s.getTimestamp(),sr.getTimestamp())
&& eq(s.getId(),sr.getId()))
return; // duplicate
}
suites.add(sr);
@@ -230,7 +231,7 @@ public final class TestResult extends MetaTabulatedResult {
if (getId().equals(id) || (id == null)) {
return this;
}
String firstElement = null;
String subId = null;
int sepIndex = id.indexOf('/');
@@ -250,14 +251,14 @@ public final class TestResult extends MetaTabulatedResult {
sepIndex = subId.indexOf('/');
if (sepIndex < 0) {
packageName = subId;
subId = null;
subId = null;
} else {
packageName = subId.substring(0, sepIndex);
subId = subId.substring(sepIndex + 1);
}
} else {
packageName = firstElement;
subId = null;
subId = null;
}
PackageResult child = byPackage(packageName);
if (child != null) {
@@ -284,9 +285,9 @@ public final class TestResult extends MetaTabulatedResult {
@Exported(visibility=999)
@Override
public float getDuration() {
return duration;
return duration;
}
@Exported(visibility=999)
@Override
public int getPassCount() {
@@ -396,7 +397,7 @@ public final class TestResult extends MetaTabulatedResult {
*/
@Override
public String getErrorStackTrace() {
return "No error stack traces available at this level. Drill down to individual tests to find stack traces.";
return "No error stack traces available at this level. Drill down to individual tests to find stack traces.";
}
/**
@@ -425,7 +426,7 @@ public final class TestResult extends MetaTabulatedResult {
*/
@Override
public boolean hasChildren() {
return !suites.isEmpty();
return !suites.isEmpty();
}
@Exported(inline=true,visibility=9)
@@ -444,7 +445,7 @@ public final class TestResult extends MetaTabulatedResult {
if (token.equals(getId())) {
return this;
}
PackageResult result = byPackage(token);
if (result != null) {
return result;
@@ -460,25 +461,25 @@ public final class TestResult extends MetaTabulatedResult {
public SuiteResult getSuite(String name) {
return suitesByName.get(name);
}
@Override
public void setParentAction(AbstractTestResultAction action) {
this.parentAction = action;
tally(); // I want to be sure to inform our children when we get an action.
tally(); // I want to be sure to inform our children when we get an action.
}
@Override
public AbstractTestResultAction getParentAction() {
return this.parentAction;
}
/**
* Recount my children.
*/
@Override
public void tally() {
/// Empty out data structures
// TODO: free children? memmory leak?
// TODO: free children? memmory leak?
suitesByName = new HashMap<String,SuiteResult>();
failedTests = new ArrayList<CaseResult>();
byPackages = new TreeMap<String,PackageResult>();
@@ -558,6 +559,6 @@ public final class TestResult extends MetaTabulatedResult {
}
private static final long serialVersionUID = 1L;
private static final boolean checkTimestamps = true; // TODO: change to System.getProperty
private static final boolean checkTimestamps = true; // TODO: change to System.getProperty
}