Search in sources :

Example 1 with CompressedTarFunction

use of com.google.devtools.build.lib.bazel.repository.CompressedTarFunction in project bazel by bazelbuild.

the class CompressedTarFunctionTest method testDecompressWithPrefix.

/**
   * Test decompressing a tar.gz file with hard link file and symbolic link file inside and
   * stripping a prefix
   *
   * @throws Exception
   */
@Test
public void testDecompressWithPrefix() throws Exception {
    descriptorBuilder.setPrefix(ROOT_FOLDER_NAME);
    Path outputDir = new CompressedTarFunction() {

        @Override
        protected InputStream getDecompressorStream(DecompressorDescriptor descriptor) throws IOException {
            return new GZIPInputStream(new FileInputStream(descriptor.archivePath().getPathFile()));
        }
    }.decompress(descriptorBuilder.build());
    assertOutputFiles(outputDir.getRelative(INNER_FOLDER_NAME));
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) GZIPInputStream(java.util.zip.GZIPInputStream) CompressedTarFunction(com.google.devtools.build.lib.bazel.repository.CompressedTarFunction) GZIPInputStream(java.util.zip.GZIPInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) DecompressorDescriptor(com.google.devtools.build.lib.bazel.repository.DecompressorDescriptor) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 2 with CompressedTarFunction

use of com.google.devtools.build.lib.bazel.repository.CompressedTarFunction in project bazel by bazelbuild.

the class CompressedTarFunctionTest method testDecompressWithoutPrefix.

/**
   * Test decompressing a tar.gz file with hard link file and symbolic link file inside without
   * stripping a prefix
   *
   * @throws Exception
   */
@Test
public void testDecompressWithoutPrefix() throws Exception {
    Path outputDir = new CompressedTarFunction() {

        @Override
        protected InputStream getDecompressorStream(DecompressorDescriptor descriptor) throws IOException {
            return new GZIPInputStream(new FileInputStream(descriptor.archivePath().getPathFile()));
        }
    }.decompress(descriptorBuilder.build());
    assertOutputFiles(outputDir.getRelative(ROOT_FOLDER_NAME).getRelative(INNER_FOLDER_NAME));
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) GZIPInputStream(java.util.zip.GZIPInputStream) CompressedTarFunction(com.google.devtools.build.lib.bazel.repository.CompressedTarFunction) GZIPInputStream(java.util.zip.GZIPInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) DecompressorDescriptor(com.google.devtools.build.lib.bazel.repository.DecompressorDescriptor) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Aggregations

CompressedTarFunction (com.google.devtools.build.lib.bazel.repository.CompressedTarFunction)2 DecompressorDescriptor (com.google.devtools.build.lib.bazel.repository.DecompressorDescriptor)2 Path (com.google.devtools.build.lib.vfs.Path)2 FileInputStream (java.io.FileInputStream)2 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 GZIPInputStream (java.util.zip.GZIPInputStream)2 Test (org.junit.Test)2