Search in sources :

Example 1 with GradleExecuter

use of org.gradle.integtests.fixtures.executer.GradleExecuter in project gradle by gradle.

the class AbstractIntegrationTest method artifactBuilder.

protected ArtifactBuilder artifactBuilder() {
    GradleExecuter gradleExecuter = new InProcessGradleExecuter(distribution, testDirectoryProvider);
    gradleExecuter.withGradleUserHomeDir(getExecuter().getGradleUserHomeDir());
    return new GradleBackedArtifactBuilder(gradleExecuter, getTestDirectory().file("artifacts"));
}
Also used : GradleBackedArtifactBuilder(org.gradle.integtests.fixtures.executer.GradleBackedArtifactBuilder) InProcessGradleExecuter(org.gradle.integtests.fixtures.executer.InProcessGradleExecuter) InProcessGradleExecuter(org.gradle.integtests.fixtures.executer.InProcessGradleExecuter) GradleExecuter(org.gradle.integtests.fixtures.executer.GradleExecuter)

Example 2 with GradleExecuter

use of org.gradle.integtests.fixtures.executer.GradleExecuter in project gradle by gradle.

the class IntegrationTestSamplesExecutor method run.

@Override
protected int run(String executable, List<String> args, List<String> flags, OutputStream outputStream) {
    List<String> filteredFlags = new ArrayList<>();
    WarningMode warningMode = WarningMode.Fail;
    for (String flag : flags) {
        if (flag.startsWith(WARNING_MODE_FLAG_PREFIX)) {
            warningMode = WarningMode.valueOf(capitalize(flag.replace(WARNING_MODE_FLAG_PREFIX, "").toLowerCase()));
        } else {
            filteredFlags.add(flag);
        }
    }
    configureAvailableJdks(filteredFlags);
    GradleExecuter executer = gradle.inDirectory(workingDir).ignoreMissingSettingsFile().withStacktraceDisabled().noDeprecationChecks().withWarningMode(warningMode).withToolchainDetectionEnabled().withArguments(filteredFlags).withTasks(args);
    try {
        if (expectFailure) {
            ExecutionFailure result = executer.runWithFailure();
            outputStream.write((result.getOutput() + result.getError()).getBytes());
        } else {
            ExecutionResult result = executer.run();
            outputStream.write(result.getOutput().getBytes());
        }
        return expectFailure ? 1 : 0;
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : WarningMode(org.gradle.api.logging.configuration.WarningMode) ArrayList(java.util.ArrayList) GradleExecuter(org.gradle.integtests.fixtures.executer.GradleExecuter) ExecutionResult(org.gradle.integtests.fixtures.executer.ExecutionResult) UncheckedIOException(org.gradle.api.UncheckedIOException) ExecutionFailure(org.gradle.integtests.fixtures.executer.ExecutionFailure) IOException(java.io.IOException) UncheckedIOException(org.gradle.api.UncheckedIOException)

Aggregations

GradleExecuter (org.gradle.integtests.fixtures.executer.GradleExecuter)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 UncheckedIOException (org.gradle.api.UncheckedIOException)1 WarningMode (org.gradle.api.logging.configuration.WarningMode)1 ExecutionFailure (org.gradle.integtests.fixtures.executer.ExecutionFailure)1 ExecutionResult (org.gradle.integtests.fixtures.executer.ExecutionResult)1 GradleBackedArtifactBuilder (org.gradle.integtests.fixtures.executer.GradleBackedArtifactBuilder)1 InProcessGradleExecuter (org.gradle.integtests.fixtures.executer.InProcessGradleExecuter)1