Skip to content

Commit

Permalink
Throw RunFailedException when process run fails
Browse files Browse the repository at this point in the history
Fixes gh-86
  • Loading branch information
wilkinsona committed Aug 12, 2024
1 parent 5d08982 commit 13f12f6
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void run(Consumer<ProcessSpec> configurer) {
Files.copy(spec.output, spec.outputStream);
}
catch (Exception ex) {
throw new RuntimeException("Process failed", ex);
throw new RunFailedException(ex);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2020-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.spring.develocity.conventions.maven;

import io.spring.develocity.conventions.core.ProcessRunner;
import io.spring.develocity.conventions.core.ProcessRunner.RunFailedException;
import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThatExceptionOfType;

/**
* Tests for {@link ProcessBuilderProcessRunner}.
*
* @author Andy Wilkinson
*/
class ProcessBuilderProcessRunnerTests {

private final ProcessRunner processRunner = new ProcessBuilderProcessRunner();

@Test
void whenRunFailsThenRunFailedExceptionIsThrown() {
assertThatExceptionOfType(RunFailedException.class)
.isThrownBy(() -> this.processRunner.run((spec) -> spec.commandLine("does-not-exist")));
}

}

0 comments on commit 13f12f6

Please sign in to comment.