use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class ProjectLoadingIntegrationTest method settingsFileTakesPrecedenceOverBuildFileInSameDirectory.
@Test
public void settingsFileTakesPrecedenceOverBuildFileInSameDirectory() {
testFile("settings.gradle").write("rootProject.buildFileName = 'root.gradle'");
testFile("root.gradle").write("task('do-stuff')");
TestFile buildFile = testFile("build.gradle");
buildFile.write("throw new RuntimeException()");
inTestDirectory().withTasks("do-stuff").run();
usingProjectDir(getTestDirectory()).withTasks("do-stuff").run();
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class ProjectLoadingIntegrationTest method explicitBuildFileTakesPrecedenceOverSettingsFileInSameDirectory.
@Test
public void explicitBuildFileTakesPrecedenceOverSettingsFileInSameDirectory() {
testFile("settings.gradle").write("rootProject.buildFileName = 'root.gradle'");
testFile("root.gradle").write("throw new RuntimeException()");
TestFile buildFile = testFile("build.gradle");
buildFile.write("task('do-stuff')");
usingBuildFile(buildFile).withTasks("do-stuff").run();
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class ProjectLoadingIntegrationTest method rootProjectDirectoryAndBuildFileDoNotHaveToExistWhenInSettingsDir.
@Test
public void rootProjectDirectoryAndBuildFileDoNotHaveToExistWhenInSettingsDir() {
TestFile settingsDir = testFile("gradle");
TestFile settingsFile = settingsDir.file("settings.gradle");
settingsFile.writelns("rootProject.projectDir = new File(settingsDir, '../root')", "include 'sub'", "project(':sub').projectDir = new File(settingsDir, '../sub')");
getTestDirectory().createDir("sub").file("build.gradle").writelns("task thing");
inDirectory(settingsDir).withTasks("thing").run().assertTasksExecuted(":sub:thing");
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class ProjectLoadingIntegrationTest method buildFailsWhenSpecifiedSettingsFileDoesNotContainMatchingProject.
@Test
public void buildFailsWhenSpecifiedSettingsFileDoesNotContainMatchingProject() {
TestFile settingsFile = testFile("settings.gradle");
settingsFile.write("// empty");
TestFile projectDir = testFile("project dir");
TestFile buildFile = projectDir.file("build.gradle").createFile();
ExecutionFailure result = usingProjectDir(projectDir).usingSettingsFile(settingsFile).runWithFailure();
result.assertHasDescription(String.format("No projects in this build have project directory '%s'.", projectDir));
result = usingBuildFile(buildFile).usingSettingsFile(settingsFile).runWithFailure();
result.assertHasDescription(String.format("No projects in this build have build file '%s'.", buildFile));
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class ProjectLoadingIntegrationTest method handlesSimilarlyNamedBuildFilesInSameDirectory.
@Test
public void handlesSimilarlyNamedBuildFilesInSameDirectory() {
TestFile buildFile1 = testFile("similarly-named build.gradle").write("task build");
TestFile buildFile2 = testFile("similarly_named_build_gradle").write("task 'other-build'");
usingBuildFile(buildFile1).withTasks("build").run();
usingBuildFile(buildFile2).withTasks("other-build").run();
usingBuildFile(buildFile1).withTasks("build").run();
}
Aggregations