Skip to content

Commit ef722f6

Browse files
committed
Fix test failures in pipeline and messenger specs.
1 parent 41ce855 commit ef722f6

File tree

5 files changed

+30
-10
lines changed

5 files changed

+30
-10
lines changed

src/main/groovy/org/pipelinelabs/pipeline/dsl/internal/DefaultPipelineDsl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.pipelinelabs.pipeline.dsl.MessengerDsl;
77
import org.pipelinelabs.pipeline.dsl.StageDsl;
88
import org.pipelinelabs.pipeline.event.PipeEvent;
9+
import org.pipelinelabs.pipeline.exception.PipelineException;
910
import org.pipelinelabs.pipeline.messenger.MessageContext;
1011
import org.pipelinelabs.pipeline.runner.DefaultPipeline;
1112
import org.pipelinelabs.pipeline.util.ConfigureUtil;
@@ -29,7 +30,7 @@ public StageDsl stage(final String name, final Closure closure) {
2930
events.add(new PipeEvent("ProjectName", "Success", stage.getDescription(), ""));
3031
stages.add(stage);
3132
return stage;
32-
} catch (Exception e) {
33+
} catch (PipelineException e) {
3334
events.add(new PipeEvent("ProjectName", "Failure", stage.getDescription(), e.getMessage()));
3435
return stage;
3536
}

src/main/groovy/org/pipelinelabs/pipeline/dsl/internal/DefaultStageDsl.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.pipelinelabs.pipeline.dsl.internal;
22

33
import org.pipelinelabs.pipeline.api.Stage;
4+
import org.pipelinelabs.pipeline.exception.PipelineException;
45
import org.pipelinelabs.pipeline.runner.DefaultStage;
56
import org.apache.maven.shared.utils.cli.CommandLineException;
67
import org.apache.maven.shared.utils.cli.CommandLineUtils;
@@ -71,7 +72,7 @@ public void run() {
7172
final int exitStatus = executeCommand(cl, createStreamingConsumer(out), createStreamingConsumer(err));
7273
if (0 != exitStatus) {
7374
final String msg = "Error occurred during execution of command [%s]";
74-
throw new RuntimeException(String.format(msg, command));
75+
throw new PipelineException(String.format(msg, command));
7576
}
7677
}
7778

@@ -81,7 +82,7 @@ private int executeCommand(final Commandline cl,
8182
try {
8283
exitStatus = CommandLineUtils.executeCommandLine(cl, stdOut, stdErr);
8384
} catch (CommandLineException e) {
84-
throw new RuntimeException("Failed to execute command", e);
85+
throw new PipelineException("Failed to execute command", e);
8586
}
8687
return exitStatus;
8788
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package org.pipelinelabs.pipeline.exception;
2+
3+
public class PipelineException extends RuntimeException {
4+
public PipelineException() {
5+
super();
6+
}
7+
8+
public PipelineException(String message) {
9+
super(message);
10+
}
11+
12+
public PipelineException(String message, Throwable cause) {
13+
super(message, cause);
14+
}
15+
16+
public PipelineException(Throwable cause) {
17+
super(cause);
18+
}
19+
}

src/test/groovy/org/pipelinelabs/pipeline/messenger/internal/AggregateMessengerSpec.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import org.pipelinelabs.pipeline.messenger.SpecializedMessenger
99

1010
class AggregateMessengerSpec extends Specification {
1111
MessageContext context = Mock()
12-
PipeEvent event = Mock()
12+
PipeEvent event = new PipeEvent('', '', '', '')
1313

1414
def 'if no messengers, does nothing'() {
1515
given:

src/test/groovy/org/pipelinelabs/pipeline/messenger/internal/EmailMessengerSpec.groovy

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@ class EmailMessengerSpec extends Specification {
2727

2828
def 'process generates the correct email'() {
2929
given:
30-
PipeEvent event = [
31-
getName: { 'MyProject' },
32-
getStatus: { 'Success' },
33-
getDescription: { 'Gradle build succeeded in 10 seconds.' },
34-
getDetails: { 'a bunch of\nlog data\n' }
35-
] as PipeEvent
30+
PipeEvent event = new PipeEvent(
31+
'MyProject',
32+
'Success',
33+
'Gradle build succeeded in 10 seconds.',
34+
'a bunch of\nlog data\n')
3635
def from = '[email protected]'
3736
3837
def cc = ['[email protected]']

0 commit comments

Comments
 (0)