Package org.gradle.util

Examples of org.gradle.util.TestFile


import org.junit.Test;

public class InitScriptErrorIntegrationTest extends AbstractIntegrationTest {
    @Test
    public void reportsInitScriptEvaluationFailsWithGroovyException() {
        TestFile initScript = testFile("init.gradle");
        initScript.write("\ncreateTakk('do-stuff')");
        ExecutionFailure failure = inTestDirectory().usingInitScript(initScript).runWithFailure();

        failure.assertHasFileName(String.format("Initialization script '%s'", initScript));
        failure.assertHasLineNumber(2);
        failure.assertHasDescription("A problem occurred evaluating initialization script.");
View Full Code Here


        failure.assertHasCause("No signature of method: org.gradle.invocation.DefaultGradle.createTakk() is applicable for argument types: (java.lang.String) values: [do-stuff]");
    }

    @Test
    public void reportsGroovyCompilationException() {
        TestFile initScript = testFile("init.gradle");
        initScript.writelns(
            "// a comment",
            "import org.gradle.unknown.Unknown",
            "new Unknown()");
        ExecutionFailure failure = inTestDirectory().usingInitScript(initScript).runWithFailure();
        failure.assertHasFileName(String.format("Initialization script '%s'", initScript));
View Full Code Here

        this.outputDir = outputDir;
    }

    @TaskAction
    public void transform() {
        TestFile inputDir = new TestFile(this.inputDir);
        for (File file : inputDir.listFiles()) {
            TestFile inputFile = new TestFile(file);
            TestFile outputFile = new TestFile(outputDir, inputFile.getName());
            outputFile.write(String.format("[%s]", inputFile.getText()));
        }
    }
View Full Code Here

        graphListenerNotified = false;
    }

    @Test
    public void taskCanAccessTaskGraph() {
        TestFile buildFile = testFile("build.gradle");
        buildFile.writelns("import org.gradle.integtests.TaskExecutionIntegrationTest",
                "task a(dependsOn: 'b') << { task ->",
                "    assert gradle.taskGraph.hasTask(task)",
                "    assert gradle.taskGraph.hasTask(':a')",
                "    assert gradle.taskGraph.hasTask(a)",
                "    assert gradle.taskGraph.hasTask(':b')",
View Full Code Here

        assertTrue(graphListenerNotified);
    }

    @Test
    public void executesAllTasksInASingleBuildAndEachTaskAtMostOnce() {
        TestFile buildFile = testFile("build.gradle");
        buildFile.writelns(
                "gradle.taskGraph.whenReady { assert !project.hasProperty('graphReady'); graphReady = true }",
                "task a << { task -> project.executedA = task }",
                "task b << { ",
                "    assert a == project.executedA",
                "    assert gradle.taskGraph.hasTask(':a')",
View Full Code Here

    }

    @Test
    public void executesMultiProjectsTasksInASingleBuildAndEachTaskAtMostOnce() {
        testFile("settings.gradle").writelns("include 'child1', 'child2'");
        TestFile buildFile = testFile("build.gradle");
        buildFile.writelns(
                "task a",
                "allprojects {",
                "    task b",
                "    task c(dependsOn: ['b', ':a'])",
                "}");
View Full Code Here

    }

    @Test
    public void executesMultiProjectDefaultTasksInASingleBuildAndEachTaskAtMostOnce() {
        testFile("settings.gradle").writelns("include 'child1', 'child2'");
        TestFile buildFile = testFile("build.gradle");
        buildFile.writelns("defaultTasks 'a', 'b'", "task a", "subprojects {", "    task a(dependsOn: ':a')",
                "    task b(dependsOn: ':a')", "}");
        usingBuildFile(buildFile).run().assertTasksExecuted(":a", ":child1:a", ":child2:a", ":child1:b", ":child2:b");
    }
View Full Code Here

        usingBuildFile(buildFile).run().assertTasksExecuted(":a", ":child1:a", ":child2:a", ":child1:b", ":child2:b");
    }

    @Test
    public void executesProjectDefaultTasksWhenNoneSpecified() {
        TestFile buildFile = testFile("build.gradle");
        buildFile.writelns(
                "task a",
                "task b(dependsOn: a)",
                "defaultTasks 'b'"
        );
        usingBuildFile(buildFile).withTasks().run().assertTasksExecuted(":a", ":b");
View Full Code Here

        usingBuildFile(buildFile).withTasks().run().assertTasksExecuted(":a", ":b");
    }
   
    @Test
    public void doesNotExecuteTaskActionsWhenDryRunSpecified() {
        TestFile buildFile = testFile("build.gradle");
        buildFile.writelns(
                "task a << { fail() }",
                "task b(dependsOn: a) << { fail() }",
                "defaultTasks 'b'"
        );
View Full Code Here

    }

    @Test
    public void excludesTasksWhenExcludePatternSpecified() {
        testFile("settings.gradle").write("include 'sub'");
        TestFile buildFile = testFile("build.gradle");
        buildFile.writelns(
                "task a",
                "task b(dependsOn: a)",
                "task c(dependsOn: [a, b])",
                "task d(dependsOn: c)",
                "defaultTasks 'd'"
View Full Code Here

TOP

Related Classes of org.gradle.util.TestFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.