Skip to content
Permalink
Browse files

Merge pull request #12 from yoichi/JENKINS-17040-19716

[FIXED JENKINS-17040][FIXED JENKINS-19716] fix status handling for nested NestedView
  • Loading branch information...
ctapobep committed Nov 5, 2013
2 parents 7137761 + 59c1fc2 commit 8e1ca88ebbeb0092191032ac678674d142642539
@@ -230,7 +230,7 @@ void setOwner(ViewGroup owner) {
* mentionned previously.</p>
*/
public Result getWorstResult() {
Result result = Result.SUCCESS, check;
Result result = Result.NOT_BUILT, check;
boolean found = false;

List<View> normalViews = new ArrayList<View>();
@@ -251,13 +251,11 @@ public Result getWorstResult() {
check = getWorstResultForNormalView(v);
if (check != null) {
found = true;
if (check.isWorseThan(result)) {
result = check;
if (result.isWorseOrEqualTo(WORST_RESULT)) {
// cut the search if we find the worst possible case
return result;
}
if (isWorst(check)) {
// cut the search if we find the worst possible case
return check;
}
result = getWorse(check, result);
}
}

@@ -268,21 +266,27 @@ public Result getWorstResult() {
// has the worst result possible, in which case the algorithm ends)
// TODO: derecursify the algorithm to improve performance on complex views
check = v.getWorstResult();
found = true;
if (check != null) {
if (check.isWorseThan(result)) {
result = check;
if (result.isWorseOrEqualTo(WORST_RESULT)) {
// as before, cut the search if we find the worst possible case
return result;
}
found = true;
if (isWorst(check)) {
// as before, cut the search if we find the worst possible case
return check;
}
result = getWorse(check, result);
}
}

return found ? result : null;
}

/**
* Returns true if r is worst.
*/
private static boolean isWorst(Result r) {
return (r.isCompleteBuild() == WORST_RESULT.isCompleteBuild() &&
r.isWorseOrEqualTo(WORST_RESULT));
}

/**
* Returns the worse result from two.
*/
@@ -314,8 +318,7 @@ private static Result getWorstResultForNormalView(View v) {
if (lastCompletedBuild != null) {
found = true;
check = lastCompletedBuild.getResult();
if (check.isCompleteBuild() == WORST_RESULT.isCompleteBuild() &&
check.isWorseOrEqualTo(WORST_RESULT)) {
if (isWorst(check)) {
// cut the search if we find the worst possible case
return check;
}
@@ -113,6 +113,15 @@ public void testGetWorstResult() throws Exception {
assertSame(SUCCESS, NestedView.getWorstResult(view)); // Ignore disabled job
}

public void testStatusOfEmptyNest() throws Exception {
NestedView parent = new NestedView("parent");
parent.setOwner(hudson);
NestedView child = new NestedView("child");
parent.addView(child);
assertSame(null, NestedView.getWorstResult(child)); // Empty
assertSame(null, NestedView.getWorstResult(parent)); // contains Empty child only
}

public void testDoViewExistsCheck() {
NestedView view = new NestedView("test");
view.setOwner(hudson);

0 comments on commit 8e1ca88

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.