use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class UriScriptSourceTest method convenienceMethodScriptForFileThatHasContent.
@Test
public void convenienceMethodScriptForFileThatHasContent() {
new TestFile(scriptFile).write("content");
ScriptSource source = UriScriptSource.file("<file-type>", scriptFile);
assertThat(source, instanceOf(UriScriptSource.class));
assertThat(source.getResource().getFile(), equalTo(scriptFile));
assertThat(source.getResource().getCharset(), equalTo(Charset.forName("utf-8")));
assertThat(source.getResource().getLocation().getFile(), equalTo(scriptFile));
assertThat(source.getResource().getLocation().getURI(), equalTo(scriptFileUri));
assertThat(source.getResource().getText(), equalTo("content"));
assertFalse(source.getResource().isContentCached());
assertFalse(source.getResource().getHasEmptyContent());
assertTrue(source.getResource().getExists());
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class IntegrationTestBuildContext method getFatToolingApiJar.
public TestFile getFatToolingApiJar() {
TestFile toolingApiShadedJarDir = file("integTest.toolingApiShadedJarDir", "subprojects/tooling-api/build/shaded-jar");
TestFile fatToolingApiJar = new TestFile(toolingApiShadedJarDir, String.format("gradle-tooling-api-shaded-%s.jar", getVersion().getBaseVersion().getVersion()));
if (!fatToolingApiJar.exists()) {
throw new IllegalStateException(String.format("The fat Tooling API JAR file does not exist: %s", fatToolingApiJar.getAbsolutePath()));
}
return fatToolingApiJar;
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class Sample method apply.
public Statement apply(final Statement base, FrameworkMethod method, Object target) {
sampleName = getSampleName(method);
return new Statement() {
@Override
public void evaluate() throws Throwable {
if (sampleName != null) {
String hintForMissingSample = String.format("If '%s' is a new sample, try running 'gradle intTestImage'.", sampleName);
TestFile srcDir = new IntegrationTestBuildContext().getSamplesDir().file(sampleName).assertIsDir(hintForMissingSample);
logger.debug("Copying sample '{}' to test directory.", sampleName);
srcDir.copyTo(getDir());
} else {
logger.debug("No sample specified for this test, skipping.");
}
base.evaluate();
}
};
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class ForkingGradleExecuter method createExecHandleBuilder.
private DefaultExecHandleBuilder createExecHandleBuilder() {
TestFile gradleHomeDir = getDistribution().getGradleHomeDir();
if (!gradleHomeDir.isDirectory()) {
fail(gradleHomeDir + " is not a directory.\n" + "If you are running tests from IDE make sure that gradle tasks that prepare the test image were executed. Last time it was 'intTestImage' task.");
}
NativeServicesTestFixture.initialize();
DefaultExecHandleBuilder builder = new DefaultExecHandleBuilder(TestFiles.resolver()) {
@Override
public File getWorkingDir() {
// the working directory is not canonicalised
return ForkingGradleExecuter.this.getWorkingDir();
}
};
// Clear the user's environment
builder.environment("GRADLE_HOME", "");
builder.environment("JAVA_HOME", "");
builder.environment("GRADLE_OPTS", "");
builder.environment("JAVA_OPTS", "");
GradleInvocation invocation = buildInvocation();
builder.environment(invocation.environmentVars);
builder.workingDir(getWorkingDir());
builder.setStandardInput(connectStdIn());
builder.args(invocation.args);
ExecHandlerConfigurer configurer = OperatingSystem.current().isWindows() ? new WindowsConfigurer() : new UnixConfigurer();
configurer.configure(builder);
getLogger().debug(String.format("Execute in %s with: %s %s", builder.getWorkingDir(), builder.getExecutable(), builder.getArgs()));
return builder;
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class WebProjectIntegrationTest method canCustomizeArchiveNamesUsingConventionProperties.
@Test
public void canCustomizeArchiveNamesUsingConventionProperties() {
testFile("settings.gradle").writelns("rootProject.name = 'test'");
TestFile buildFile = testFile("build.gradle");
buildFile.writelns("apply plugin: 'war'", "buildDir = 'output'", "libsDirName = 'archives'", "archivesBaseName = 'test'", "version = '0.5-RC2'");
testFile("src/main/resources/org/gradle/resource.file").write("some resource");
usingBuildFile(buildFile).withTasks("assemble").run();
testFile("output/archives/test-0.5-RC2.war").assertIsFile();
}
Aggregations