Search in sources :

Example 1 with ExecutionFailure

use of org.gradle.integtests.fixtures.executer.ExecutionFailure in project gradle by gradle.

the class BuildScriptClasspathIntegrationTest method buildSrcProjectCanReferToSourceOutsideBuildSrcDir.

@Test
public void buildSrcProjectCanReferToSourceOutsideBuildSrcDir() {
    testFile("gradle/src/BuildClass.java").writelns("public class BuildClass { }");
    testFile("buildSrc/build.gradle").writelns("apply plugin: 'java'", "sourceSets.main.java.srcDirs = ['../gradle/src']");
    testFile("build.gradle").writelns("task test { doLast { new BuildClass() } }");
    inTestDirectory().withTasks("test").run();
    testFile("gradle/src/BuildClass.java").writelns("public class BuildClass { public BuildClass(String value) { throw new RuntimeException(\"broken\"); } }");
    ExecutionFailure failure = inTestDirectory().withTasks("test").runWithFailure();
    failure.assertHasCause("broken");
}
Also used : ExecutionFailure(org.gradle.integtests.fixtures.executer.ExecutionFailure) Test(org.junit.Test) AbstractIntegrationTest(org.gradle.integtests.fixtures.AbstractIntegrationTest)

Example 2 with ExecutionFailure

use of org.gradle.integtests.fixtures.executer.ExecutionFailure in project gradle by gradle.

the class ProjectLoadingIntegrationTest method buildFailsWhenMultipleProjectsMeetDefaultProjectCriteria.

@Test
public void buildFailsWhenMultipleProjectsMeetDefaultProjectCriteria() {
    testFile("settings.gradle").writelns("include 'child'", "project(':child').projectDir = rootProject.projectDir");
    testFile("build.gradle").write("// empty");
    ExecutionFailure result = inTestDirectory().withTasks("test").runWithFailure();
    result.assertThatDescription(startsWith("Multiple projects in this build have project directory"));
    result = usingProjectDir(getTestDirectory()).withTasks("test").runWithFailure();
    result.assertThatDescription(startsWith("Multiple projects in this build have project directory"));
    result = usingBuildFile(testFile("build.gradle")).withTasks("test").runWithFailure();
    result.assertThatDescription(startsWith("Multiple projects in this build have build file"));
}
Also used : ExecutionFailure(org.gradle.integtests.fixtures.executer.ExecutionFailure) Test(org.junit.Test) AbstractIntegrationTest(org.gradle.integtests.fixtures.AbstractIntegrationTest)

Example 3 with ExecutionFailure

use of org.gradle.integtests.fixtures.executer.ExecutionFailure 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 4 with ExecutionFailure

use of org.gradle.integtests.fixtures.executer.ExecutionFailure 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)

Example 5 with ExecutionFailure

use of org.gradle.integtests.fixtures.executer.ExecutionFailure 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)

Aggregations

AbstractIntegrationTest (org.gradle.integtests.fixtures.AbstractIntegrationTest)6 ExecutionFailure (org.gradle.integtests.fixtures.executer.ExecutionFailure)6 Test (org.junit.Test)6 TestFile (org.gradle.test.fixtures.file.TestFile)4