Search in sources :

Example 41 with TestFile

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

the class ZipFileTreeTest method doesNotOverwriteFilesOnSecondVisit.

@Test
public void doesNotOverwriteFilesOnSecondVisit() throws InterruptedException {
    rootDir.file("file1.txt").write("content");
    rootDir.zipTo(zipFile);
    assertVisits(tree, toList("file1.txt"), new ArrayList<String>());
    TestFile content = expandDir.listFiles()[0].listFiles()[0];
    content.makeOlder();
    TestFile.Snapshot snapshot = content.snapshot();
    assertVisits(tree, toList("file1.txt"), new ArrayList<String>());
    content.assertHasNotChangedSince(snapshot);
}
Also used : TestFile(org.gradle.test.fixtures.file.TestFile) Test(org.junit.Test)

Example 42 with TestFile

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

the class ProjectLoadingIntegrationTest method buildFailsWhenSpecifiedBuildFileIsNotAFile.

@Test
public void buildFailsWhenSpecifiedBuildFileIsNotAFile() {
    TestFile file = testFile("unknown");
    ExecutionFailure result = usingBuildFile(file).runWithFailure();
    result.assertHasDescription("The specified build file '" + file + "' does not exist.");
    file.createDir();
    result = usingBuildFile(file).runWithFailure();
    result.assertHasDescription("The specified build file '" + file + "' is not a file.");
}
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 43 with TestFile

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

the class ProjectLoadingIntegrationTest method multiProjectBuildCanHaveSettingsFileAndRootBuildFileInSubDir.

@Test
public void multiProjectBuildCanHaveSettingsFileAndRootBuildFileInSubDir() {
    TestFile buildFilesDir = getTestDirectory().file("root");
    TestFile settingsFile = buildFilesDir.file("settings.gradle");
    settingsFile.writelns("includeFlat 'child'", "rootProject.projectDir = new File(settingsDir, '..')", "rootProject.buildFileName = 'root/build.gradle'");
    TestFile rootBuildFile = buildFilesDir.file("build.gradle");
    rootBuildFile.write("task('do-stuff', dependsOn: ':child:task')");
    TestFile childBuildFile = testFile("child/build.gradle");
    childBuildFile.writelns("task('do-stuff')", "task('task')");
    usingProjectDir(getTestDirectory()).usingSettingsFile(settingsFile).withTasks("do-stuff").run().assertTasksExecuted(":child:task", ":do-stuff", ":child:do-stuff").assertTaskOrder(":child:task", ":do-stuff");
    usingBuildFile(rootBuildFile).withTasks("do-stuff").run().assertTasksExecuted(":child:task", ":do-stuff", ":child:do-stuff").assertTaskOrder(":child:task", ":do-stuff");
    usingBuildFile(childBuildFile).usingSettingsFile(settingsFile).withTasks("do-stuff").run().assertTasksExecutedInOrder(":child:do-stuff");
}
Also used : TestFile(org.gradle.test.fixtures.file.TestFile) Test(org.junit.Test) AbstractIntegrationTest(org.gradle.integtests.fixtures.AbstractIntegrationTest)

Example 44 with TestFile

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

the class ProjectLoadingIntegrationTest method canDetermineRootProjectAndDefaultProjectBasedOnProjectDirectory.

@Test
public void canDetermineRootProjectAndDefaultProjectBasedOnProjectDirectory() {
    File rootDir = getTestDirectory();
    File childDir = new File(rootDir, "child");
    testFile("settings.gradle").write("include('child')");
    testFile("build.gradle").write("task('do-stuff')");
    testFile("child/build.gradle").write("task('do-stuff')");
    usingProjectDir(rootDir).withTasks("do-stuff").run().assertTasksExecuted(":do-stuff", ":child:do-stuff");
    usingProjectDir(rootDir).withTasks(":do-stuff").run().assertTasksExecuted(":do-stuff");
    usingProjectDir(childDir).withTasks("do-stuff").run().assertTasksExecuted(":child:do-stuff");
    usingProjectDir(childDir).withTasks(":do-stuff").run().assertTasksExecuted(":do-stuff");
}
Also used : TestFile(org.gradle.test.fixtures.file.TestFile) File(java.io.File) Test(org.junit.Test) AbstractIntegrationTest(org.gradle.integtests.fixtures.AbstractIntegrationTest)

Example 45 with TestFile

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

the class ProjectLoadingIntegrationTest method buildFailsWhenSpecifiedSettingsFileIsNotAFile.

@Test
public void buildFailsWhenSpecifiedSettingsFileIsNotAFile() {
    TestFile file = testFile("unknown");
    ExecutionFailure result = inTestDirectory().usingSettingsFile(file).runWithFailure();
    result.assertHasDescription("The specified settings file '" + file + "' does not exist.");
    file.createDir();
    result = inTestDirectory().usingSettingsFile(file).runWithFailure();
    result.assertHasDescription("The specified settings file '" + file + "' is not a file.");
}
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