diff options
author | 2022-08-15 15:47:41 -0700 | |
---|---|---|
committer | 2022-08-15 16:05:03 -0700 | |
commit | 7ddd08ad2b6e757efc619945078deb931bf311c9 (patch) | |
tree | ce945b9dbdb244d4c7f8c30dfd1dc3e8a8b092a5 /zip/zip_test.go | |
parent | b262f883a986237684ee4725e3ad14f83c395b91 (diff) |
Allow duplicate files inputs in soong_zip
Accept duplicate file inputs in soong_zip when they are the same
source file. This came up when trying to zip lint srcs, as some
java modules have duplicate source files that seem to be ignored
by javac.
Test: TestZip
Bug: 216456886
Change-Id: I8c43df9aded8cf094afaed79cca2b9eb091cc861
Diffstat (limited to 'zip/zip_test.go')
-rw-r--r-- | zip/zip_test.go | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/zip/zip_test.go b/zip/zip_test.go index 79cc0b4b7..c4832dc9a 100644 --- a/zip/zip_test.go +++ b/zip/zip_test.go @@ -46,6 +46,7 @@ var mockFs = pathtools.MockFs(map[string][]byte{ "dangling -> missing": nil, "a/a/d -> b": nil, "c": fileC, + "d/a/a": nil, "l_nl": []byte("a/a/a\na/a/b\nc\n\\[\n"), "l_sp": []byte("a/a/a a/a/b c \\["), "l2": []byte("missing\n"), @@ -400,6 +401,17 @@ func TestZip(t *testing.T) { fh("a/a/b", fileB, zip.Deflate), }, }, + { + name: "duplicate sources", + args: fileArgsBuilder(). + File("a/a/a"). + File("a/a/a"), + compressionLevel: 9, + + files: []zip.FileHeader{ + fh("a/a/a", fileA, zip.Deflate), + }, + }, // errors { @@ -427,6 +439,15 @@ func TestZip(t *testing.T) { File("a/a/a"), err: IncorrectRelativeRootError{}, }, + { + name: "error conflicting file", + args: fileArgsBuilder(). + SourcePrefixToStrip("a"). + File("a/a/a"). + SourcePrefixToStrip("d"). + File("d/a/a"), + err: ConflictingFileError{}, + }, } for _, test := range testCases { @@ -454,13 +475,17 @@ func TestZip(t *testing.T) { t.Fatalf("want error %v, got %v", test.err, err) } else if test.err != nil { if os.IsNotExist(test.err) { - if !os.IsNotExist(test.err) { + if !os.IsNotExist(err) { t.Fatalf("want error %v, got %v", test.err, err) } } else if _, wantRelativeRootErr := test.err.(IncorrectRelativeRootError); wantRelativeRootErr { if _, gotRelativeRootErr := err.(IncorrectRelativeRootError); !gotRelativeRootErr { t.Fatalf("want error %v, got %v", test.err, err) } + } else if _, wantConflictingFileError := test.err.(ConflictingFileError); wantConflictingFileError { + if _, gotConflictingFileError := err.(ConflictingFileError); !gotConflictingFileError { + t.Fatalf("want error %v, got %v", test.err, err) + } } else { t.Fatalf("want error %v, got %v", test.err, err) } |