Search in sources :

Example 16 with CommandException

use of com.google.copybara.shell.CommandException in project copybara by google.

the class QuiltTransformationTest method setUpQuiltBin.

// Returns "quilt" if the "quilt" command can execute successfully. Otherwise, returns the path
// to the quilt binary from build-time data dependency.
private static String setUpQuiltBin(GeneralOptions options) {
    // Try executing "quilt --version" to see if "quilt" command can run.
    Command cmd = new Command(new String[] { "quilt", "--version" }, options.getEnvironment(), null);
    boolean success = false;
    try {
        options.newCommandRunner(cmd).execute();
        success = true;
    } catch (CommandException e) {
    // "success" remains false.
    }
    if (success) {
        return "quilt";
    }
    Path runtime = Paths.get(System.getenv("TEST_SRCDIR")).resolve(System.getenv("TEST_WORKSPACE")).resolve("third_party/quilt");
    return runtime.resolve("quilt").toAbsolutePath().toString();
}
Also used : FileSubjects.assertThatPath(com.google.copybara.testing.FileSubjects.assertThatPath) Path(java.nio.file.Path) Command(com.google.copybara.shell.Command) CommandException(com.google.copybara.shell.CommandException)

Aggregations

CommandException (com.google.copybara.shell.CommandException)16 Command (com.google.copybara.shell.Command)14 BadExitStatusWithOutputException (com.google.copybara.util.BadExitStatusWithOutputException)9 IOException (java.io.IOException)8 CommandOutputWithStatus (com.google.copybara.util.CommandOutputWithStatus)7 ImmutableList (com.google.common.collect.ImmutableList)6 RepoException (com.google.copybara.exception.RepoException)5 CommandRunner (com.google.copybara.util.CommandRunner)4 ValidationException (com.google.copybara.exception.ValidationException)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 Matcher (com.google.re2j.Matcher)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 AccessValidationException (com.google.copybara.exception.AccessValidationException)1 GitEnvironment (com.google.copybara.git.GitEnvironment)1 BadExitStatusException (com.google.copybara.shell.BadExitStatusException)1 CommandResult (com.google.copybara.shell.CommandResult)1 KillableObserver (com.google.copybara.shell.KillableObserver)1 TerminationStatus (com.google.copybara.shell.TerminationStatus)1