use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class JavaBinaryIntegrationTest method fatJarWithBlacklist.
@Test
public void fatJarWithBlacklist() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "java_binary_with_blacklist", tmp);
workspace.setUp();
Path binaryJarWithBlacklist = workspace.buildAndReturnOutput("//:bin-blacklist");
Path binaryJarWithoutBlacklist = workspace.buildAndReturnOutput("//:bin-no-blacklist");
ImmutableSet<String> commonEntries = ImmutableSet.of("META-INF/", "META-INF/MANIFEST.MF", "com/", "com/example/", "com/example/B.class");
ImmutableSet<String> blacklistedEntries = ImmutableSet.of("com/example/A.class", "com/example/A$C.class", "com/example/Alligator.class");
assertEquals("com.example.Alligator, com.example.A and any inner classes should be removed.", commonEntries, new ZipInspector(binaryJarWithBlacklist).getZipFileEntries());
assertEquals(ImmutableSet.builder().addAll(commonEntries).addAll(blacklistedEntries).build(), new ZipInspector(binaryJarWithoutBlacklist).getZipFileEntries());
}
use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class CalculateAbiStepTest method shouldCalculateAbiFromAStubJar.
@Test
public void shouldCalculateAbiFromAStubJar() throws IOException {
Path outDir = temp.newFolder().toAbsolutePath();
ProjectFilesystem filesystem = new ProjectFilesystem(outDir);
Path directory = TestDataHelper.getTestDataDirectory(this);
Path source = directory.resolve("prebuilt/junit.jar");
Path binJar = Paths.get("source.jar");
Files.copy(source, outDir.resolve(binJar));
Path abiJar = outDir.resolve("abi.jar");
ExecutionContext executionContext = TestExecutionContext.newInstance();
FakeBuildableContext context = new FakeBuildableContext();
new CalculateAbiStep(context, filesystem, binJar, abiJar).execute(executionContext);
String seenHash = filesystem.computeSha1(Paths.get("abi.jar")).getHash();
// Hi there! This is hardcoded here because we want to make sure buck always produces the same
// jar files across timezones and versions. If the test is failing because of an intentional
// modification to how we produce abi .jar files, then just update the hash, otherwise please
// investigate why the value is different.
// NOTE: If this starts failing on CI for no obvious reason it's possible that the offset
// calculation in ZipConstants.getFakeTime() does not account for DST correctly.
assertEquals("2f8dd47439697c6d633f7baef3d0f71cbac9d4a4", seenHash);
// Assert that the abiJar contains non-class resources (like txt files).
ZipInspector inspector = new ZipInspector(abiJar);
inspector.assertFileExists("LICENSE.txt");
}
use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class InteractiveReportIntegrationTest method testTraceInReport.
@Test
public void testTraceInReport() throws Exception {
DefectSubmitResult report = createDefectReport(traceWorkspace, new ByteArrayInputStream("1\nreport text\n".getBytes("UTF-8")));
Path reportFile = traceWorkspace.asCell().getFilesystem().resolve(report.getReportSubmitLocation().get());
ZipInspector zipInspector = new ZipInspector(reportFile);
zipInspector.assertFileExists(tracePath1);
}
use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class InteractiveReportIntegrationTest method testTraceRespectReportSize.
@Test
public void testTraceRespectReportSize() throws Exception {
DefectSubmitResult report = createDefectReport(traceWorkspace, new ByteArrayInputStream("0,1\nreport text\n".getBytes("UTF-8")));
Path reportFile = traceWorkspace.asCell().getFilesystem().resolve(report.getReportSubmitLocation().get());
ZipInspector zipInspector = new ZipInspector(reportFile);
// The second command was more recent, so its file should be included.
zipInspector.assertFileExists(tracePath2);
zipInspector.assertFileDoesNotExist(tracePath1);
}
use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class ZipRuleIntegrationTest method shouldUnpackContentsOfASrcJar.
@Test
public void shouldUnpackContentsOfASrcJar() throws IOException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "zip-rule", tmp);
workspace.setUp();
Path zip = workspace.buildAndReturnOutput("//example:unrolled");
ZipInspector inspector = new ZipInspector(zip);
inspector.assertFileExists("menu.txt");
}
Aggregations