blob: f4a1016bc069a6e269bc2b29eba503cf3d6e569d [file] [log] [blame]
Rupert Shuttlewortha9d76dd2021-07-02 07:17:16 -04001// 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
15package bp2build
16
17import (
18 "android/soong/android"
19 "android/soong/apex"
20 "testing"
21)
22
23func runApexTestCase(t *testing.T, tc bp2buildTestCase) {
24 t.Helper()
25 runBp2BuildTestCase(t, registerApexModuleTypes, tc)
26}
27
28func registerApexModuleTypes(ctx android.RegistrationContext) {
29}
30
31func 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: `
39apex {
40 name: "apogee",
41 manifest: "manifest.json",
42}
43`,
44 expectedBazelTargets: []string{`apex(
45 name = "apogee",
46 manifest = "manifest.json",
47)`}})
48}
Jingwen Chenf59a8e12021-07-16 09:28:53 +000049
50func 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: `
58apex {
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}