summaryrefslogtreecommitdiff
path: root/zip/zip_test.go
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2023-05-08 15:05:29 -0700
committer Colin Cross <ccross@android.com> 2023-05-09 23:19:12 +0000
commit25ff305370712354a8a6f903825833893be275cc (patch)
tree1d0aca4853d84d8a6fea8e0589b8f8be0aa7f552 /zip/zip_test.go
parent38917496e5e87fd638dc2a5a8dff937bb436480c (diff)
Add -e argument to soong_zip to allow setting an explicit filename
soong_zip normally takes the name of the input source file as the name of the file in the zip, which is ideal for zipping up directories but not for constructing arbitrary zip files. Add a -e argument that explicitly sets the path in the zip file for the next -f argument. Bug: 254867347 Test: zip_test.go Change-Id: If9d62c1a0064a485aebddf6d2a661f63f3e60b0f
Diffstat (limited to 'zip/zip_test.go')
-rw-r--r--zip/zip_test.go70
1 files changed, 70 insertions, 0 deletions
diff --git a/zip/zip_test.go b/zip/zip_test.go
index e7fdea839..c64c3f499 100644
--- a/zip/zip_test.go
+++ b/zip/zip_test.go
@@ -454,6 +454,60 @@ func TestZip(t *testing.T) {
fhWithSHA256("c", fileC, zip.Deflate, sha256FileC),
},
},
+ {
+ name: "explicit path",
+ args: fileArgsBuilder().
+ ExplicitPathInZip("foo").
+ File("a/a/a").
+ File("a/a/b"),
+ compressionLevel: 9,
+
+ files: []zip.FileHeader{
+ fh("foo", fileA, zip.Deflate),
+ fh("a/a/b", fileB, zip.Deflate),
+ },
+ },
+ {
+ name: "explicit path with prefix",
+ args: fileArgsBuilder().
+ PathPrefixInZip("prefix").
+ ExplicitPathInZip("foo").
+ File("a/a/a").
+ File("a/a/b"),
+ compressionLevel: 9,
+
+ files: []zip.FileHeader{
+ fh("prefix/foo", fileA, zip.Deflate),
+ fh("prefix/a/a/b", fileB, zip.Deflate),
+ },
+ },
+ {
+ name: "explicit path with glob",
+ args: fileArgsBuilder().
+ ExplicitPathInZip("foo").
+ File("a/a/a*").
+ File("a/a/b"),
+ compressionLevel: 9,
+
+ files: []zip.FileHeader{
+ fh("foo", fileA, zip.Deflate),
+ fh("a/a/b", fileB, zip.Deflate),
+ },
+ },
+ {
+ name: "explicit path with junk paths",
+ args: fileArgsBuilder().
+ JunkPaths(true).
+ ExplicitPathInZip("foo/bar").
+ File("a/a/a*").
+ File("a/a/b"),
+ compressionLevel: 9,
+
+ files: []zip.FileHeader{
+ fh("foo/bar", fileA, zip.Deflate),
+ fh("b", fileB, zip.Deflate),
+ },
+ },
// errors
{
@@ -490,6 +544,22 @@ func TestZip(t *testing.T) {
File("d/a/a"),
err: ConflictingFileError{},
},
+ {
+ name: "error explicit path conflicting",
+ args: fileArgsBuilder().
+ ExplicitPathInZip("foo").
+ File("a/a/a").
+ ExplicitPathInZip("foo").
+ File("a/a/b"),
+ err: ConflictingFileError{},
+ },
+ {
+ name: "error explicit path conflicting glob",
+ args: fileArgsBuilder().
+ ExplicitPathInZip("foo").
+ File("a/a/*"),
+ err: ConflictingFileError{},
+ },
}
for _, test := range testCases {