Rupert Shuttleworth | a9d76dd | 2021-07-02 07:17:16 -0400 | [diff] [blame] | 1 | // Copyright 2021 Google Inc. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package bp2build |
| 16 | |
| 17 | import ( |
| 18 | "android/soong/android" |
| 19 | "android/soong/apex" |
| 20 | "testing" |
| 21 | ) |
| 22 | |
| 23 | func runApexTestCase(t *testing.T, tc bp2buildTestCase) { |
| 24 | t.Helper() |
| 25 | runBp2BuildTestCase(t, registerApexModuleTypes, tc) |
| 26 | } |
| 27 | |
| 28 | func registerApexModuleTypes(ctx android.RegistrationContext) { |
| 29 | } |
| 30 | |
| 31 | func TestApexBundleSimple(t *testing.T) { |
| 32 | runApexTestCase(t, bp2buildTestCase{ |
| 33 | description: "apex - simple example", |
| 34 | moduleTypeUnderTest: "apex", |
| 35 | moduleTypeUnderTestFactory: apex.BundleFactory, |
| 36 | moduleTypeUnderTestBp2BuildMutator: apex.ApexBundleBp2Build, |
| 37 | filesystem: map[string]string{}, |
| 38 | blueprint: ` |
| 39 | apex { |
| 40 | name: "apogee", |
| 41 | manifest: "manifest.json", |
| 42 | } |
| 43 | `, |
| 44 | expectedBazelTargets: []string{`apex( |
| 45 | name = "apogee", |
| 46 | manifest = "manifest.json", |
| 47 | )`}}) |
| 48 | } |
Jingwen Chen | f59a8e1 | 2021-07-16 09:28:53 +0000 | [diff] [blame^] | 49 | |
| 50 | func TestApexBundleHasBazelModuleProps(t *testing.T) { |
| 51 | runApexTestCase(t, bp2buildTestCase{ |
| 52 | description: "apex - has bazel module props", |
| 53 | moduleTypeUnderTest: "apex", |
| 54 | moduleTypeUnderTestFactory: apex.BundleFactory, |
| 55 | moduleTypeUnderTestBp2BuildMutator: apex.ApexBundleBp2Build, |
| 56 | filesystem: map[string]string{}, |
| 57 | blueprint: ` |
| 58 | apex { |
| 59 | name: "apogee", |
| 60 | manifest: "manifest.json", |
| 61 | bazel_module: { bp2build_available: true }, |
| 62 | } |
| 63 | `, |
| 64 | expectedBazelTargets: []string{`apex( |
| 65 | name = "apogee", |
| 66 | manifest = "manifest.json", |
| 67 | )`}}) |
| 68 | } |