-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIXED JENKINS-17084] Changelog should produce output even if some ch…
…angelog annotator fails
- Loading branch information
Showing
2 changed files
with
50 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package hudson.scm; | ||
|
||
import hudson.Extension; | ||
import hudson.MarkupText; | ||
import hudson.model.AbstractBuild; | ||
import hudson.scm.ChangeLogSet.Entry; | ||
|
||
import org.jvnet.hudson.test.Bug; | ||
import org.jvnet.hudson.test.FakeChangeLogSCM.EntryImpl; | ||
import org.jvnet.hudson.test.HudsonTestCase; | ||
|
||
public class ChangeLogSetTest extends HudsonTestCase { | ||
|
||
@Bug(17084) | ||
public void testCatchingExceptionDuringAnnotation() throws Exception { | ||
EntryImpl change = new EntryImpl(); | ||
change.setParent(ChangeLogSet.createEmpty(null)); // otherwise test would actually test only NPE thrown when accessing paret.build | ||
boolean notCaught = false; | ||
try { | ||
change.getMsgAnnotated(); | ||
} catch (Throwable t) { | ||
notCaught = true; | ||
} | ||
assertEquals((new EntryImpl()).getMsg(), change.getMsg()); | ||
assertEquals(false, notCaught); | ||
} | ||
|
||
@Extension | ||
public static final class ThrowExceptionChangeLogAnnotator extends ChangeLogAnnotator { | ||
|
||
@Override | ||
public void annotate(AbstractBuild<?,?> build, Entry change, MarkupText text ) { | ||
throw new RuntimeException(); | ||
} | ||
|
||
} | ||
|
||
@Extension | ||
public static final class ThrowErrorChangeLogAnnotator extends ChangeLogAnnotator { | ||
|
||
@Override | ||
public void annotate(AbstractBuild<?,?> build, Entry change, MarkupText text ) { | ||
throw new Error(); | ||
} | ||
|
||
} | ||
} |