Search in sources :

Example 1 with ExecOutput

use of org.gradle.test.fixtures.file.ExecOutput in project gradle by gradle.

the class MSBuildExecutor method succeeds.

public List<ExecutionResult> succeeds(MSBuildAction action) {
    withArgument(toTargetArgument(action));
    ExecOutput result = findMSBuild().execute(args, buildEnvironment(workingDir));
    System.out.println(result.getOut());
    String output = trimLines(result.getOut());
    String error = trimLines(result.getError());
    List<ExecutionResult> results = new ArrayList<ExecutionResult>();
    int first = output.indexOf(SEPARATOR);
    if (first < 0) {
        return Collections.emptyList();
    }
    output = output.substring(first + SEPARATOR.length());
    while (output.length() > 0) {
        int next = output.indexOf(SEPARATOR);
        if (next < 0) {
            results.add(OutputScrapingExecutionResult.from(output, error));
            output = "";
        } else {
            results.add(OutputScrapingExecutionResult.from(output.substring(0, next), error));
            output = output.substring(next + SEPARATOR.length());
        }
        error = "";
    }
    return results;
}
Also used : ExecOutput(org.gradle.test.fixtures.file.ExecOutput) ArrayList(java.util.ArrayList) ExecutionResult(org.gradle.integtests.fixtures.executer.ExecutionResult) OutputScrapingExecutionResult(org.gradle.integtests.fixtures.executer.OutputScrapingExecutionResult)

Example 2 with ExecOutput

use of org.gradle.test.fixtures.file.ExecOutput in project gradle by gradle.

the class MSBuildVersionLocator method getMSBuildInstall.

public File getMSBuildInstall(AvailableToolChains.InstalledToolChain toolChain) {
    VersionNumber vsVersion;
    if (toolChain instanceof AvailableToolChains.InstalledVisualCpp) {
        AvailableToolChains.InstalledVisualCpp visualCpp = (AvailableToolChains.InstalledVisualCpp) toolChain;
        vsVersion = visualCpp.getVersion();
    } else {
        vsVersion = VersionNumber.version(15);
    }
    File vswhere = vswhereLocator.getVswhereInstall();
    if (vswhere == null) {
        throw new IllegalStateException("vswhere tool is required to be installed");
    }
    ExecOutput vsWhereOutput = new TestFile(vswhere).exec("-version", String.format("[%s.0,%s.0)", vsVersion.getMajor(), vsVersion.getMajor() + 1), "-products", "*", "-requires", "Microsoft.Component.MSBuild", "-property", "installationPath");
    if (!vsWhereOutput.getError().trim().isEmpty()) {
        throw new IllegalStateException(String.format("Could not determine the location of MSBuild %s: %s", vsVersion.getMajor(), vsWhereOutput.getError()));
    }
    String location = vsWhereOutput.getOut().trim();
    TestFile msbuild;
    if (!location.isEmpty()) {
        msbuild = new TestFile(location).file("MSBuild/" + vsVersion.getMajor() + ".0/Bin/MSBuild.exe");
    } else if (vsVersion.getMajor() == 11) {
        msbuild = new TestFile("C:/Windows/Microsoft.Net/Framework/v4.0.30319/MSBuild.exe");
    } else {
        msbuild = new TestFile("C:/program files (x86)/MSBuild/" + vsVersion.getMajor() + ".0/Bin/MSBuild.exe");
    }
    if (!msbuild.exists()) {
        throw new IllegalStateException(String.format("This test requires MSBuild %s to be installed. Expected it to be installed at %s.", vsVersion.getMajor(), msbuild));
    }
    return msbuild;
}
Also used : AvailableToolChains(org.gradle.nativeplatform.fixtures.AvailableToolChains) ExecOutput(org.gradle.test.fixtures.file.ExecOutput) TestFile(org.gradle.test.fixtures.file.TestFile) TestFile(org.gradle.test.fixtures.file.TestFile) File(java.io.File) VersionNumber(org.gradle.util.VersionNumber)

Example 3 with ExecOutput

use of org.gradle.test.fixtures.file.ExecOutput in project gradle by gradle.

the class XcodebuildExecutor method fails.

public ExecutionFailure fails(XcodeAction action) {
    withArgument(action.toString());
    ExecOutput result = findXcodeBuild().execWithFailure(args, buildEnvironment(testDirectory));
    // stderr of Gradle is redirected to stdout of xcodebuild tool. To work around, we consider xcodebuild stdout and stderr as
    // the error output only if xcodebuild failed most likely due to Gradle.
    System.out.println(result.getOut());
    System.out.println(result.getError());
    return OutputScrapingExecutionFailure.from(result.getOut(), result.getError());
}
Also used : ExecOutput(org.gradle.test.fixtures.file.ExecOutput)

Example 4 with ExecOutput

use of org.gradle.test.fixtures.file.ExecOutput in project gradle by gradle.

the class XcodebuildExecutor method succeeds.

public ExecutionResult succeeds(XcodeAction action) {
    withArgument(action.toString());
    ExecOutput result = findXcodeBuild().execute(args, buildEnvironment(testDirectory));
    System.out.println(result.getOut());
    return OutputScrapingExecutionResult.from(result.getOut(), result.getError());
}
Also used : ExecOutput(org.gradle.test.fixtures.file.ExecOutput)

Example 5 with ExecOutput

use of org.gradle.test.fixtures.file.ExecOutput in project gradle by gradle.

the class MSBuildExecutor method fails.

public ExecutionFailure fails(MSBuildAction action) {
    withArgument(toTargetArgument(action));
    ExecOutput result = findMSBuild().execWithFailure(args, buildEnvironment(workingDir));
    System.out.println(result.getOut());
    System.out.println(result.getError());
    return OutputScrapingExecutionFailure.from(trimLines(result.getOut()), trimLines(result.getError()));
}
Also used : ExecOutput(org.gradle.test.fixtures.file.ExecOutput)

Aggregations

ExecOutput (org.gradle.test.fixtures.file.ExecOutput)5 File (java.io.File)1 ArrayList (java.util.ArrayList)1 ExecutionResult (org.gradle.integtests.fixtures.executer.ExecutionResult)1 OutputScrapingExecutionResult (org.gradle.integtests.fixtures.executer.OutputScrapingExecutionResult)1 AvailableToolChains (org.gradle.nativeplatform.fixtures.AvailableToolChains)1 TestFile (org.gradle.test.fixtures.file.TestFile)1 VersionNumber (org.gradle.util.VersionNumber)1