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(":import.bzl", "java_import") 16load(":java_system_modules.bzl", "SystemInfo", "java_system_modules") 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 asserts.true( 28 env, 29 len(java_system_modules_target[SystemInfo].java_info.compile_jars.to_list()) > 0, 30 "java_system_modules should contain compile jars.", 31 ) 32 return analysistest.end(env) 33 34java_system_modules_test = analysistest.make( 35 _java_system_modules_test_impl, 36) 37 38def test_java_system_modules_provider(): 39 name = "test_java_system_modules_provider" 40 import_name = name + "_import" 41 import_target = ":" + import_name 42 java_system_modules( 43 name = name + "_target", 44 deps = [import_target], 45 tags = ["manual"], 46 ) 47 java_system_modules_test( 48 name = name, 49 target_under_test = name + "_target", 50 ) 51 52 java_import( 53 name = import_name, 54 jars = ["some_jar.jar"], 55 tags = ["manual"], 56 ) 57 return name 58 59def java_system_modules_test_suite(name): 60 native.test_suite( 61 name = name, 62 tests = [ 63 test_java_system_modules_provider(), 64 ], 65 ) 66