Search in sources :

Example 46 with TestFile

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

the class ProjectLoadingIntegrationTest method noDeprecationWarningAppearsWhenEnclosingBuildUsesAnotherBuildFile.

@Test
public void noDeprecationWarningAppearsWhenEnclosingBuildUsesAnotherBuildFile() {
    testFile("settings.gradle").write("include 'another'");
    TestFile renamedBuildGradle = getTestDirectory().file("renamed_build.gradle").createFile();
    usingBuildFile(renamedBuildGradle).inDirectory(getTestDirectory()).withTasks("help").run();
}
Also used : TestFile(org.gradle.test.fixtures.file.TestFile) Test(org.junit.Test) AbstractIntegrationTest(org.gradle.integtests.fixtures.AbstractIntegrationTest)

Example 47 with TestFile

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

the class ProjectLoadingIntegrationTest method canDetermineRootProjectAndDefaultProjectBasedOnCurrentDirectory.

@Test
public void canDetermineRootProjectAndDefaultProjectBasedOnCurrentDirectory() {
    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')");
    inDirectory(rootDir).withTasks("do-stuff").run().assertTasksExecuted(":do-stuff", ":child:do-stuff");
    inDirectory(rootDir).withTasks(":do-stuff").run().assertTasksExecuted(":do-stuff");
    inDirectory(childDir).withTasks("do-stuff").run().assertTasksExecuted(":child:do-stuff");
    inDirectory(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 48 with TestFile

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

the class ProjectLoadingIntegrationTest method deprecationWarningAppearsWhenNestedBuildHasNoSettingsFile.

@Test
public void deprecationWarningAppearsWhenNestedBuildHasNoSettingsFile() {
    testFile("settings.gradle").write("include 'another'");
    TestFile subDirectory = getTestDirectory().file("sub");
    TestFile subBuildFile = subDirectory.file("sub.gradle").write("");
    subDirectory.file("build.gradle").write("");
    ExecutionResult result = inDirectory(subDirectory).withTasks("help").expectDeprecationWarning().run();
    result.assertOutputContains("Support for nested build without a settings file was deprecated and will be removed in Gradle 5.0. You should create a empty settings file in " + subDirectory.getAbsolutePath());
    result = usingBuildFile(subBuildFile).inDirectory(subDirectory).withTasks("help").expectDeprecationWarning().run();
    result.assertOutputContains("Support for nested build without a settings file was deprecated and will be removed in Gradle 5.0. You should create a empty settings file in " + subDirectory.getAbsolutePath());
    result = usingProjectDir(subDirectory).withTasks("help").expectDeprecationWarning().run();
    result.assertOutputContains("Support for nested build without a settings file was deprecated and will be removed in Gradle 5.0. You should create a empty settings file in " + subDirectory.getAbsolutePath());
}
Also used : TestFile(org.gradle.test.fixtures.file.TestFile) ExecutionResult(org.gradle.integtests.fixtures.executer.ExecutionResult) Test(org.junit.Test) AbstractIntegrationTest(org.gradle.integtests.fixtures.AbstractIntegrationTest)

Example 49 with TestFile

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

the class TestResources method maybeCopy.

/**
 * Copies the given resource to the test directory.
 */
public void maybeCopy(String resource) {
    TestFile dir = resources.findResource(resource);
    if (dir != null) {
        logger.debug("Copying test resource '{}' from {} to test directory.", resource, dir);
        dir.copyTo(getDir());
    } else {
        logger.debug("Test resource '{}' not found, skipping.", resource);
    }
}
Also used : TestFile(org.gradle.test.fixtures.file.TestFile)

Example 50 with TestFile

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

the class AbstractGradleExecuter method isSettingsFileAvailable.

private boolean isSettingsFileAvailable() {
    boolean settingsFoundAboveInTestDir = false;
    TestFile dir = new TestFile(getWorkingDir());
    while (dir != null && getTestDirectoryProvider().getTestDirectory().isSelfOrDescendent(dir)) {
        if (dir.file("settings.gradle").isFile()) {
            settingsFoundAboveInTestDir = true;
            break;
        }
        dir = dir.getParentFile();
    }
    return settingsFoundAboveInTestDir;
}
Also used : TestFile(org.gradle.test.fixtures.file.TestFile)

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