Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/main/java/org/jvnet/hudson/test/JenkinsRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -591,12 +591,14 @@ public void evaluate() throws Throwable {
t.setName("Executing "+ testDescription.getDisplayName());
System.out.println("=== Starting " + testDescription.getDisplayName());
before();
Throwable testFailure = null;
try {
// so that test code has all the access to the system
ACL.impersonate(ACL.SYSTEM);
try {
base.evaluate();
} catch (Throwable th) {
testFailure = th;
// allow the late attachment of a debugger in case of a failure. Useful
// for diagnosing a rare failure
try {
Expand All @@ -611,9 +613,20 @@ public void evaluate() throws Throwable {
throw th;
}
} finally {
after();
testDescription = null;
t.setName(o);
try {
after();
} catch (Exception e) {
if (testFailure != null) {
// Exceptions thrown by the test itself are more important than those thrown during cleanup.
testFailure.addSuppressed(e);
throw testFailure;
} else {
throw e;
}
} finally {
testDescription = null;
t.setName(o);
}
}
}
};
Expand Down