Search in sources :

Example 6 with ArArchiveInputStream

use of org.apache.commons.compress.archivers.ar.ArArchiveInputStream in project buck by facebook.

the class ArchiveStepIntegrationTest method emptyArchives.

@Test
public void emptyArchives() throws IOException, InterruptedException {
    ProjectFilesystem filesystem = new ProjectFilesystem(tmp.getRoot());
    CxxPlatform platform = CxxPlatformUtils.build(new CxxBuckConfig(FakeBuckConfig.builder().build()));
    // Build up the paths to various files the archive step will use.
    SourcePathResolver sourcePathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
    Archiver archiver = platform.getAr();
    Path output = filesystem.getPath("output.a");
    // Build an archive step.
    ArchiveStep archiveStep = new ArchiveStep(filesystem, archiver.getEnvironment(sourcePathResolver), archiver.getCommandPrefix(sourcePathResolver), ImmutableList.of(), getArchiveOptions(false), output, ImmutableList.of(), archiver);
    // Execute the archive step and verify it ran successfully.
    ExecutionContext executionContext = TestExecutionContext.newInstance();
    TestConsole console = (TestConsole) executionContext.getConsole();
    int exitCode = archiveStep.execute(executionContext).getExitCode();
    assertEquals("archive step failed: " + console.getTextWrittenToStdErr(), 0, exitCode);
    // zero'd out.
    try (ArArchiveInputStream stream = new ArArchiveInputStream(new FileInputStream(filesystem.resolve(output).toFile()))) {
        assertThat(stream.getNextArEntry(), Matchers.nullValue());
    }
}
Also used : Path(java.nio.file.Path) ArArchiveInputStream(org.apache.commons.compress.archivers.ar.ArArchiveInputStream) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) FileInputStream(java.io.FileInputStream) ExecutionContext(com.facebook.buck.step.ExecutionContext) TestExecutionContext(com.facebook.buck.step.TestExecutionContext) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) TestConsole(com.facebook.buck.testutil.TestConsole) Test(org.junit.Test)

Aggregations

ArArchiveInputStream (org.apache.commons.compress.archivers.ar.ArArchiveInputStream)6 FileInputStream (java.io.FileInputStream)5 Path (java.nio.file.Path)5 Test (org.junit.Test)5 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)4 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)4 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)4 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)4 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)4 ExecutionContext (com.facebook.buck.step.ExecutionContext)4 TestExecutionContext (com.facebook.buck.step.TestExecutionContext)4 TestConsole (com.facebook.buck.testutil.TestConsole)4 ArArchiveEntry (org.apache.commons.compress.archivers.ar.ArArchiveEntry)4 OutputStream (java.io.OutputStream)2 FileScrubberStep (com.facebook.buck.step.fs.FileScrubberStep)1 ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)1 BufferedInputStream (java.io.BufferedInputStream)1 IOException (java.io.IOException)1 ArchiveInputStream (org.apache.commons.compress.archivers.ArchiveInputStream)1 CpioArchiveInputStream (org.apache.commons.compress.archivers.cpio.CpioArchiveInputStream)1