aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test
diff options
context:
space:
mode:
authorGravatar Xin Gao <xingao@google.com>2016-09-19 20:59:36 +0000
committerGravatar Laszlo Csomor <laszlocsomor@google.com>2016-09-20 06:46:17 +0000
commit4e2f75d8e60020f13a7df452488ec4cc7a719f03 (patch)
treefb97f63a4047a034699002a30450cb2a074256cc /src/test
parent243cd7559926dd5ef03609197b5c6bfaf874eaaa (diff)
Fixed symbolic link and hard link path not stripped when "strip_prefix" is set.
-- MOS_MIGRATED_REVID=133628392
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/repository/CompressedTarFunctionTest.java38
-rw-r--r--src/test/java/com/google/devtools/build/lib/rules/repository/test_decompress_archive.tar.gzbin216 -> 269 bytes
2 files changed, 36 insertions, 2 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/rules/repository/CompressedTarFunctionTest.java b/src/test/java/com/google/devtools/build/lib/rules/repository/CompressedTarFunctionTest.java
index b638b21052..35305da87f 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/repository/CompressedTarFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/rules/repository/CompressedTarFunctionTest.java
@@ -54,6 +54,8 @@ public class CompressedTarFunctionTest {
private static final String PATH_TO_TEST_ARCHIVE =
"/com/google/devtools/build/lib/rules/repository/";
+ private static final String ROOT_FOLDER_NAME = "root_folder";
+
/* Tarball, created by
* tar -czf <ARCHIVE_NAME> <REGULAR_FILE_NAME> <HARD_LINK_FILE_NAME> <SYMBOLIC_LINK_FILE_NAME>
*/
@@ -86,12 +88,36 @@ public class CompressedTarFunctionTest {
}
/**
- * Test decompressing a tar.gz file with hard link file and symbolic link file inside
+ * 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));
+ }
+
+ /**
+ * Test decompressing a tar.gz file with hard link file and symbolic link file inside and
+ * stripping a prefix
*
* @throws Exception
*/
@Test
- public void testDecompress() throws Exception {
+ public void testDecompressWithPrefix() throws Exception {
+
+ descriptorBuilder.setPrefix(ROOT_FOLDER_NAME);
Path outputDir =
new CompressedTarFunction() {
@@ -102,6 +128,14 @@ public class CompressedTarFunctionTest {
}
}.decompress(descriptorBuilder.build());
+ assertOutputFiles(outputDir);
+ }
+
+ /**
+ * Validate the content of the output directory
+ */
+ private void assertOutputFiles(Path outputDir) throws Exception {
+
assertThat(outputDir.exists()).isTrue();
assertThat(outputDir.getRelative(REGULAR_FILE_NAME).exists()).isTrue();
assertThat(outputDir.getRelative(REGULAR_FILE_NAME).getFileSize()).isNotEqualTo(0);
diff --git a/src/test/java/com/google/devtools/build/lib/rules/repository/test_decompress_archive.tar.gz b/src/test/java/com/google/devtools/build/lib/rules/repository/test_decompress_archive.tar.gz
index f951e97860..b1bd70fafd 100644
--- a/src/test/java/com/google/devtools/build/lib/rules/repository/test_decompress_archive.tar.gz
+++ b/src/test/java/com/google/devtools/build/lib/rules/repository/test_decompress_archive.tar.gz
Binary files differ