aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party/ijar/test
diff options
context:
space:
mode:
authorGravatar cushon <cushon@google.com>2018-03-21 20:30:12 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-21 20:32:06 -0700
commitf572845d04c579e81b2dc78e8efeea12dc7dbee7 (patch)
tree068525bf67cfaec5ed1c4d384b9de7dd0c0b0da5 /third_party/ijar/test
parent2410e1ab3e035382abe519003c618271a69a7b8e (diff)
Include manifest size when presizing ijar output
PiperOrigin-RevId: 190010996
Diffstat (limited to 'third_party/ijar/test')
-rw-r--r--third_party/ijar/test/BUILD10
-rw-r--r--third_party/ijar/test/IjarTests.java12
2 files changed, 22 insertions, 0 deletions
diff --git a/third_party/ijar/test/BUILD b/third_party/ijar/test/BUILD
index d9ab5f788e..62b6edd3a3 100644
--- a/third_party/ijar/test/BUILD
+++ b/third_party/ijar/test/BUILD
@@ -109,6 +109,14 @@ genrule(
tools = ["//third_party/ijar"],
)
+genrule(
+ name = "empty_with_target_label",
+ srcs = [":empty_zip.jar"],
+ outs = ["empty_with_target_label.jar"],
+ cmd = "$(location //third_party/ijar) $< $@ --target_label //empty",
+ tools = ["//third_party/ijar"],
+)
+
java_library(
name = "typeannotations2",
srcs = glob(["typeannotations2/**/*.java"]),
@@ -187,6 +195,7 @@ java_test(
"UseDeprecatedParts.java",
"UseRestrictedAnnotation.java",
"package-info.java",
+ ":empty_with_target_label",
":interface_ijar_testlib",
":interface_ijar_testlib_with_target_label",
":liblocal_and_anonymous_lib.jar",
@@ -234,6 +243,7 @@ java_binary(
("largest_regular", 65535),
("smallest_zip64", 65536),
("definitely_zip64", 70000),
+ ("empty_zip", 1),
]
]
diff --git a/third_party/ijar/test/IjarTests.java b/third_party/ijar/test/IjarTests.java
index a2e10db570..dc6c02062a 100644
--- a/third_party/ijar/test/IjarTests.java
+++ b/third_party/ijar/test/IjarTests.java
@@ -292,4 +292,16 @@ public class IjarTests {
LocalDateTime.of(2010, 1, 1, 0, 0, 0).atZone(ZoneOffset.systemDefault()).toInstant());
}
}
+
+ @Test
+ public void testEmptyWithTargetLabel() throws Exception {
+ try (JarFile jf = new JarFile("third_party/ijar/test/empty_with_target_label.jar")) {
+ Manifest manifest = jf.getManifest();
+ Attributes attributes = manifest.getMainAttributes();
+ assertThat(attributes.getValue("Target-Label")).isEqualTo("//empty");
+ assertThat(jf.getEntry(JarFile.MANIFEST_NAME).getLastModifiedTime().toInstant())
+ .isEqualTo(
+ LocalDateTime.of(2010, 1, 1, 0, 0, 0).atZone(ZoneOffset.systemDefault()).toInstant());
+ }
+ }
}