zip2zip: support included an excluded file
Make needs to exclude all files that match a filespec except for
those specified in a list. Add a -X argument that overrides the
-x argument to allow files be included that were previously
excluded.
Bug: 69500920
Test: zip2zip_test.go
Change-Id: Icc8aebc788b53bcdde73a39c9c7cf3107a049251
diff --git a/cmd/zip2zip/zip2zip_test.go b/cmd/zip2zip/zip2zip_test.go
index e032fe6..ae16494 100644
--- a/cmd/zip2zip/zip2zip_test.go
+++ b/cmd/zip2zip/zip2zip_test.go
@@ -31,6 +31,7 @@
sortJava bool
args []string
excludes []string
+ includes []string
uncompresses []string
outputFiles []string
@@ -228,7 +229,7 @@
},
},
{
- name: "excludes with include",
+ name: "excludes with args",
inputFiles: []string{
"a/a",
@@ -242,6 +243,31 @@
},
},
{
+ name: "excludes over args",
+
+ inputFiles: []string{
+ "a/a",
+ "a/b",
+ },
+ args: []string{"a/a"},
+ excludes: []string{"a/*"},
+
+ outputFiles: nil,
+ },
+ {
+ name: "excludes with includes",
+
+ inputFiles: []string{
+ "a/a",
+ "a/b",
+ },
+ args: nil,
+ excludes: []string{"a/*"},
+ includes: []string{"a/b"},
+
+ outputFiles: []string{"a/b"},
+ },
+ {
name: "excludes with glob",
inputFiles: []string{
@@ -358,7 +384,7 @@
outputWriter := zip.NewWriter(outputBuf)
err = zip2zip(inputReader, outputWriter, testCase.sortGlobs, testCase.sortJava, false,
- testCase.args, testCase.excludes, testCase.uncompresses)
+ testCase.args, testCase.excludes, testCase.includes, testCase.uncompresses)
if errorString(testCase.err) != errorString(err) {
t.Fatalf("Unexpected error:\n got: %q\nwant: %q", errorString(err), errorString(testCase.err))
}