提交 0cb0d039 编写于 作者: J jglick

[FIXED HUDSON-2988] Confused display of test results when using static Test suite().

1. Uniquify relative URLs of test objects (plain, plain_2, plain_3, ...) so they can be browsed separately.
2. Indicate the originating suite name if distinct from the test class name.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@16202 71c3de6d-444a-0410-be80-ed276b4c234a
上级 0cf93a97
......@@ -151,7 +151,7 @@ public final class CaseResult extends TestObject implements Comparable<CaseResul
* Note that this may contain any URL-unfriendly character.
*/
@Exported(visibility=999)
public String getName() {
public @Override String getName() {
return testName;
}
......@@ -166,14 +166,14 @@ public final class CaseResult extends TestObject implements Comparable<CaseResul
/**
* Gets the version of {@link #getName()} that's URL-safe.
*/
public String getSafeName() {
public @Override String getSafeName() {
StringBuffer buf = new StringBuffer(testName);
for( int i=0; i<buf.length(); i++ ) {
char ch = buf.charAt(i);
if(!Character.isJavaIdentifierPart(ch))
buf.setCharAt(i,'_');
}
return buf.toString();
return uniquifyName(classResult.getChildren(), buf.toString());
}
/**
......
......@@ -78,6 +78,10 @@ public final class ClassResult extends TabulatedResult implements Comparable<Cla
else return className.substring(idx+1);
}
public @Override String getSafeName() {
return uniquifyName(parent.getChildren(), safe(getName()));
}
public CaseResult getDynamic(String name, StaplerRequest req, StaplerResponse rsp) {
for (CaseResult c : cases) {
if(c.getSafeName().equals(name))
......
......@@ -63,6 +63,10 @@ public final class PackageResult extends MetaTabulatedResult implements Comparab
return packageName;
}
public @Override String getSafeName() {
return uniquifyName(parent.getChildren(), safe(getName()));
}
public AbstractBuild<?,?> getOwner() {
return parent.getOwner();
}
......
......@@ -67,12 +67,6 @@ public abstract class TabulatedResult extends TestObject {
/**
* Gets the name of this object.
*/
public abstract String getName();
public @Override abstract String getName();
/**
* Gets the version of {@link #getName()} that's URL-safe.
*/
public String getSafeName() {
return safe(getName());
}
}
......@@ -30,6 +30,9 @@ import hudson.Util;
import java.io.Serializable;
import java.util.Collection;
import java.util.Map;
import java.util.WeakHashMap;
import org.kohsuke.stapler.export.ExportedBean;
/**
......@@ -69,6 +72,34 @@ public abstract class TestObject implements ModelObject, Serializable {
return new Api(this);
}
/**
* Gets the name of this object.
*/
public /*abstract*/ String getName() {return "";}
/**
* Gets the version of {@link #getName()} that's URL-safe.
*/
public String getSafeName() {
return safe(getName());
}
/**
* #2988: uniquifies a {@link #getSafeName} amongst children of the parent.
*/
protected final synchronized String uniquifyName(Collection<? extends TestObject> siblings, String base) {
String uniquified = base;
int sequence = 1;
for (TestObject sibling : siblings) {
if (sibling != this && uniquified.equals(UNIQUIFIED_NAMES.get(sibling))) {
uniquified = base + '_' + ++sequence;
}
}
UNIQUIFIED_NAMES.put(this, uniquified);
return uniquified;
}
private static final Map<TestObject,String> UNIQUIFIED_NAMES = new WeakHashMap<TestObject,String>();
/**
* Replaces URL-unsafe characters.
*/
......
......@@ -31,8 +31,13 @@ THE SOFTWARE.
<h1 class="${st.cssClass}">
<st:out value="${st.message}" />
</h1>
<p style="font-weight:bold">
<st:out value="${it.fullName}"/>
<p>
<span style="font-weight:bold">
<st:out value="${it.fullName}"/>
</span>
<j:if test="${it.className != it.parent.name}">
(from <st:out value="${it.parent.name}"/>)
</j:if>
</p>
<j:if test="${!it.passed}">
<div style="text-align:right;">
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册