• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
14load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
15load(":java_system_modules.bzl", "SystemInfo", "java_system_modules")
16load(":rules.bzl", "java_import")
17
18def _java_system_modules_test_impl(ctx):
19    env = analysistest.begin(ctx)
20    java_system_modules_target = analysistest.target_under_test(env)
21
22    asserts.true(
23        env,
24        java_system_modules_target[SystemInfo].system.is_directory,
25        "java_system_modules output should be a directory.",
26    )
27    return analysistest.end(env)
28
29java_system_modules_test = analysistest.make(
30    _java_system_modules_test_impl,
31)
32
33def test_java_system_modules_provider():
34    name = "test_java_system_modules_provider"
35    import_target = ":" + name + "_import"
36    java_system_modules(
37        name = name + "_target",
38        deps = [import_target],
39        tags = ["manual"],
40    )
41    java_system_modules_test(
42        name = name,
43        target_under_test = name + "_target",
44    )
45
46    java_import(
47        name = import_target[1:],
48        jars = ["some_jar.jar"],
49        tags = ["manual"],
50    )
51    return name
52
53def java_system_modules_test_suite(name):
54    native.test_suite(
55        name = name,
56        tests = [
57            test_java_system_modules_provider(),
58        ],
59    )
60