Search in sources :

Example 16 with TestFile

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

the class MapFileTreeTest method doesNotOverwriteFileWhenGeneratedContentRemainsTheSame.

@Test
public void doesNotOverwriteFileWhenGeneratedContentRemainsTheSame() throws InterruptedException {
    Action<OutputStream> action = getAction();
    tree.add("path/file.txt", action);
    assertVisits(tree, toList("path/file.txt"), toList("path"));
    TestFile file = rootDir.file("path/file.txt");
    file.assertContents(equalTo("content"));
    file.makeOlder();
    TestFile.Snapshot snapshot = file.snapshot();
    assertVisits(tree, toList("path/file.txt"), toList("path"));
    file.assertContents(equalTo("content"));
    file.assertHasNotChangedSince(snapshot);
}
Also used : OutputStream(java.io.OutputStream) TestFile(org.gradle.test.fixtures.file.TestFile) Test(org.junit.Test)

Example 17 with TestFile

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

the class ProjectLoadingIntegrationTest method canDetermineRootProjectAndDefaultProjectBasedOnBuildFile.

@Test
public void canDetermineRootProjectAndDefaultProjectBasedOnBuildFile() {
    testFile("settings.gradle").write("include('child')");
    TestFile rootBuildFile = testFile("build.gradle");
    rootBuildFile.write("task('do-stuff')");
    TestFile childBuildFile = testFile("child/build.gradle");
    childBuildFile.write("task('do-stuff')");
    usingBuildFile(rootBuildFile).withTasks("do-stuff").run().assertTasksExecuted(":do-stuff", ":child:do-stuff");
    usingBuildFile(rootBuildFile).withTasks(":do-stuff").run().assertTasksExecuted(":do-stuff");
    usingBuildFile(childBuildFile).withTasks("do-stuff").run().assertTasksExecuted(":child:do-stuff");
    usingBuildFile(childBuildFile).withTasks(":do-stuff").run().assertTasksExecuted(":do-stuff");
}
Also used : TestFile(org.gradle.test.fixtures.file.TestFile) Test(org.junit.Test) AbstractIntegrationTest(org.gradle.integtests.fixtures.AbstractIntegrationTest)

Example 18 with TestFile

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

the class ProjectLoadingIntegrationTest method settingsFileInParentDirectoryTakesPrecedenceOverBuildFile.

@Test
public void settingsFileInParentDirectoryTakesPrecedenceOverBuildFile() {
    testFile("settings.gradle").writelns("include 'child'", "project(':child').buildFileName = 'child.gradle'");
    TestFile subDirectory = getTestDirectory().file("child");
    subDirectory.file("build.gradle").write("throw new RuntimeException()");
    subDirectory.file("child.gradle").write("task('do-stuff')");
    inDirectory(subDirectory).withTasks("do-stuff").run();
    usingProjectDir(subDirectory).withTasks("do-stuff").run();
}
Also used : TestFile(org.gradle.test.fixtures.file.TestFile) Test(org.junit.Test) AbstractIntegrationTest(org.gradle.integtests.fixtures.AbstractIntegrationTest)

Example 19 with TestFile

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

the class ProjectLoadingIntegrationTest method noDeprecationWarningAppearsWhenSettingsFileIsSpecified.

@Test
public void noDeprecationWarningAppearsWhenSettingsFileIsSpecified() {
    testFile("settings.gradle").write("include 'another'");
    TestFile subDirectory = getTestDirectory().file("sub");
    TestFile subSettingsFile = subDirectory.file("renamed_settings.gradle").write("");
    subDirectory.file("build.gradle").write("");
    inDirectory(subDirectory).usingSettingsFile(subSettingsFile).withTasks("help").run();
}
Also used : TestFile(org.gradle.test.fixtures.file.TestFile) Test(org.junit.Test) AbstractIntegrationTest(org.gradle.integtests.fixtures.AbstractIntegrationTest)

Example 20 with TestFile

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

the class ProjectLoadingIntegrationTest method buildFailsWhenSpecifiedProjectDirectoryIsNotADirectory.

@Test
public void buildFailsWhenSpecifiedProjectDirectoryIsNotADirectory() {
    TestFile file = testFile("unknown");
    ExecutionFailure result = usingProjectDir(file).runWithFailure();
    result.assertHasDescription("The specified project directory '" + file + "' does not exist.");
    file.createFile();
    result = usingProjectDir(file).runWithFailure();
    result.assertHasDescription("The specified project directory '" + file + "' is not a directory.");
}
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)

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