Search in sources :

Example 36 with TestFile

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

the class ProjectLoadingIntegrationTest method settingsFileGetsIgnoredWhenUsingSettingsOnlyDirectoryAsProjectDirectory.

@Test
public void settingsFileGetsIgnoredWhenUsingSettingsOnlyDirectoryAsProjectDirectory() {
    TestFile settingsDir = testFile("gradle");
    TestFile settingsFile = settingsDir.file("settings.gradle");
    settingsFile.writelns("rootProject.projectDir = new File(settingsDir, '../root')");
    getTestDirectory().createDir("root").file("build.gradle").writelns("task thing");
    inTestDirectory().withArguments("-p", settingsDir.getAbsolutePath()).withTasks("thing").runWithFailure().assertHasDescription("Task 'thing' not found in root project 'gradle'.");
}
Also used : TestFile(org.gradle.test.fixtures.file.TestFile) Test(org.junit.Test) AbstractIntegrationTest(org.gradle.integtests.fixtures.AbstractIntegrationTest)

Example 37 with TestFile

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

the class ProjectLoadingIntegrationTest method usesRootProjectAsDefaultProjectWhenInSettingsDir.

@Test
public void usesRootProjectAsDefaultProjectWhenInSettingsDir() {
    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, '../root/sub')");
    getTestDirectory().createDir("root").file("build.gradle").writelns("allprojects { task thing }");
    inDirectory(settingsDir).withTasks("thing").run().assertTasksExecuted(":thing", ":sub:thing");
}
Also used : TestFile(org.gradle.test.fixtures.file.TestFile) Test(org.junit.Test) AbstractIntegrationTest(org.gradle.integtests.fixtures.AbstractIntegrationTest)

Example 38 with TestFile

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

the class ProjectLoadingIntegrationTest method multiProjectBuildCanHaveAllProjectsAsChildrenOfSettingsDir.

@Test
public void multiProjectBuildCanHaveAllProjectsAsChildrenOfSettingsDir() {
    TestFile settingsFile = testFile("settings.gradle");
    settingsFile.writelns("rootProject.projectDir = new File(settingsDir, 'root')", "include 'sub'", "project(':sub').projectDir = new File(settingsDir, 'root/sub')");
    getTestDirectory().createDir("root").file("build.gradle").writelns("allprojects { task thing }");
    inTestDirectory().withTasks(":thing").run().assertTasksExecuted(":thing");
    inTestDirectory().withTasks(":sub: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 39 with TestFile

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

the class ProjectLoadingIntegrationTest method cannotUseDirectoryAsBuildFile.

@Test
public void cannotUseDirectoryAsBuildFile() {
    TestFile settingsDir = testFile("gradle").createDir();
    inTestDirectory().withArguments("-b", settingsDir.getAbsolutePath()).withTasks("thing").runWithFailure().assertHasDescription(String.format("Build file '%s' is not a file.", settingsDir.getAbsolutePath()));
}
Also used : TestFile(org.gradle.test.fixtures.file.TestFile) Test(org.junit.Test) AbstractIntegrationTest(org.gradle.integtests.fixtures.AbstractIntegrationTest)

Example 40 with TestFile

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

the class WebProjectIntegrationTest method createsAWar.

@Test
public void createsAWar() {
    testFile("settings.gradle").writelns("rootProject.name = 'test'");
    TestFile buildFile = testFile("build.gradle");
    buildFile.writelns("apply plugin: 'war'");
    testFile("src/main/webapp/index.jsp").write("<p>hi</p>");
    usingBuildFile(buildFile).withTasks("assemble").run();
    testFile("build/libs/test.war").assertIsFile();
}
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