提交 161a0092 编写于 作者: K Kanstantsin Shautsou

Fixing PR comments:

- Typo
- Print error combined
- Set result only when phase like in other code parts.
- Test for expected error message in log
上级 3e856e68
......@@ -725,8 +725,10 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
try {
if (!perform(bs,listener)) {
LOGGER.log(Level.FINE, "{0} : {1} failed", new Object[] {AbstractBuild.this, bs});
setResult(Result.FAILURE);
r = false;
if (phase) {
setResult(Result.FAILURE);
}
}
} catch (Exception e) {
reportError(bs, e, listener, phase);
......@@ -744,8 +746,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
if (e instanceof AbortException) {
LOGGER.log(Level.FINE, "{0} : {1} failed", new Object[] {AbstractBuild.this, publisher});
listener.error("Publisher '" + publisher + "' failed: ");
listener.error(e.getMessage());
listener.error("Publisher '" + publisher + "' failed: " + e.getMessage());
} else {
String msg = "Publisher '" + publisher + "' aborted due to exception: ";
e.printStackTrace(listener.error(msg));
......
......@@ -73,9 +73,10 @@ public class FreestyleJobPublisherTest {
assertEquals("Build must fail, because we used AbortExceptionPublisher", b.getResult(), Result.FAILURE);
j.assertLogNotContains("\tat", b); // log must not contain stacktrace
j.assertLogContains("Threw AbortException from publisher!", b); // log must contain exact error message
File file = new File(b.getArtifactsDir(), "result.txt");
assertTrue("ArtifactArchiver is executed even prior publisher fails", file.exists());
assertTrue("Second publisher must see FAILURE status",
assertTrue("Third publisher must see FAILURE status",
FileUtils.readFileToString(file).equals(Result.FAILURE.toString()));
}
......@@ -98,6 +99,7 @@ public class FreestyleJobPublisherTest {
assertEquals("Build must fail, because we used FalsePublisher", b.getResult(), Result.FAILURE);
j.assertLogContains("\tat hudson.model.utils.IOExceptionPublisher", b); // log must contain stacktrace
j.assertLogContains("Threw IOException from publisher!", b); // log must contain exact error message
File file = new File(b.getArtifactsDir(), "result.txt");
assertTrue("ArtifactArchiver is executed even prior publisher fails", file.exists());
assertTrue("Third publisher must see FAILURE status",
......
......@@ -19,7 +19,7 @@ import java.io.IOException;
public class IOExceptionPublisher extends Recorder {
@Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
throw new IOException("Throwed IOException from publisher!");
throw new IOException("Threw IOException from publisher!");
}
@Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册