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(":bootclasspath.bzl", "bootclasspath") 16load(":rules.bzl", "java_import") 17load(":java_system_modules.bzl", "java_system_modules") 18 19def _bootclasspath_test_impl(ctx): 20 env = analysistest.begin(ctx) 21 bootclasspath_target = analysistest.target_under_test(env) 22 23 asserts.true( 24 env, 25 java_common.BootClassPathInfo in bootclasspath_target, 26 "Expected BootClassPathInfo in bootclasspath providers.", 27 ) 28 return analysistest.end(env) 29 30bootclasspath_test = analysistest.make( 31 _bootclasspath_test_impl, 32) 33 34def test_bootclasspath_provider(): 35 name = "test_bootclasspath_provider" 36 import_target = ":" + name + "_import" 37 system_target = ":" + name + "_jsm" 38 bootclasspath( 39 name = name + "_target", 40 bootclasspath = [import_target], 41 system = system_target, 42 auxiliary = [import_target], 43 tags = ["manual"], 44 ) 45 bootclasspath_test( 46 name = name, 47 target_under_test = name + "_target", 48 ) 49 java_system_modules( 50 name = name + "_jsm", 51 deps = [import_target], 52 tags = ["manual"], 53 ) 54 java_import( 55 name = import_target[1:], 56 jars = ["some_jar.jar"], 57 tags = ["manual"], 58 ) 59 return name 60 61def bootclasspath_test_suite(name): 62 native.test_suite( 63 name = name, 64 tests = [ 65 test_bootclasspath_provider(), 66 ], 67 ) 68