use of org.gradle.test.fixtures.file.TestFile 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;
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class XcodebuildExecutor method findXcodeBuild.
private TestFile findXcodeBuild() {
TestFile xcodebuild = new TestFile("/usr/bin/xcodebuild");
assertTrue("This test requires xcode to be installed in " + xcodebuild.getAbsolutePath(), xcodebuild.exists());
return xcodebuild;
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class IncrementalElement method delete.
/**
* Returns a transform that delete the before element.
*/
protected static Transform delete(final SourceElement beforeElement) {
final String sourceSetName = beforeElement.getSourceSetName();
final List<SourceFile> beforeFiles = beforeElement.getFiles();
return new Transform() {
@Override
public void applyChangesToProject(TestFile projectDir) {
for (SourceFile beforeFile : beforeFiles) {
TestFile file = projectDir.file(beforeFile.withPath("src/" + sourceSetName));
file.assertExists();
file.delete();
}
}
@Override
public List<SourceFile> getBeforeFiles() {
return beforeElement.getFiles();
}
@Override
public List<SourceFile> getAfterFiles() {
return Collections.emptyList();
}
};
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class IncrementalSwiftElement method modify.
/**
* Returns a transform that replace the content of the before element with the content of the after element.
* Both elements must have the same location.
*/
protected static Transform modify(final SourceFileElement beforeElement, SourceFileElement afterElement) {
assert beforeElement.getFiles().size() == 1;
assert afterElement.getFiles().size() == 1;
assert beforeElement.getSourceSetName().equals(afterElement.getSourceSetName());
final String sourceSetName = beforeElement.getSourceSetName();
final SourceFile beforeFile = beforeElement.getSourceFile();
final SourceFile afterFile = afterElement.getSourceFile();
assert beforeFile.getPath().equals(afterFile.getPath());
assert beforeFile.getName().equals(afterFile.getName());
assert !beforeFile.getContent().equals(afterFile.getContent());
return new Transform() {
@Override
public void applyChangesToProject(TestFile projectDir) {
TestFile file = projectDir.file(beforeFile.withPath("src/" + sourceSetName));
file.assertExists();
file.write(afterFile.getContent());
}
@Override
public List<SourceFile> getBeforeFiles() {
return Arrays.asList(beforeFile);
}
@Override
public List<SourceFile> getAfterFiles() {
return Arrays.asList(afterFile);
}
};
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class UriScriptSourceTest method createJar.
private URI createJar() throws URISyntaxException {
TestFile jarFile = tmpDir.getTestDirectory().file("test.jar");
testDir.file("ignoreme").write("content");
testDir.zipTo(jarFile);
return new URI(String.format("jar:%s!/build.script", jarFile.toURI()));
}
Aggregations