1*7594170eSAndroid Build Coastguard Worker# Copyright (C) 2022 The Android Open Source Project 2*7594170eSAndroid Build Coastguard Worker# 3*7594170eSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License"); 4*7594170eSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License. 5*7594170eSAndroid Build Coastguard Worker# You may obtain a copy of the License at 6*7594170eSAndroid Build Coastguard Worker# 7*7594170eSAndroid Build Coastguard Worker# http://www.apache.org/licenses/LICENSE-2.0 8*7594170eSAndroid Build Coastguard Worker# 9*7594170eSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software 10*7594170eSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS, 11*7594170eSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*7594170eSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and 13*7594170eSAndroid Build Coastguard Worker# limitations under the License. 14*7594170eSAndroid Build Coastguard Worker 15*7594170eSAndroid Build Coastguard Workerload("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") 16*7594170eSAndroid Build Coastguard Workerload(":sysprop_library.bzl", "SyspropGenInfo", "sysprop_library") 17*7594170eSAndroid Build Coastguard Worker 18*7594170eSAndroid Build Coastguard Workerdef _provides_src_files_test_impl(ctx): 19*7594170eSAndroid Build Coastguard Worker env = analysistest.begin(ctx) 20*7594170eSAndroid Build Coastguard Worker 21*7594170eSAndroid Build Coastguard Worker target_under_test = analysistest.target_under_test(env) 22*7594170eSAndroid Build Coastguard Worker asserts.equals( 23*7594170eSAndroid Build Coastguard Worker env, 24*7594170eSAndroid Build Coastguard Worker ["foo.sysprop", "bar.sysprop"], 25*7594170eSAndroid Build Coastguard Worker [src.label.name for src in target_under_test[SyspropGenInfo].srcs], 26*7594170eSAndroid Build Coastguard Worker ) 27*7594170eSAndroid Build Coastguard Worker 28*7594170eSAndroid Build Coastguard Worker return analysistest.end(env) 29*7594170eSAndroid Build Coastguard Worker 30*7594170eSAndroid Build Coastguard Workerprovides_src_files_test = analysistest.make( 31*7594170eSAndroid Build Coastguard Worker _provides_src_files_test_impl, 32*7594170eSAndroid Build Coastguard Worker) 33*7594170eSAndroid Build Coastguard Worker 34*7594170eSAndroid Build Coastguard Workerdef _test_provides_src_files(): 35*7594170eSAndroid Build Coastguard Worker name = "provides_src_files" 36*7594170eSAndroid Build Coastguard Worker test_name = name + "_test" 37*7594170eSAndroid Build Coastguard Worker sysprop_library( 38*7594170eSAndroid Build Coastguard Worker name = name, 39*7594170eSAndroid Build Coastguard Worker srcs = ["foo.sysprop", "bar.sysprop"], 40*7594170eSAndroid Build Coastguard Worker tags = ["manual"], 41*7594170eSAndroid Build Coastguard Worker ) 42*7594170eSAndroid Build Coastguard Worker provides_src_files_test( 43*7594170eSAndroid Build Coastguard Worker name = test_name, 44*7594170eSAndroid Build Coastguard Worker target_under_test = name, 45*7594170eSAndroid Build Coastguard Worker ) 46*7594170eSAndroid Build Coastguard Worker return test_name 47*7594170eSAndroid Build Coastguard Worker 48*7594170eSAndroid Build Coastguard Workerdef sysprop_library_test_suite(name): 49*7594170eSAndroid Build Coastguard Worker native.test_suite( 50*7594170eSAndroid Build Coastguard Worker name = name, 51*7594170eSAndroid Build Coastguard Worker tests = [ 52*7594170eSAndroid Build Coastguard Worker _test_provides_src_files(), 53*7594170eSAndroid Build Coastguard Worker ], 54*7594170eSAndroid Build Coastguard Worker ) 55