Examples of TestFile


Examples of org.gradle.util.TestFile

        scriptFileUri = scriptFile.toURI();
        createJar();
    }

    private URI createJar() throws URISyntaxException {
        TestFile jarFile = tmpDir.getDir().file("test.jar");
        testDir.file("ignoreme").write("content");
        testDir.zipTo(jarFile);
        return new URI(String.format("jar:%s!/build.script", jarFile.toURI()));
    }
View Full Code Here

Examples of org.gradle.util.TestFile

            returnedExecuter = forkingGradleExecuter;
        }

        boolean settingsFound = false;
        for (
                File dir = new TestFile(getWorkingDir()); dir != null && dist.isFileUnderTest(dir) && !settingsFound;
                dir = dir.getParentFile()) {
            if (new File(dir, "settings.gradle").isFile()) {
                settingsFound = true;
            }
        }
        if (settingsFound) {
View Full Code Here

Examples of org.gradle.util.TestFile

    @Rule
    public final TemporaryFolder tmpDir = new TemporaryFolder();

    @Test
    public void testNeedsCopy() throws IOException {
        TestFile source = tmpDir.createFile("src");
        TestFile dest = tmpDir.getDir().file("dest");
        dest.assertDoesNotExist();

        TestFileTreeElement element = new TestFileTreeElement(source);

        assertTrue(element.needsCopy(dest));

        element.copyTo(dest);

        assertFalse(element.needsCopy(dest));

        dest.setLastModified(source.lastModified() - 1000);
        assertTrue(element.needsCopy(dest));
    }
View Full Code Here

Examples of org.gradle.util.TestFile

            will(returnValue(90L));
        }});

        mappedDetails.filter(HelperUtil.toClosure("{ 'PREFIX: ' + it } "));

        TestFile destDir = tmpDir.getDir().file("test.txt");
        mappedDetails.copyTo(destDir);
        destDir.assertContents(equalTo("PREFIX: content"));
    }
View Full Code Here

Examples of org.gradle.util.TestFile

        classLoader = createClassLoader(pluginId, TestPlugin1.class.getName(), "parent");
        pluginRegistry = new DefaultPluginRegistry(classLoader);
    }

    private ClassLoader createClassLoader(final String id, String implClass, String name) throws IOException {
        TestFile classPath = testDir.createDir(name);
        Properties props = new Properties();
        props.setProperty("implementation-class", implClass);
        final TestFile propertiesFile = classPath.file(id + ".properties");
        propertiesFile.getParentFile().mkdirs();
        GUtil.saveProperties(props, propertiesFile);
        final ClassLoader classLoader = context.mock(ClassLoader.class, name);
        context.checking(new Expectations() {{
            allowing(classLoader).getResource("META-INF/gradle-plugins/" + id + ".properties");
            will(returnValue(propertiesFile.toURI().toURL()));
        }});
        return classLoader;
    }
View Full Code Here

Examples of org.gradle.util.TestFile

    }

    @Test
    public void failsWhenNoImplementationClassSpecifiedInPropertiesFile() throws MalformedURLException {
        Properties properties = new Properties();
        final TestFile propertiesFile = testDir.file("prop");
        GUtil.saveProperties(properties, propertiesFile);
        final URL url = propertiesFile.toURI().toURL();

        context.checking(new Expectations() {{
            allowing(classLoader).getResource("META-INF/gradle-plugins/noImpl.properties");
            will(returnValue(url));
        }});
View Full Code Here

Examples of org.gradle.util.TestFile

        failure.assertHasCause("Could not find method createTakk() for arguments [do-stuff] on root project 'reportsProjectEvaluationFailsWithGroovyException");
    }

    @Test
    public void reportsScriptCompilationException() {
        TestFile buildFile = testFile("build.gradle");
        buildFile.writelns(
            "// a comment",
            "import org.gradle.unknown.Unknown",
            "new Unknown()");
        ExecutionFailure failure = inTestDirectory().runWithFailure();
        failure.assertHasFileName(String.format("Build file '%s'", buildFile));
View Full Code Here

Examples of org.gradle.util.TestFile

    @Test
    public void reportsNestedProjectEvaluationFailsWithRuntimeException() {
        testFile("settings.gradle").write("include 'child'");

        TestFile buildFile = testFile("build.gradle");
        buildFile.writelns(
                "dependsOn 'child'",
                "task t");

        TestFile childBuildFile = testFile("child/build.gradle");
        childBuildFile.writelns(
                "def broken = { ->",
                "    throw new RuntimeException('failure') }",
                "broken()");
        ExecutionFailure failure = inTestDirectory().withTasks("t").runWithFailure();
View Full Code Here

Examples of org.gradle.util.TestFile

        failure.assertHasCause("failure");
    }

    @Test
    public void reportsTaskActionExecutionFailsWithError() {
        TestFile buildFile = testFile("build.gradle");
        buildFile.writelns(
                "task('do-stuff').doFirst",
                "{",
                "1/0",
                "}");
        ExecutionFailure failure = usingBuildFile(buildFile).withTasks("do-stuff").runWithFailure();
View Full Code Here

Examples of org.gradle.util.TestFile

    }

    @Test
    public void reportsTaskInjectedByOtherProjectFailsWithRuntimeException() {
        testFile("settings.gradle").write("include 'a', 'b'");
        TestFile buildFile = testFile("b/build.gradle");
        buildFile.writelns(
                "project(':a') {",
                "    task a << {",
                "        throw new RuntimeException('broken')",
                "    }",
                "}");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.