Loading cmd/find_input_delta/find_input_delta_lib/internal_state.go +6 −5 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ import ( "errors" "fmt" "io/fs" "path/filepath" "regexp" "slices" fid_proto "android/soong/cmd/find_input_delta/find_input_delta_proto_internal" Loading Loading @@ -73,15 +73,16 @@ func CreateState(inputs []string, inspect_contents bool, fsys StatReadFileFS) (* return ret, nil } // We ignore any suffix digit caused by sharding. var InspectExtsZipRegexp = regexp.MustCompile("\\.(jar|apex|apk)[0-9]*$") // Inspect the file and extract the state of the elements in the archive. // If this is not an archive of some sort, nil is returned. func InspectFileContents(name string) ([]*fid_proto.PartialCompileInput, error) { switch filepath.Ext(name) { case ".jar", ".apex", ".apk": if InspectExtsZipRegexp.Match([]byte(name)) { return inspectZipFileContents(name) default: return nil, nil } return nil, nil } func inspectZipFileContents(name string) ([]*fid_proto.PartialCompileInput, error) { Loading cmd/find_input_delta/find_input_delta_lib/internal_state_test.go +22 −0 Original line number Diff line number Diff line Loading @@ -259,3 +259,25 @@ func TestCompareInternalState(t *testing.T) { } } } func TestCompareInspectExtsZipRegexp(t *testing.T) { testCases := []struct { Name string Expected bool }{ {Name: ".jar", Expected: true}, {Name: ".jar5", Expected: true}, {Name: ".apex", Expected: true}, {Name: ".apex9", Expected: true}, {Name: ".apexx", Expected: false}, {Name: ".apk", Expected: true}, {Name: ".apk3", Expected: true}, {Name: ".go", Expected: false}, } for _, tc := range testCases { actual := InspectExtsZipRegexp.Match([]byte(tc.Name)) if tc.Expected != actual { t.Errorf("%s: expected %v, actual %v", tc.Name, tc.Expected, actual) } } } Loading
cmd/find_input_delta/find_input_delta_lib/internal_state.go +6 −5 Original line number Diff line number Diff line Loading @@ -18,7 +18,7 @@ import ( "errors" "fmt" "io/fs" "path/filepath" "regexp" "slices" fid_proto "android/soong/cmd/find_input_delta/find_input_delta_proto_internal" Loading Loading @@ -73,15 +73,16 @@ func CreateState(inputs []string, inspect_contents bool, fsys StatReadFileFS) (* return ret, nil } // We ignore any suffix digit caused by sharding. var InspectExtsZipRegexp = regexp.MustCompile("\\.(jar|apex|apk)[0-9]*$") // Inspect the file and extract the state of the elements in the archive. // If this is not an archive of some sort, nil is returned. func InspectFileContents(name string) ([]*fid_proto.PartialCompileInput, error) { switch filepath.Ext(name) { case ".jar", ".apex", ".apk": if InspectExtsZipRegexp.Match([]byte(name)) { return inspectZipFileContents(name) default: return nil, nil } return nil, nil } func inspectZipFileContents(name string) ([]*fid_proto.PartialCompileInput, error) { Loading
cmd/find_input_delta/find_input_delta_lib/internal_state_test.go +22 −0 Original line number Diff line number Diff line Loading @@ -259,3 +259,25 @@ func TestCompareInternalState(t *testing.T) { } } } func TestCompareInspectExtsZipRegexp(t *testing.T) { testCases := []struct { Name string Expected bool }{ {Name: ".jar", Expected: true}, {Name: ".jar5", Expected: true}, {Name: ".apex", Expected: true}, {Name: ".apex9", Expected: true}, {Name: ".apexx", Expected: false}, {Name: ".apk", Expected: true}, {Name: ".apk3", Expected: true}, {Name: ".go", Expected: false}, } for _, tc := range testCases { actual := InspectExtsZipRegexp.Match([]byte(tc.Name)) if tc.Expected != actual { t.Errorf("%s: expected %v, actual %v", tc.Name, tc.Expected, actual) } } }