use of com.facebook.buck.timing.FakeClock in project buck by facebook.
the class MiniAaptTest method testProcessFileNamesInDirectory.
@Test
public void testProcessFileNamesInDirectory() throws IOException, ResourceParseException {
filesystem.touch(Paths.get("res/drawable/icon.png"));
filesystem.touch(Paths.get("res/drawable/another_icon.png.orig"));
filesystem.touch(Paths.get("res/drawable-ldpi/nine_patch.9.png"));
filesystem.touch(Paths.get("res/drawable-ldpi/.DS_Store"));
filesystem.touch(Paths.get("res/transition-v19/some_transition.xml"));
filesystem.writeContentsToPath("<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<resources>" + "<bool name=\"v\">false</bool>" + "</resources>", Paths.get("res/values/value.xml~"));
MiniAapt aapt = new MiniAapt(resolver, filesystem, new FakeSourcePath(filesystem, "res"), Paths.get("R.txt"), ImmutableSet.of());
aapt.processFileNamesInDirectory(filesystem, Paths.get("res/drawable"));
aapt.processFileNamesInDirectory(filesystem, Paths.get("res/drawable-ldpi"));
aapt.processFileNamesInDirectory(filesystem, Paths.get("res/transition-v19"));
aapt.processValues(filesystem, new BuckEventBus(new FakeClock(0), new BuildId("")), Paths.get("res/values"));
assertEquals(ImmutableSet.<RDotTxtEntry>of(new FakeRDotTxtEntry(IdType.INT, RType.DRAWABLE, "icon"), new FakeRDotTxtEntry(IdType.INT, RType.DRAWABLE, "nine_patch"), new FakeRDotTxtEntry(IdType.INT, RType.TRANSITION, "some_transition")), aapt.getResourceCollector().getResources());
}
use of com.facebook.buck.timing.FakeClock in project buck by facebook.
the class TestWithBuckd method before.
@Override
protected void before() throws IOException, InterruptedException {
// In case root_restrict_files is enabled in /etc/watchmanconfig, assume
// this is one of the entries so it doesn't give up.
temporaryPaths.newFolder(".git");
temporaryPaths.newFile(".arcconfig");
Watchman watchman = Watchman.build(ImmutableSet.of(temporaryPaths.getRoot()), getWatchmanEnv(), new TestConsole(), new FakeClock(0), Optional.empty());
// We assume watchman has been installed and configured properly on the system, and that setting
// up the watch is successful.
assumeFalse(watchman == Watchman.NULL_WATCHMAN);
}
use of com.facebook.buck.timing.FakeClock in project buck by facebook.
the class PrebuiltJarSymbolsFinderTest method createFinderForFileWithEntries.
private PrebuiltJarSymbolsFinder createFinderForFileWithEntries(String jarFileName, Iterable<String> entries) throws IOException {
Clock clock = new FakeClock(1);
Path jarFile = tmp.newFile(jarFileName);
try (OutputStream stream = new BufferedOutputStream(java.nio.file.Files.newOutputStream(jarFile));
CustomZipOutputStream out = ZipOutputStreams.newOutputStream(stream, ZipOutputStreams.HandleDuplicates.THROW_EXCEPTION, clock)) {
for (String entry : entries) {
out.putNextEntry(new ZipEntry(entry));
}
}
ProjectFilesystem filesystem = new ProjectFilesystem(tmp.getRoot());
SourcePath sourcePath = new PathSourcePath(filesystem, Paths.get(jarFileName));
return new PrebuiltJarSymbolsFinder(sourcePath);
}
use of com.facebook.buck.timing.FakeClock in project buck by facebook.
the class IjProjectDataPreparerTest method testExcludePaths.
@Test
public void testExcludePaths() throws Exception {
/**
* Fake filesystem structure
* .idea
* |- misc.xml
* .git
* |- HEAD
* java
* |- com
* |- BUCK
* |- data
* |- wsad.txt
* |- src
* |- BUCK
* |- Source.java
* |- foo
* |- Foo.java
* |- src2
* |- Code.java
* |- org
* |- bar
* |- Bar.java
* lib
* |- BUCK
* |- guava.jar
*/
ImmutableSet<Path> paths = ImmutableSet.of(Paths.get(".idea/misc.xml"), Paths.get(".git/HEAD"), Paths.get("java/com/BUCK"), Paths.get("java/com/data/wsad.txt"), Paths.get("java/com/src/BUCK"), Paths.get("java/com/src/Source.java"), Paths.get("java/com/src/foo/Foo.java"), Paths.get("java/org/bar/Bar.java"), Paths.get("lib/BUCK"), Paths.get("lib/guava.jar"));
FakeProjectFilesystem filesystemForExcludesTest = new FakeProjectFilesystem(new FakeClock(0), Paths.get(".").toAbsolutePath(), paths);
TargetNode<?, ?> guavaTargetNode = PrebuiltJarBuilder.createBuilder(BuildTargetFactory.newInstance("//lib:guava")).setBinaryJar(Paths.get("lib/guava.jar")).build();
TargetNode<?, ?> srcTargetNode = JavaLibraryBuilder.createBuilder(BuildTargetFactory.newInstance("//java/com/src:src")).addDep(guavaTargetNode.getBuildTarget()).addSrc(Paths.get("java/com/src/Source.java")).build();
TargetNode<?, ?> src2TargetNode = JavaLibraryBuilder.createBuilder(BuildTargetFactory.newInstance("//java/com:src2")).addDep(guavaTargetNode.getBuildTarget()).addSrc(Paths.get("java/com/src2/Code.java")).build();
TargetNode<?, ?> rootTargetNode = JavaLibraryBuilder.createBuilder(BuildTargetFactory.newInstance("//:root")).build();
IjModuleGraph moduleGraph = IjModuleGraphTest.createModuleGraph(ImmutableSet.of(guavaTargetNode, srcTargetNode, src2TargetNode, rootTargetNode));
IjModule srcModule = IjModuleGraphTest.getModuleForTarget(moduleGraph, srcTargetNode);
IjModule src2Module = IjModuleGraphTest.getModuleForTarget(moduleGraph, src2TargetNode);
IjModule rootModule = IjModuleGraphTest.getModuleForTarget(moduleGraph, rootTargetNode);
IjProjectTemplateDataPreparer dataPreparer = new IjProjectTemplateDataPreparer(javaPackageFinder, moduleGraph, filesystemForExcludesTest);
assertEquals(ImmutableSet.of(Paths.get("java/com/src/foo")), distillExcludeFolders(dataPreparer.createExcludes(srcModule)));
assertEquals(ImmutableSet.of(Paths.get("java/com/data")), distillExcludeFolders(dataPreparer.createExcludes(src2Module)));
// In this case it's fine to exclude "lib" as there is no source code there.
assertEquals(ImmutableSet.of(Paths.get(".git"), Paths.get("java/org"), Paths.get("lib")), distillExcludeFolders(dataPreparer.createExcludes(rootModule)));
}
Aggregations