summaryrefslogtreecommitdiff
path: root/zip/zip_test.go
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2018-09-28 15:16:48 -0700
committer Colin Cross <ccross@android.com> 2018-09-28 16:14:52 -0700
commit4be8f9e2a3e857050f4d6d9b3d728492828445bf (patch)
tree02d5d87c95a304bfeb58f4f436d7fa4043f06763 /zip/zip_test.go
parent09f11056f876a9f705a53fd6f122aa7575e0b51b (diff)
soong_zip: add --ignore_missing_files flag
soong_zip builds a list of files to zip early and then starts zipping them all. If a directory being zipped is concurrently modified, a file that existed when soong_zip started may not still exist. Add a flag that continues when an expected file does not exist. Print a warning, since this should be rare in normal usages but is a sign of a problem if it happens regularly. Test: zip_test.go Test: m checkbuild Test: m platform Change-Id: I78426fe66fded8528ddd436c0f71a7442183cfeb
Diffstat (limited to 'zip/zip_test.go')
-rw-r--r--zip/zip_test.go33
1 files changed, 25 insertions, 8 deletions
diff --git a/zip/zip_test.go b/zip/zip_test.go
index a08fb126d..93c5f3dee 100644
--- a/zip/zip_test.go
+++ b/zip/zip_test.go
@@ -98,14 +98,15 @@ func fileArgsBuilder() *FileArgsBuilder {
func TestZip(t *testing.T) {
testCases := []struct {
- name string
- args *FileArgsBuilder
- compressionLevel int
- emulateJar bool
- nonDeflatedFiles map[string]bool
- dirEntries bool
- manifest string
- storeSymlinks bool
+ name string
+ args *FileArgsBuilder
+ compressionLevel int
+ emulateJar bool
+ nonDeflatedFiles map[string]bool
+ dirEntries bool
+ manifest string
+ storeSymlinks bool
+ ignoreMissingFiles bool
files []zip.FileHeader
err error
@@ -338,6 +339,20 @@ func TestZip(t *testing.T) {
fh("a/a/b", fileB, zip.Deflate),
},
},
+ {
+ name: "ignore missing files",
+ args: fileArgsBuilder().
+ File("a/a/a").
+ File("a/a/b").
+ File("missing"),
+ compressionLevel: 9,
+ ignoreMissingFiles: true,
+
+ files: []zip.FileHeader{
+ fh("a/a/a", fileA, zip.Deflate),
+ fh("a/a/b", fileB, zip.Deflate),
+ },
+ },
// errors
{
@@ -381,7 +396,9 @@ func TestZip(t *testing.T) {
args.NonDeflatedFiles = test.nonDeflatedFiles
args.ManifestSourcePath = test.manifest
args.StoreSymlinks = test.storeSymlinks
+ args.IgnoreMissingFiles = test.ignoreMissingFiles
args.Filesystem = mockFs
+ args.Stderr = &bytes.Buffer{}
buf := &bytes.Buffer{}
err := ZipTo(args, buf)