1# Copyright 2022 Google LLC. All rights reserved. 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 15"""An assertion on kt_compiler_plugin analysis.""" 16 17load("//kotlin:compiler_plugin.bzl", "KtCompilerPluginInfo") 18load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") 19load("//:visibility.bzl", "RULES_KOTLIN") 20 21def _test_impl(ctx): 22 env = analysistest.begin(ctx) 23 info = ctx.attr.target_under_test[KtCompilerPluginInfo] 24 25 asserts.equals(env, info.plugin_id, ctx.attr.expected_id) 26 asserts.equals(env, info.jar, ctx.file.expected_jar) 27 asserts.equals(env, info.args, ctx.attr.expected_args) 28 29 return analysistest.end(env) 30 31assert_compiler_plugin_test = analysistest.make( 32 impl = _test_impl, 33 attrs = dict( 34 expected_id = attr.string(), 35 expected_jar = attr.label(allow_single_file = True, cfg = "exec"), 36 expected_args = attr.string_list(), 37 ), 38) 39