use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class ProjectLoadingIntegrationTest method ignoresMultiProjectBuildInParentDirectoryWhichDoesNotMeetDefaultProjectCriteria.
@Test
public void ignoresMultiProjectBuildInParentDirectoryWhichDoesNotMeetDefaultProjectCriteria() {
testFile("settings.gradle").write("include 'another'");
testFile("gradle.properties").writelns("prop=value2", "otherProp=value");
TestFile subDirectory = getTestDirectory().file("subdirectory");
TestFile buildFile = subDirectory.file("build.gradle");
buildFile.writelns("task('do-stuff') {", "doLast {", "assert prop == 'value'", "assert !project.hasProperty('otherProp')", "}", "}");
testFile("subdirectory/gradle.properties").write("prop=value");
inDirectory(subDirectory).withTasks("do-stuff").expectDeprecationWarning().run();
usingProjectDir(subDirectory).withTasks("do-stuff").expectDeprecationWarning().run();
usingBuildFile(buildFile).withTasks("do-stuff").expectDeprecationWarning().run();
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class ProjectLoadingIntegrationTest method noDeprecationWarningAppearsWhenUsingRootProject.
@Test
public void noDeprecationWarningAppearsWhenUsingRootProject() {
testFile("settings.gradle").write("include 'another'");
TestFile subDirectory = getTestDirectory().file("sub");
subDirectory.file("build.gradle").write("");
usingProjectDir(getTestDirectory()).inDirectory(subDirectory).withTasks("help").run();
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class NoDaemonGradleExecuter method createExecHandleBuilder.
private DefaultExecHandleBuilder createExecHandleBuilder() {
TestFile gradleHomeDir = getDistribution().getGradleHomeDir();
if (!gradleHomeDir.isDirectory()) {
fail(gradleHomeDir + " is not a directory.\n" + "If you are running tests from IDE make sure that gradle tasks that prepare the test image were executed. Last time it was 'intTestImage' task.");
}
NativeServicesTestFixture.initialize();
DefaultExecHandleBuilder builder = new DefaultExecHandleBuilder(TestFiles.resolver(), Executors.newCachedThreadPool()) {
@Override
public File getWorkingDir() {
// the working directory is not canonicalised
return NoDaemonGradleExecuter.this.getWorkingDir();
}
};
// Clear the user's environment
builder.environment("GRADLE_HOME", "");
builder.environment("JAVA_HOME", "");
builder.environment("GRADLE_OPTS", "");
builder.environment("JAVA_OPTS", "");
GradleInvocation invocation = buildInvocation();
builder.environment(invocation.environmentVars);
builder.workingDir(getWorkingDir());
builder.setStandardInput(connectStdIn());
builder.args(invocation.args);
ExecHandlerConfigurer configurer = OperatingSystem.current().isWindows() ? new WindowsConfigurer() : new UnixConfigurer();
configurer.configure(builder);
getLogger().debug(String.format("Execute in %s with: %s %s", builder.getWorkingDir(), builder.getExecutable(), builder.getArgs()));
return builder;
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class Resources method findResource.
/**
* Locates the resource with the given name, relative to the current test class.
* @return the resource, or null if not found.
*/
public TestFile findResource(String name) {
assertNotNull(testClass);
URL resource = testClass.getResource(name);
if (resource == null) {
return null;
}
assertEquals(String.format("Cannot handle resource URI %s", resource), "file", resource.getProtocol());
File file;
try {
file = new File(resource.toURI());
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
return new TestFile(file);
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class MSBuildExecutor method withSolution.
public MSBuildExecutor withSolution(SolutionFile visualStudioSolution) {
TestFile solutionFile = new TestFile(visualStudioSolution.getFile());
solutionFile.assertIsFile();
return addArguments(solutionFile.getAbsolutePath());
}
Aggregations