Skip to content

Commit 13f12f6

Browse files
committed
Throw RunFailedException when process run fails
Fixes gh-86
1 parent 5d08982 commit 13f12f6

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

develocity-conventions-maven-extension/src/main/java/io/spring/develocity/conventions/maven/ProcessBuilderProcessRunner.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void run(Consumer<ProcessSpec> configurer) {
4444
Files.copy(spec.output, spec.outputStream);
4545
}
4646
catch (Exception ex) {
47-
throw new RuntimeException("Process failed", ex);
47+
throw new RunFailedException(ex);
4848
}
4949
}
5050

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2020-2024 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.spring.develocity.conventions.maven;
18+
19+
import io.spring.develocity.conventions.core.ProcessRunner;
20+
import io.spring.develocity.conventions.core.ProcessRunner.RunFailedException;
21+
import org.junit.jupiter.api.Test;
22+
23+
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
24+
25+
/**
26+
* Tests for {@link ProcessBuilderProcessRunner}.
27+
*
28+
* @author Andy Wilkinson
29+
*/
30+
class ProcessBuilderProcessRunnerTests {
31+
32+
private final ProcessRunner processRunner = new ProcessBuilderProcessRunner();
33+
34+
@Test
35+
void whenRunFailsThenRunFailedExceptionIsThrown() {
36+
assertThatExceptionOfType(RunFailedException.class)
37+
.isThrownBy(() -> this.processRunner.run((spec) -> spec.commandLine("does-not-exist")));
38+
}
39+
40+
}

0 commit comments

Comments
 (0)