Search in sources :

Example 6 with TestFile

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();
}
Also used : TestFile(org.gradle.test.fixtures.file.TestFile) Test(org.junit.Test) AbstractIntegrationTest(org.gradle.integtests.fixtures.AbstractIntegrationTest)

Example 7 with TestFile

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();
}
Also used : TestFile(org.gradle.test.fixtures.file.TestFile) Test(org.junit.Test) AbstractIntegrationTest(org.gradle.integtests.fixtures.AbstractIntegrationTest)

Example 8 with TestFile

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");
}
Also used : TestFile(org.gradle.test.fixtures.file.TestFile) Test(org.junit.Test) AbstractIntegrationTest(org.gradle.integtests.fixtures.AbstractIntegrationTest)

Example 9 with TestFile

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));
}
Also used : TestFile(org.gradle.test.fixtures.file.TestFile) ExecutionFailure(org.gradle.integtests.fixtures.executer.ExecutionFailure) Test(org.junit.Test) AbstractIntegrationTest(org.gradle.integtests.fixtures.AbstractIntegrationTest)

Example 10 with TestFile

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();
}
Also used : TestFile(org.gradle.test.fixtures.file.TestFile) Test(org.junit.Test) AbstractIntegrationTest(org.gradle.integtests.fixtures.AbstractIntegrationTest)

Aggregations

TestFile (org.gradle.test.fixtures.file.TestFile)53 Test (org.junit.Test)33 AbstractIntegrationTest (org.gradle.integtests.fixtures.AbstractIntegrationTest)25 File (java.io.File)5 ExecutionFailure (org.gradle.integtests.fixtures.executer.ExecutionFailure)4 OutputStream (java.io.OutputStream)2 URI (java.net.URI)2 MaybeCompressedFileResource (org.gradle.api.internal.file.MaybeCompressedFileResource)2 LocalResourceAdapter (org.gradle.api.resources.internal.LocalResourceAdapter)2 SourceFile (org.gradle.integtests.fixtures.SourceFile)2 DefaultExecHandleBuilder (org.gradle.process.internal.DefaultExecHandleBuilder)2 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 UncheckedIOException (org.gradle.api.UncheckedIOException)1 ExecutionResult (org.gradle.integtests.fixtures.executer.ExecutionResult)1 IntegrationTestBuildContext (org.gradle.integtests.fixtures.executer.IntegrationTestBuildContext)1 AvailableToolChains (org.gradle.nativeplatform.fixtures.AvailableToolChains)1 ExecOutput (org.gradle.test.fixtures.file.ExecOutput)1