use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class AndroidResourceFilterIntegrationTest method testApkWithStringsAsAssets.
@Test
public void testApkWithStringsAsAssets() throws IOException {
String target = "//apps/sample:app_comp_str";
ProjectWorkspace.ProcessResult result = workspace.runBuckCommand("build", target);
result.assertSuccess();
Path apkFile = workspace.getPath(BuildTargets.getGenPath(filesystem, BuildTargetFactory.newInstance(target), "%s.apk"));
ZipInspector zipInspector = new ZipInspector(apkFile);
zipInspector.assertFileExists("assets/strings/fr.fbstr");
}
use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class ResourcesRootIntegrationTest method testResourcePathRelativeToResourcesRoot.
@Test
public void testResourcePathRelativeToResourcesRoot() throws IOException, InterruptedException {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "resources_root", temporaryFolder);
workspace.setUp();
Path supWorldJar = workspace.buildAndReturnOutput("//java/com/example:SupWorld");
ZipInspector inspector = new ZipInspector(supWorldJar);
inspector.assertFileExists("com/another/supworld.txt");
ProcessExecutor.Result result = workspace.runJar(supWorldJar);
assertEquals("SupWorld should print the resource file's contents.", "nuthin much\n", result.getStdout().get());
assertEquals("", result.getStderr().get());
}
use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class RageCommandIntegrationTest method testUploadFailure.
@Test
public void testUploadFailure() throws Exception {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "interactive_report", temporaryFolder);
workspace.setUp();
try (HttpdForTests httpd = new HttpdForTests()) {
httpd.addHandler(new AbstractHandler() {
@Override
public void handle(String s, Request request, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException, ServletException {
httpServletResponse.setStatus(500);
request.setHandled(true);
}
});
httpd.start();
RageConfig rageConfig = createRageConfig(httpd.getRootUri().getPort(), "", RageProtocolVersion.SIMPLE);
ProjectFilesystem filesystem = new ProjectFilesystem(temporaryFolder.getRoot());
ObjectMapper objectMapper = ObjectMappers.newDefaultInstance();
Clock clock = new DefaultClock();
DefectReporter reporter = new DefaultDefectReporter(filesystem, objectMapper, rageConfig, BuckEventBusFactory.newInstance(clock), clock);
AutomatedReport automatedReport = new AutomatedReport(reporter, filesystem, objectMapper, new TestConsole(), TestBuildEnvironmentDescription.INSTANCE, VcsInfoCollector.create(new NoOpCmdLineInterface()), rageConfig, Optional::empty);
DefectSubmitResult submitReport = automatedReport.collectAndSubmitResult().get();
// If upload fails it should store the zip locally and inform the user.
assertFalse(submitReport.getReportSubmitErrorMessage().get().isEmpty());
ZipInspector zipInspector = new ZipInspector(filesystem.resolve(submitReport.getReportSubmitLocation().get()));
assertEquals(zipInspector.getZipFileEntries().size(), 7);
}
}
use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class RageCommandIntegrationTest method testUpload.
@Test
public void testUpload() throws Exception {
ProjectWorkspace workspace = TestDataHelper.createProjectWorkspaceForScenario(this, "interactive_report", temporaryFolder);
workspace.setUp();
final AtomicReference<String> requestMethod = new AtomicReference<>();
final AtomicReference<String> requestPath = new AtomicReference<>();
final AtomicReference<byte[]> requestBody = new AtomicReference<>();
final String successMessage = "Upload successful";
try (HttpdForTests httpd = new HttpdForTests()) {
httpd.addHandler(new AbstractHandler() {
@Override
public void handle(String s, Request request, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException, ServletException {
httpServletResponse.setStatus(200);
request.setHandled(true);
if (request.getUri().getPath().equals("/status.php")) {
return;
}
requestPath.set(request.getUri().getPath());
requestMethod.set(request.getMethod());
requestBody.set(ByteStreams.toByteArray(httpServletRequest.getInputStream()));
try (DataOutputStream out = new DataOutputStream(httpServletResponse.getOutputStream())) {
out.writeBytes(successMessage);
}
}
});
httpd.start();
RageConfig rageConfig = createRageConfig(httpd.getRootUri().getPort(), "", RageProtocolVersion.SIMPLE);
ProjectFilesystem filesystem = new ProjectFilesystem(temporaryFolder.getRoot());
Clock clock = new DefaultClock();
DefectReporter reporter = new DefaultDefectReporter(filesystem, objectMapper, rageConfig, BuckEventBusFactory.newInstance(clock), clock);
AutomatedReport automatedReport = new AutomatedReport(reporter, filesystem, objectMapper, new TestConsole(), TestBuildEnvironmentDescription.INSTANCE, VcsInfoCollector.create(new NoOpCmdLineInterface()), rageConfig, Optional::empty);
DefectSubmitResult defectSubmitResult = automatedReport.collectAndSubmitResult().get();
assertThat(defectSubmitResult.getReportSubmitMessage(), Matchers.equalTo(Optional.of(successMessage)));
assertThat(requestPath.get(), Matchers.equalTo(UPLOAD_PATH));
assertThat(requestMethod.get(), Matchers.equalTo("POST"));
filesystem.mkdirs(filesystem.getBuckPaths().getBuckOut());
Path report = filesystem.createTempFile(filesystem.getBuckPaths().getBuckOut(), "report", "zip");
filesystem.writeBytesToPath(requestBody.get(), report);
ZipInspector zipInspector = new ZipInspector(filesystem.resolve(report));
zipInspector.assertFileExists("report.json");
zipInspector.assertFileExists("buckconfig.local");
zipInspector.assertFileExists("bucklogging.local.properties");
zipInspector.assertFileExists(BUILD_COMMAND_DIR_PATH + "buck.log");
zipInspector.assertFileExists(AUTODEPS_COMMAND_DIR_PATH + "buck.log");
zipInspector.assertFileExists(BUILD_COMMAND_DIR_PATH + "buck-machine-log");
zipInspector.assertFileExists(AUTODEPS_COMMAND_DIR_PATH + "buck-machine-log");
}
}
use of com.facebook.buck.testutil.integration.ZipInspector in project buck by facebook.
the class DefectReporterTest method testAttachesPaths.
@Test
public void testAttachesPaths() throws Exception {
ProjectFilesystem filesystem = new ProjectFilesystem(temporaryFolder.getRoot());
RageConfig config = RageConfig.of(FakeBuckConfig.builder().build());
Clock clock = new DefaultClock();
DefectReporter reporter = new DefaultDefectReporter(filesystem, ObjectMappers.newDefaultInstance(), config, BuckEventBusFactory.newInstance(clock), clock);
Path fileToBeIncluded = Paths.get("FileToBeIncluded.txt");
filesystem.touch(fileToBeIncluded);
String fileToBeIncludedContent = "testcontentbehere";
filesystem.writeContentsToPath(fileToBeIncludedContent, fileToBeIncluded);
DefectSubmitResult defectSubmitResult = reporter.submitReport(DefectReport.builder().setBuildEnvironmentDescription(TEST_ENV_DESCRIPTION).setIncludedPaths(fileToBeIncluded).setUserLocalConfiguration(TEST_USER_LOCAL_CONFIGURATION).build());
Path reportPath = filesystem.resolve(defectSubmitResult.getReportSubmitLocation().get());
ZipInspector inspector = new ZipInspector(reportPath);
inspector.assertFileContents(fileToBeIncluded, fileToBeIncludedContent);
}
Aggregations