use of com.facebook.buck.io.ProjectFilesystem in project buck by facebook.
the class AndroidManifestTest method testBuildInternal.
@Test
public void testBuildInternal() throws IOException {
AndroidManifest androidManifest = createSimpleAndroidManifestRule();
ProjectFilesystem filesystem = androidManifest.getProjectFilesystem();
Path skeletonPath = Paths.get("java/com/example/AndroidManifestSkeleton.xml");
// Mock out a BuildContext whose DependencyGraph will be traversed.
BuildContext buildContext = FakeBuildContext.NOOP_CONTEXT;
SourcePathResolver pathResolver = buildContext.getSourcePathResolver();
expect(pathResolver.getAbsolutePath(new PathSourcePath(filesystem, skeletonPath))).andStubReturn(filesystem.resolve(skeletonPath));
expect(pathResolver.getAllAbsolutePaths(ImmutableSortedSet.of())).andStubReturn(ImmutableSortedSet.of());
Path outPath = Paths.get("foo/bar");
expect(pathResolver.getRelativePath(androidManifest.getSourcePathToOutput())).andStubReturn(outPath);
replay(pathResolver);
List<Step> steps = androidManifest.getBuildSteps(buildContext, new FakeBuildableContext());
Step generateManifestStep = steps.get(2);
assertEquals(new GenerateManifestStep(filesystem, filesystem.resolve(skeletonPath), /* libraryManifestPaths */
ImmutableSet.of(), outPath), generateManifestStep);
}
use of com.facebook.buck.io.ProjectFilesystem in project buck by facebook.
the class DxStepTest method testDxCommandOptimizeNoJumbo.
@Test
public void testDxCommandOptimizeNoJumbo() throws IOException {
// Context with --verbose 2.
try (ExecutionContext context = createExecutionContext(2)) {
ProjectFilesystem filesystem = FakeProjectFilesystem.createJavaOnlyFilesystem();
DxStep dx = new DxStep(filesystem, SAMPLE_OUTPUT_PATH, SAMPLE_FILES_TO_DEX);
String expected = String.format("%s --output %s %s", EXPECTED_DX_PREFIX, SAMPLE_OUTPUT_PATH, Joiner.on(' ').join(Iterables.transform(SAMPLE_FILES_TO_DEX, filesystem::resolve)));
MoreAsserts.assertShellCommands("Neither --no-optimize nor --force-jumbo should be present.", ImmutableList.of(expected), ImmutableList.of(dx), context);
verifyAll();
}
}
use of com.facebook.buck.io.ProjectFilesystem in project buck by facebook.
the class DxStepTest method testDxCommandNoOptimizeNoJumbo.
@Test
public void testDxCommandNoOptimizeNoJumbo() throws IOException {
// Context with --verbose 2.
try (ExecutionContext context = createExecutionContext(2)) {
ProjectFilesystem filesystem = FakeProjectFilesystem.createJavaOnlyFilesystem();
DxStep dx = new DxStep(filesystem, SAMPLE_OUTPUT_PATH, SAMPLE_FILES_TO_DEX, EnumSet.of(Option.NO_OPTIMIZE));
String expected = String.format("%s --no-optimize --output %s %s", EXPECTED_DX_PREFIX, SAMPLE_OUTPUT_PATH, Joiner.on(' ').join(Iterables.transform(SAMPLE_FILES_TO_DEX, filesystem::resolve)));
MoreAsserts.assertShellCommands("--no-optimize should be present, but --force-jumbo should not.", ImmutableList.of(expected), ImmutableList.of(dx), context);
verifyAll();
}
}
use of com.facebook.buck.io.ProjectFilesystem in project buck by facebook.
the class FilterResourcesStepTest method valuesAlwaysIncludesFallback.
@Test
public void valuesAlwaysIncludesFallback() throws IOException, InterruptedException {
final ResourceFilters.Density targetDensity = ResourceFilters.Density.MDPI;
final String file = "somefile.xml";
final Path resDir = Paths.get("res/foo/bar");
final Path resOutDir = Paths.get("res-out");
ProjectFilesystem filesystem = new FakeProjectFilesystem();
filesystem.mkdirs(resDir);
filesystem.createNewFile(resDir.resolve("values").resolve(file));
filesystem.createNewFile(resDir.resolve(String.format("values-%s", targetDensity)).resolve(file));
FilterResourcesStep command = new FilterResourcesStep(filesystem, ImmutableBiMap.of(resDir, resOutDir), /* filterByDPI */
true, /* enableStringWhitelisting */
false, /* whitelistedStringDirs */
ImmutableSet.of(), /* locales */
ImmutableSet.of(), DefaultFilteredDirectoryCopier.getInstance(), ImmutableSet.of(targetDensity), FilterResourcesStep.DefaultDrawableFinder.getInstance(), /* imageScaler */
null);
command.execute(null);
assertThat(filesystem, ProjectFilesystemMatchers.pathExists(resOutDir.resolve("values").resolve(file)));
assertThat(filesystem, ProjectFilesystemMatchers.pathExists(resOutDir.resolve(String.format("values-%s", targetDensity)).resolve(file)));
}
use of com.facebook.buck.io.ProjectFilesystem in project buck by facebook.
the class FilterResourcesStepTest method xmlDrawableResourcesFiltered.
@Test
public void xmlDrawableResourcesFiltered() throws IOException, InterruptedException {
final ResourceFilters.Density targetDensity = ResourceFilters.Density.MDPI;
final ResourceFilters.Density excludedDensity = ResourceFilters.Density.LDPI;
final String file = "somefile.xml";
final Path resDir = Paths.get("res");
final Path resOutDir = Paths.get("res-out");
ProjectFilesystem filesystem = new FakeProjectFilesystem();
filesystem.mkdirs(resDir);
filesystem.createNewFile(resDir.resolve(String.format("drawable-%s", targetDensity)).resolve(file));
filesystem.createNewFile(resDir.resolve(String.format("drawable-%s", excludedDensity)).resolve(file));
FilterResourcesStep command = new FilterResourcesStep(filesystem, ImmutableBiMap.of(resDir, resOutDir), /* filterByDPI */
true, /* enableStringWhitelisting */
false, /* whitelistedStringDirs */
ImmutableSet.of(), /* locales */
ImmutableSet.of(), DefaultFilteredDirectoryCopier.getInstance(), ImmutableSet.of(targetDensity), FilterResourcesStep.DefaultDrawableFinder.getInstance(), /* imageScaler */
null);
command.execute(null);
assertThat(filesystem, ProjectFilesystemMatchers.pathExists(resOutDir.resolve(String.format("drawable-%s", targetDensity)).resolve(file)));
assertThat(filesystem, ProjectFilesystemMatchers.pathDoesNotExist(resOutDir.resolve(String.format("drawable-%s", excludedDensity)).resolve(file)));
}
Aggregations