diff options
author | 2024-12-03 16:40:08 -0800 | |
---|---|---|
committer | 2025-02-10 19:55:26 -0800 | |
commit | 1cea5308a7915665d8d3480021ca2da00f5206eb (patch) | |
tree | 67c5a61b9257166cced772791550e28db4487b5e /android/apex_test.go | |
parent | 92b0eb18e199f44ddc26b32ae993d9909f1fd7fa (diff) |
Convert android.TransitionMutator to TransitionInfo
Use the ApexInfo instead of a string as the TransitionInfo for apex
variations. This removes the need for apexInfoMutator, which is the
last remaining top down mutator.
This has a variety of ramifications. One is that it is no longer
possible to add a dependency onto the apex variation of a module,
as that would require constructing a matching ApexInfo. Instead,
anything that wants to add a dependency on the apex variation has
to depend on the apex instead, and get to the module by walking
its transistive dependencies.
Another ramification is that modules in apexes can no longer
determine which apexes they are in (unless they set
UniqueApexVariations so that each variation is in exactly one
apex). This prevents some of the existing container violation
checks from working after this CL, tracked in b/394955484.
It also requires using unique variation names for the prebuilt
and source dependencies of apexes, so the apex variations
for dependencies of prebuilts now have a prebuilt_ prefix.
Bug: 372543712
Bug: 394955484
Test: go test ./...
Change-Id: I3d08aca1ac956ab0e343ec3f235a736cd93be0e1
Diffstat (limited to 'android/apex_test.go')
-rw-r--r-- | android/apex_test.go | 277 |
1 files changed, 0 insertions, 277 deletions
diff --git a/android/apex_test.go b/android/apex_test.go deleted file mode 100644 index acc195de2..000000000 --- a/android/apex_test.go +++ /dev/null @@ -1,277 +0,0 @@ -// Copyright 2020 Google Inc. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package android - -import ( - "reflect" - "testing" -) - -func Test_mergeApexVariations(t *testing.T) { - const ( - ForPrebuiltApex = true - NotForPrebuiltApex = false - ) - tests := []struct { - name string - in []ApexInfo - wantMerged []ApexInfo - wantAliases [][2]string - }{ - { - name: "single", - in: []ApexInfo{ - { - ApexVariationName: "foo", - MinSdkVersion: FutureApiLevel, - InApexVariants: []string{"foo"}, - ForPrebuiltApex: NotForPrebuiltApex, - }, - }, - wantMerged: []ApexInfo{ - { - ApexVariationName: "apex10000", - MinSdkVersion: FutureApiLevel, - InApexVariants: []string{"foo"}, - ForPrebuiltApex: NotForPrebuiltApex, - }, - }, - wantAliases: [][2]string{ - {"foo", "apex10000"}, - }, - }, - { - name: "merge", - in: []ApexInfo{ - { - ApexVariationName: "foo", - MinSdkVersion: FutureApiLevel, - InApexVariants: []string{"foo"}, - ForPrebuiltApex: NotForPrebuiltApex, - }, - { - ApexVariationName: "bar", - MinSdkVersion: FutureApiLevel, - InApexVariants: []string{"bar"}, - ForPrebuiltApex: NotForPrebuiltApex, - }, - }, - wantMerged: []ApexInfo{ - { - ApexVariationName: "apex10000", - MinSdkVersion: FutureApiLevel, - InApexVariants: []string{"foo", "bar"}, - }}, - wantAliases: [][2]string{ - {"foo", "apex10000"}, - {"bar", "apex10000"}, - }, - }, - { - name: "don't merge version", - in: []ApexInfo{ - { - ApexVariationName: "foo", - MinSdkVersion: FutureApiLevel, - InApexVariants: []string{"foo"}, - ForPrebuiltApex: NotForPrebuiltApex, - }, - { - ApexVariationName: "bar", - MinSdkVersion: uncheckedFinalApiLevel(30), - InApexVariants: []string{"bar"}, - ForPrebuiltApex: NotForPrebuiltApex, - }, - }, - wantMerged: []ApexInfo{ - { - ApexVariationName: "apex10000", - MinSdkVersion: FutureApiLevel, - InApexVariants: []string{"foo"}, - ForPrebuiltApex: NotForPrebuiltApex, - }, - { - ApexVariationName: "apex30", - MinSdkVersion: uncheckedFinalApiLevel(30), - InApexVariants: []string{"bar"}, - ForPrebuiltApex: NotForPrebuiltApex, - }, - }, - wantAliases: [][2]string{ - {"foo", "apex10000"}, - {"bar", "apex30"}, - }, - }, - { - name: "merge updatable", - in: []ApexInfo{ - { - ApexVariationName: "foo", - MinSdkVersion: FutureApiLevel, - InApexVariants: []string{"foo"}, - ForPrebuiltApex: NotForPrebuiltApex, - }, - { - ApexVariationName: "bar", - MinSdkVersion: FutureApiLevel, - Updatable: true, - InApexVariants: []string{"bar"}, - ForPrebuiltApex: NotForPrebuiltApex, - }, - }, - wantMerged: []ApexInfo{ - { - ApexVariationName: "apex10000", - MinSdkVersion: FutureApiLevel, - Updatable: true, - InApexVariants: []string{"foo", "bar"}, - ForPrebuiltApex: NotForPrebuiltApex, - }, - }, - wantAliases: [][2]string{ - {"foo", "apex10000"}, - {"bar", "apex10000"}, - }, - }, - { - name: "don't merge when for prebuilt_apex", - in: []ApexInfo{ - { - ApexVariationName: "foo", - MinSdkVersion: FutureApiLevel, - InApexVariants: []string{"foo"}, - ForPrebuiltApex: NotForPrebuiltApex, - }, - { - ApexVariationName: "bar", - MinSdkVersion: FutureApiLevel, - Updatable: true, - InApexVariants: []string{"bar"}, - ForPrebuiltApex: NotForPrebuiltApex, - }, - // This one should not be merged in with the others because it is for - // a prebuilt_apex. - { - ApexVariationName: "baz", - MinSdkVersion: FutureApiLevel, - Updatable: true, - InApexVariants: []string{"baz"}, - ForPrebuiltApex: ForPrebuiltApex, - }, - }, - wantMerged: []ApexInfo{ - { - ApexVariationName: "apex10000", - MinSdkVersion: FutureApiLevel, - Updatable: true, - InApexVariants: []string{"foo", "bar"}, - ForPrebuiltApex: NotForPrebuiltApex, - }, - { - ApexVariationName: "baz", - MinSdkVersion: FutureApiLevel, - Updatable: true, - InApexVariants: []string{"baz"}, - ForPrebuiltApex: ForPrebuiltApex, - }, - }, - wantAliases: [][2]string{ - {"foo", "apex10000"}, - {"bar", "apex10000"}, - }, - }, - { - name: "don't merge different UsePlatformApis", - in: []ApexInfo{ - { - ApexVariationName: "foo", - MinSdkVersion: FutureApiLevel, - InApexVariants: []string{"foo"}, - ForPrebuiltApex: NotForPrebuiltApex, - }, - { - ApexVariationName: "bar", - MinSdkVersion: FutureApiLevel, - UsePlatformApis: true, - InApexVariants: []string{"bar"}, - ForPrebuiltApex: NotForPrebuiltApex, - }, - }, - wantMerged: []ApexInfo{ - { - ApexVariationName: "apex10000", - MinSdkVersion: FutureApiLevel, - InApexVariants: []string{"foo"}, - ForPrebuiltApex: NotForPrebuiltApex, - }, - { - ApexVariationName: "apex10000_p", - MinSdkVersion: FutureApiLevel, - UsePlatformApis: true, - InApexVariants: []string{"bar"}, - ForPrebuiltApex: NotForPrebuiltApex, - }, - }, - wantAliases: [][2]string{ - {"foo", "apex10000"}, - {"bar", "apex10000_p"}, - }, - }, - { - name: "merge same UsePlatformApis and allow using platform api", - in: []ApexInfo{ - { - ApexVariationName: "foo", - MinSdkVersion: FutureApiLevel, - UsePlatformApis: true, - InApexVariants: []string{"foo"}, - ForPrebuiltApex: NotForPrebuiltApex, - }, - { - ApexVariationName: "bar", - MinSdkVersion: FutureApiLevel, - UsePlatformApis: true, - InApexVariants: []string{"bar"}, - ForPrebuiltApex: NotForPrebuiltApex, - }, - }, - wantMerged: []ApexInfo{ - { - ApexVariationName: "apex10000_p", - MinSdkVersion: FutureApiLevel, - UsePlatformApis: true, - InApexVariants: []string{"foo", "bar"}, - ForPrebuiltApex: NotForPrebuiltApex, - }, - }, - wantAliases: [][2]string{ - {"foo", "apex10000_p"}, - {"bar", "apex10000_p"}, - }, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - gotMerged, gotAliases := mergeApexVariations(tt.in) - if !reflect.DeepEqual(gotMerged, tt.wantMerged) { - t.Errorf("mergeApexVariations() gotMerged = %v, want %v", gotMerged, tt.wantMerged) - } - if !reflect.DeepEqual(gotAliases, tt.wantAliases) { - t.Errorf("mergeApexVariations() gotAliases = %v, want %v", gotAliases, tt.wantAliases) - } - }) - } -} |