-
Notifications
You must be signed in to change notification settings - Fork 335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a list of all Skipped tests to the Test Result report #106
base: master
Are you sure you want to change the base?
Changes from all commits
6da8202
801310e
6aad9ff
74f043a
c8545c6
c966bff
c33e2d0
ee98b7e
45168ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,13 @@ public class CaseResult extends TestResult implements Comparable<CaseResult> { | |
*/ | ||
private /*final*/ int failedSince; | ||
|
||
/** | ||
* This test has been skipped since this build number (not id.) | ||
* | ||
* If {@link #isPassed() passing}, this field is left unused to 0. | ||
*/ | ||
private int skippedSince; | ||
|
||
private static float parseTime(Element testCase) { | ||
String time = testCase.attributeValue("time"); | ||
return new TimeToFloat(time).parse(); | ||
|
@@ -420,10 +427,40 @@ else if (getRun() != null) { | |
} | ||
} | ||
|
||
private void recomputeSkippedSinceIfNeeded() { | ||
if (skippedSince==0 && getSkipCount()==1) { | ||
CaseResult prev = getPreviousResult(); | ||
if(prev!=null && prev.isSkipped()){ | ||
this.skippedSince = prev.getSkippedSince(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unlike failedSince, skippedSince is not available in XML, so this could recursively load all the skipped builds leading to StackOverflowError like JENKINS-31660 . IMHO it would be safer to save skippedSince in XML too and assume current build is the first skipped one if no information is found in XML, avoiding recursion. (Related to #117.) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch! I will review this and suggest a fix There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @zbynek I've given this some thought.. as I understand we only parse the XML and have no control over its contents. Do you see any other way to protect against a StackOverflowError ? |
||
} | ||
else if (getRun() != null) { | ||
this.skippedSince = getRun().getNumber(); | ||
} else { | ||
LOGGER.warning("trouble calculating getSkippedSince. We've got prev, but no owner."); | ||
// skippedSince will be 0, which isn't correct. | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* If this test was skipped, then return the build number | ||
* when this test was first skipped. | ||
*/ | ||
@Exported(visibility=9) | ||
public int getSkippedSince() { | ||
// If we haven't calculated skippedSince yet, and we should, do it now. | ||
recomputeSkippedSinceIfNeeded(); | ||
return skippedSince; | ||
} | ||
|
||
public Run<?,?> getFailedSinceRun() { | ||
return getRun().getParent().getBuildByNumber(getFailedSince()); | ||
} | ||
|
||
public Run<?,?> getSkippedSinceRun() { | ||
return getRun().getParent().getBuildByNumber(getSkippedSince()); | ||
} | ||
|
||
/** | ||
* Gets the number of consecutive builds (including this) | ||
* that this test case has been failing. | ||
|
@@ -434,12 +471,14 @@ public Run<?,?> getFailedSinceRun() { | |
public int getAge() { | ||
if(isPassed()) | ||
return 0; | ||
else if (getRun() != null) { | ||
else if (isFailed() && getRun() != null) | ||
return getRun().getNumber()-getFailedSince()+1; | ||
else if (isSkipped() && getRun() != null) { | ||
return getRun().getNumber()-getSkippedSince()+1; | ||
} else { | ||
LOGGER.fine("Trying to get age of a CaseResult without an owner"); | ||
return 0; | ||
} | ||
return 0; | ||
} | ||
} | ||
|
||
/** | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if in
previous
the test failed and therefore it has been disabled now? Thenprevious.isPassed
isfalse
, too. Might be a good setup for an integration test.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're absolutely right - when a test becomes skipped, its skippedSince counter is set to the current build number.
In a subsequent build: