use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class InteractiveReportIntegrationTest method testReport.
@Test
public void testReport() throws Exception {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "interactive_report", temporaryFolder);
workspace.setUp();
DefectSubmitResult report = createDefectReport(workspace, new ByteArrayInputStream("0,1\nreport text\n".getBytes("UTF-8")));
Path reportFile = workspace.asCell().getFilesystem().resolve(report.getReportSubmitLocation().get());
ZipInspector zipInspector = new ZipInspector(reportFile);
zipInspector.assertFileExists("report.json");
zipInspector.assertFileExists(BUILD_PATH + "buck.log");
zipInspector.assertFileExists(DEPS_PATH + "buck.log");
}
use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class InteractiveReportIntegrationTest method testWatchmanDiagReport.
@Test
public void testWatchmanDiagReport() throws Exception {
DefectSubmitResult report = createDefectReport(traceWorkspace, new ByteArrayInputStream("0,1\nreport text\n\n".getBytes("UTF-8")));
Path reportFile = traceWorkspace.asCell().getFilesystem().resolve(report.getReportSubmitLocation().get());
ZipInspector zipInspector = new ZipInspector(reportFile);
assertThat(zipInspector.getZipFileEntries(), Matchers.hasItem(Matchers.stringContainsInOrder("watchman-diag-report")));
}
use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class TrimUberRDotJavaTest method doTrimingTest.
private void doTrimingTest(Optional<String> keepResourcePattern, String rDotJavaContentsAfterFiltering) throws IOException, InterruptedException {
ProjectFilesystem filesystem = new ProjectFilesystem(tmpFolder.getRoot());
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(resolver);
SourcePathResolver pathResolver = new SourcePathResolver(ruleFinder);
AaptPackageResources aaptPackageResources = new AaptPackageResources(new FakeBuildRuleParamsBuilder(BuildTargetFactory.newInstance("//:aapt")).setProjectFilesystem(filesystem).build(), ruleFinder, resolver, null, new IdentityResourcesProvider(ImmutableList.of()), ImmutableList.of(), ImmutableSortedSet.of(), ImmutableSet.of(), Optional.empty(), false, false, /* includesVectorDrawables */
false, EnumSet.noneOf(RType.class), null);
resolver.addToIndex(aaptPackageResources);
String rDotJavaContents = "package com.test;\n" + "\n" + "public class R {\n" + " public static class string {\n" + " public static final int my_first_resource=0x7f08005c;\n" + " public static final int my_second_resource=0x7f083bc1;\n" + " public static final int keep_resource=0x7f083bc2;\n" + " }\n" + "}\n";
Path rDotJavaPath = aaptPackageResources.getPathToGeneratedRDotJavaSrcFiles().resolve("com/test/R.java");
filesystem.createParentDirs(rDotJavaPath);
filesystem.writeContentsToPath(rDotJavaContents, rDotJavaPath);
DexProducedFromJavaLibrary dexProducedFromJavaLibrary = new DexProducedFromJavaLibrary(new FakeBuildRuleParamsBuilder(BuildTargetFactory.newInstance("//:dex")).setProjectFilesystem(filesystem).build(), new FakeJavaLibrary(BuildTargetFactory.newInstance("//:lib"), null));
dexProducedFromJavaLibrary.getBuildOutputInitializer().setBuildOutput(dexProducedFromJavaLibrary.initializeFromDisk(new FakeOnDiskBuildInfo().putMetadata(DexProducedFromJavaLibrary.WEIGHT_ESTIMATE, "1").putMetadata(DexProducedFromJavaLibrary.CLASSNAMES_TO_HASHES, "{}").putMetadata(DexProducedFromJavaLibrary.REFERENCED_RESOURCES, ImmutableList.of("com.test.my_first_resource"))));
resolver.addToIndex(dexProducedFromJavaLibrary);
TrimUberRDotJava trimUberRDotJava = new TrimUberRDotJava(new FakeBuildRuleParamsBuilder(BuildTargetFactory.newInstance("//:trim")).setProjectFilesystem(filesystem).build(), aaptPackageResources, ImmutableList.of(dexProducedFromJavaLibrary), keepResourcePattern);
resolver.addToIndex(trimUberRDotJava);
BuildContext buildContext = FakeBuildContext.withSourcePathResolver(pathResolver);
BuildableContext buildableContext = new FakeBuildableContext();
ExecutionContext executionContext = TestExecutionContext.newInstance();
ImmutableList<Step> steps = trimUberRDotJava.getBuildSteps(buildContext, buildableContext);
for (Step step : steps) {
step.execute(executionContext);
}
ZipInspector inspector = new ZipInspector(pathResolver.getAbsolutePath(trimUberRDotJava.getSourcePathToOutput()));
inspector.assertFileContents("com/test/R.java", rDotJavaContentsAfterFiltering);
}
Aggregations