xref: /aosp_15_r20/build/bazel/tests/apex/apex_aab_test.bzl (revision 7594170e27e0732bc44b93d1440d87a54b6ffe7c)
1# Copyright (C) 2022 The Android Open Source Project
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
15load("//build/bazel/rules/apex:apex_aab.bzl", "apex_aab")
16
17def apex_aab_test(name, apex, golden):
18    """Diff the .aab generated by Bazel and Soong"""
19
20    aab_name = name + "_apex_aab"
21    apex_aab(
22        name = aab_name,
23        mainline_module = apex,
24    )
25
26    native.sh_library(
27        name = name + "_wrapper_sh_lib",
28        data = [
29            ":" + aab_name,
30            golden,
31        ],
32    )
33
34    args = [
35        "$(location //build/bazel/tests/apex:" + aab_name + ")",
36        "$(location %s)" % golden,
37    ]
38
39    native.sh_test(
40        name = name,
41        srcs = ["apex_aab_test.sh"],
42        deps = ["@bazel_tools//tools/bash/runfiles"],
43        data = [
44            ":" + name + "_wrapper_sh_lib",
45            "@bazel_tools//tools/zip:zipper",
46            ":" + aab_name,
47            golden,
48        ],
49        args = args,
50        target_compatible_with = ["//build/bazel_common_rules/platforms/os:android"],
51    )
52