use of org.gradle.test.fixtures.file.TestFile 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));
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class ProjectLoadingIntegrationTest method handlesSimilarlyNamedBuildFilesInSameDirectory.
@Test
public void handlesSimilarlyNamedBuildFilesInSameDirectory() {
TestFile buildFile1 = testFile("similarly-named build.gradle").write("task build");
TestFile buildFile2 = testFile("similarly_named_build_gradle").write("task 'other-build'");
usingBuildFile(buildFile1).withTasks("build").run();
usingBuildFile(buildFile2).withTasks("other-build").run();
usingBuildFile(buildFile1).withTasks("build").run();
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class MapFileTreeTest method doesNotOverwriteFileWhenGeneratedContentRemainsTheSame.
@Test
public void doesNotOverwriteFileWhenGeneratedContentRemainsTheSame() {
Action<OutputStream> action = getAction();
tree.add("path/file.txt", action);
assertVisits(tree, toList("path/file.txt"), toList("path"));
TestFile file = rootDir.file("path/file.txt");
file.assertContents(equalTo("content"));
TestFile.Snapshot snapshot = file.snapshot();
try {
// make sure file modification time would change if file would get written
Thread.sleep(1000L);
} catch (InterruptedException e) {
// ignore
}
assertVisits(tree, toList("path/file.txt"), toList("path"));
file.assertContents(equalTo("content"));
file.assertHasNotChangedSince(snapshot);
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class MapFileTreeTest method overwritesFileWhenGeneratedContentChanges.
@Test
public void overwritesFileWhenGeneratedContentChanges() {
final AtomicReference<String> currentContentReference = new AtomicReference<String>("content");
tree.add("path/file.txt", new Action<OutputStream>() {
@Override
public void execute(OutputStream outputStream) {
try {
outputStream.write(currentContentReference.get().getBytes());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
});
assertVisits(tree, toList("path/file.txt"), toList("path"));
TestFile file = rootDir.file("path/file.txt");
file.assertContents(equalTo("content"));
TestFile.Snapshot snapshot = file.snapshot();
currentContentReference.set("updated content");
assertVisits(tree, toList("path/file.txt"), toList("path"));
file.assertContents(equalTo("updated content"));
file.assertHasChangedSince(snapshot);
}
use of org.gradle.test.fixtures.file.TestFile in project gradle by gradle.
the class TarFileTreeTest method readsGzippedTarFile.
@Test
public void readsGzippedTarFile() {
TestFile tgz = tmpDir.getTestDirectory().file("test.tgz");
rootDir.file("subdir/file1.txt").write("content");
rootDir.file("subdir2/file2.txt").write("content");
rootDir.tgzTo(tgz);
TarFileTree tree = new TarFileTree(tarFile, new MaybeCompressedFileResource(new FileResource(tgz)), expandDir, fileSystem(), fileSystem(), directoryFileTreeFactory());
assertVisits(tree, toList("subdir/file1.txt", "subdir2/file2.txt"), toList("subdir", "subdir2"));
assertSetContainsForAllTypes(tree, toList("subdir/file1.txt", "subdir2/file2.txt"));
}
Aggregations