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
This commit is contained in:
@@ -31,6 +31,7 @@ var testCases = []struct {
|
||||
sortJava bool
|
||||
args []string
|
||||
excludes []string
|
||||
includes []string
|
||||
uncompresses []string
|
||||
|
||||
outputFiles []string
|
||||
@@ -228,7 +229,7 @@ var testCases = []struct {
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "excludes with include",
|
||||
name: "excludes with args",
|
||||
|
||||
inputFiles: []string{
|
||||
"a/a",
|
||||
@@ -241,6 +242,31 @@ var testCases = []struct {
|
||||
"a/b",
|
||||
},
|
||||
},
|
||||
{
|
||||
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",
|
||||
|
||||
@@ -358,7 +384,7 @@ func TestZip2Zip(t *testing.T) {
|
||||
|
||||
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))
|
||||
}
|
||||
|
Reference in New Issue
Block a user