diff options
Diffstat (limited to 'tests/analysis')
56 files changed, 0 insertions, 3042 deletions
diff --git a/tests/analysis/BUILD b/tests/analysis/BUILD deleted file mode 100644 index 0533e13..0000000 --- a/tests/analysis/BUILD +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -# Analysis Tests - -load("//tests/analysis:jvm_compile_test.bzl", jvm_compile_test_suite = "test_suite") -load("//tests/analysis:jvm_import_test.bzl", jvm_import_test_suite = "test_suite") -load("//tests/analysis:jvm_library_test.bzl", jvm_library_test_suite = "test_suite") -load("@bazel_skylib//:bzl_library.bzl", "bzl_library") - -licenses(["notice"]) - -jvm_compile_test_suite(name = "jvm_compile_tests") - -jvm_library_test_suite(name = "jvm_library_tests") - -jvm_import_test_suite(name = "jvm_import_tests") diff --git a/tests/analysis/assert_failure_test.bzl b/tests/analysis/assert_failure_test.bzl deleted file mode 100644 index 2a742c3..0000000 --- a/tests/analysis/assert_failure_test.bzl +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""An assertion for analysis failure.""" - -load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") -load("//:visibility.bzl", "RULES_KOTLIN") - -def _assert_failure_test_impl(ctx): - env = analysistest.begin(ctx) - asserts.expect_failure(env, ctx.attr.msg_contains) - return analysistest.end(env) - -assert_failure_test = analysistest.make( - _assert_failure_test_impl, - expect_failure = True, - attrs = dict( - msg_contains = attr.string(mandatory = True), - ), -) diff --git a/tests/analysis/compiler_plugin/BUILD b/tests/analysis/compiler_plugin/BUILD deleted file mode 100644 index 0c1f9b6..0000000 --- a/tests/analysis/compiler_plugin/BUILD +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -licenses(["notice"]) - -genrule( - name = "empty_jar", - outs = ["empty.jar"], - cmd = """$(location @bazel_tools//tools/zip:zipper) c $@ "assets/_empty=" """, - tools = ["@bazel_tools//tools/zip:zipper"], - visibility = ["//tests/analysis/compiler_plugin:__subpackages__"], -) diff --git a/tests/analysis/compiler_plugin/forbidden_target/BUILD b/tests/analysis/compiler_plugin/forbidden_target/BUILD deleted file mode 100644 index 9f751fa..0000000 --- a/tests/analysis/compiler_plugin/forbidden_target/BUILD +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("//kotlin:compiler_plugin.bzl", "kt_compiler_plugin") -load("//tests/analysis:assert_failure_test.bzl", "assert_failure_test") -load("//tests/analysis:util.bzl", "ONLY_FOR_ANALYSIS_TEST_TAGS") - -licenses(["notice"]) diff --git a/tests/analysis/compiler_plugin/propagation/BUILD b/tests/analysis/compiler_plugin/propagation/BUILD deleted file mode 100644 index 0c6fe19..0000000 --- a/tests/analysis/compiler_plugin/propagation/BUILD +++ /dev/null @@ -1,79 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("//kotlin:compiler_plugin.bzl", "kt_compiler_plugin") -load(":assert_propagation_test.bzl", "assert_propagation_test") - -licenses(["notice"]) - -assert_propagation_test( - name = "f", - expected_plugin_ids = ["1"], - deps = [":e"], -) - -assert_propagation_test( - name = "e", - expected_plugin_ids = [], - exports = [":a"], -) - -assert_propagation_test( - name = "d", - expected_plugin_ids = [ - "1", - "2", - ], - deps = [ - ":a", - ":b", - ], -) - -assert_propagation_test( - name = "c", - expected_plugin_ids = ["2"], - deps = [":b"], -) - -assert_propagation_test( - name = "b", - expected_plugin_ids = ["1"], - exported_plugins = [":2"], - deps = [":a"], -) - -assert_propagation_test( - name = "a", - expected_plugin_ids = [], - exported_plugins = [":1"], -) - -kt_compiler_plugin( - name = "1", - jar = "//tests/analysis/compiler_plugin:empty_jar", - plugin_id = "1", -) - -kt_compiler_plugin( - name = "2", - jar = "//tests/analysis/compiler_plugin:empty_jar", - plugin_id = "2", -) - -kt_compiler_plugin( - name = "3", - jar = "//tests/analysis/compiler_plugin:empty_jar", - plugin_id = "3", -) diff --git a/tests/analysis/compiler_plugin/propagation/assert_propagation_test.bzl b/tests/analysis/compiler_plugin/propagation/assert_propagation_test.bzl deleted file mode 100644 index 0c1b02a..0000000 --- a/tests/analysis/compiler_plugin/propagation/assert_propagation_test.bzl +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Rule for asserting plugin propagation.""" - -load("@bazel_skylib//lib:sets.bzl", "sets") -load("@bazel_skylib//rules:build_test.bzl", "build_test") -load("//kotlin:traverse_exports.bzl", "kt_traverse_exports") -load("//:visibility.bzl", "RULES_KOTLIN") - -def _assert_propagation_impl(ctx): - expected_ids = sets.make(ctx.attr.expected_plugin_ids) - actual_ids = sets.make([ - p.plugin_id - for p in kt_traverse_exports.expand_compiler_plugins(ctx.attr.deps).to_list() - ]) - - if not sets.is_equal(expected_ids, actual_ids): - fail("Expected IDs %s, actual IDs %s" % (sets.to_list(expected_ids), sets.to_list(actual_ids))) - - return [ - # Needed for kt_traverse_exports.aspect - JavaInfo( - compile_jar = ctx.file._empty_jar, - output_jar = ctx.file._empty_jar, - ), - ] - -_assert_propagation = rule( - implementation = _assert_propagation_impl, - attrs = dict( - exports = attr.label_list(), - exported_plugins = attr.label_list(), - expected_plugin_ids = attr.string_list(), - deps = attr.label_list(aspects = [kt_traverse_exports.aspect]), - _empty_jar = attr.label( - allow_single_file = True, - default = "//tests/analysis/compiler_plugin:empty_jar", - ), - ), -) - -def assert_propagation_test(name, **kwargs): - _assert_propagation(name = name, **kwargs) - - build_test(name = name + "_build", targets = [name]) diff --git a/tests/analysis/compiler_plugin/provider_ctor/BUILD b/tests/analysis/compiler_plugin/provider_ctor/BUILD deleted file mode 100644 index fb5acbc..0000000 --- a/tests/analysis/compiler_plugin/provider_ctor/BUILD +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("//tests/analysis:assert_failure_test.bzl", "assert_failure_test") -load("//tests/analysis:util.bzl", "ONLY_FOR_ANALYSIS_TEST_TAGS") -load(":fake_compiler_plugin.bzl", "kt_fake_compiler_plugin") - -licenses(["notice"]) diff --git a/tests/analysis/compiler_plugin/provider_ctor/fake_compiler_plugin.bzl b/tests/analysis/compiler_plugin/provider_ctor/fake_compiler_plugin.bzl deleted file mode 100644 index 194025d..0000000 --- a/tests/analysis/compiler_plugin/provider_ctor/fake_compiler_plugin.bzl +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""A fake impl of kt_compiler_plugin.""" - -load("//kotlin:compiler_plugin.bzl", "KtCompilerPluginInfo") -load("//:visibility.bzl", "RULES_KOTLIN") - -def _kt_fake_compiler_plugin_impl(ctx): - return [ - KtCompilerPluginInfo( - plugin_id = "fake", - jar = ctx.file._jar, - args = [], - ), - ] - -kt_fake_compiler_plugin = rule( - implementation = _kt_fake_compiler_plugin_impl, - attrs = dict( - _jar = attr.label( - allow_single_file = True, - default = "//tests/analysis/compiler_plugin:empty_jar", - ), - ), - provides = [KtCompilerPluginInfo], -) diff --git a/tests/analysis/compiler_plugin/provider_output/BUILD b/tests/analysis/compiler_plugin/provider_output/BUILD deleted file mode 100644 index 4769965..0000000 --- a/tests/analysis/compiler_plugin/provider_output/BUILD +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("//kotlin:compiler_plugin.bzl", "kt_compiler_plugin") -load("//tests/analysis:util.bzl", "create_file") -load("@bazel_skylib//rules:build_test.bzl", "build_test") -load(":assert_compiler_plugin_test.bzl", "assert_compiler_plugin_test") - -licenses(["notice"]) - -assert_compiler_plugin_test( - name = "example_plugin_test", - expected_args = [ - "plugin:com.google.example:key=value", - ], - expected_id = "com.google.example", - expected_jar = "//tests/analysis/compiler_plugin:empty_jar", - target_under_test = ":example_plugin", -) - -build_test( - name = "example_plugin_in_java_library_build_test", - targets = [ - ":example_plugin_in_java_library", - ], -) - -java_library( - name = "example_plugin_in_java_library", - srcs = [create_file( - name = "Tmp.java", - content = """ - @SuppressWarnings("DefaultPackage") - class Tmp { } - """, - )], - plugins = [":example_plugin"], -) - -kt_compiler_plugin( - name = "example_plugin", - args = { - "key": "value", - }, - jar = "//tests/analysis/compiler_plugin:empty_jar", - plugin_id = "com.google.example", -) diff --git a/tests/analysis/compiler_plugin/provider_output/assert_compiler_plugin_test.bzl b/tests/analysis/compiler_plugin/provider_output/assert_compiler_plugin_test.bzl deleted file mode 100644 index f4e1849..0000000 --- a/tests/analysis/compiler_plugin/provider_output/assert_compiler_plugin_test.bzl +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""An assertion on kt_compiler_plugin analysis.""" - -load("//kotlin:compiler_plugin.bzl", "KtCompilerPluginInfo") -load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") -load("//:visibility.bzl", "RULES_KOTLIN") - -def _test_impl(ctx): - env = analysistest.begin(ctx) - info = ctx.attr.target_under_test[KtCompilerPluginInfo] - - asserts.equals(env, info.plugin_id, ctx.attr.expected_id) - asserts.equals(env, info.jar, ctx.file.expected_jar) - asserts.equals(env, info.args, ctx.attr.expected_args) - - return analysistest.end(env) - -assert_compiler_plugin_test = analysistest.make( - impl = _test_impl, - attrs = dict( - expected_id = attr.string(), - expected_jar = attr.label(allow_single_file = True, cfg = "exec"), - expected_args = attr.string_list(), - ), -) diff --git a/tests/analysis/for_test.bzl b/tests/analysis/for_test.bzl deleted file mode 100644 index 2a75726..0000000 --- a/tests/analysis/for_test.bzl +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Rules for test.""" - -load("//kotlin:jvm_library.bzl", "kt_jvm_library") -load("//tests/analysis:util.bzl", "ONLY_FOR_ANALYSIS_TEST_TAGS") -load("//:visibility.bzl", "RULES_KOTLIN") - -def _kt_jvm_library_for_test(name, **kwargs): - kt_jvm_library( - name = name, - tags = ONLY_FOR_ANALYSIS_TEST_TAGS, - **kwargs - ) - return name - -def _java_library_for_test(name, **kwargs): - native.java_library( - name = name, - tags = ONLY_FOR_ANALYSIS_TEST_TAGS, - **kwargs - ) - return name - -rules_for_test = struct( - kt_jvm_library = _kt_jvm_library_for_test, - java_library = _java_library_for_test, -) diff --git a/tests/analysis/internal_do_not_use/util/file_factory/BUILD b/tests/analysis/internal_do_not_use/util/file_factory/BUILD deleted file mode 100644 index d92e379..0000000 --- a/tests/analysis/internal_do_not_use/util/file_factory/BUILD +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load(":happy_test.bzl", "file_factory_happy_test") -load(":check_base_file_valid.bzl", "check_base_file_valid") -load("//tests/analysis:assert_failure_test.bzl", "assert_failure_test") - -licenses(["notice"]) - -file_factory_happy_test( - name = "happy_test", -) - -assert_failure_test( - name = "base_without_extension_test", - msg_contains = "file must have an extension", - target_under_test = check_base_file_valid( - name = "base_without_extension", - base_file = "BUILD", - ), -) - -assert_failure_test( - name = "base_from_other_package_test", - msg_contains = "file must be from ctx package", - target_under_test = check_base_file_valid( - name = "base_from_other_package", - base_file = "//tests/analysis/internal_do_not_use/util/file_factory/sub", - ), -) diff --git a/tests/analysis/internal_do_not_use/util/file_factory/check_base_file_valid.bzl b/tests/analysis/internal_do_not_use/util/file_factory/check_base_file_valid.bzl deleted file mode 100644 index 9ca1f05..0000000 --- a/tests/analysis/internal_do_not_use/util/file_factory/check_base_file_valid.bzl +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Happy tests for FileFactory.""" - -load("//kotlin/jvm/internal_do_not_use/util:file_factory.bzl", "FileFactory") -load("//tests/analysis:util.bzl", "ONLY_FOR_ANALYSIS_TEST_TAGS") -load("//:visibility.bzl", "RULES_KOTLIN") - -def _check_base_file_valid_impl(ctx): - FileFactory(ctx, ctx.file.base_file) - return [] - -_check_base_file_valid = rule( - implementation = _check_base_file_valid_impl, - attrs = dict( - base_file = attr.label(allow_single_file = True, mandatory = True), - ), -) - -def check_base_file_valid(name, tags = [], **kwargs): - _check_base_file_valid( - name = name, - tags = tags + ONLY_FOR_ANALYSIS_TEST_TAGS, - **kwargs - ) - return name diff --git a/tests/analysis/internal_do_not_use/util/file_factory/happy_test.bzl b/tests/analysis/internal_do_not_use/util/file_factory/happy_test.bzl deleted file mode 100644 index 1a2a655..0000000 --- a/tests/analysis/internal_do_not_use/util/file_factory/happy_test.bzl +++ /dev/null @@ -1,78 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""file_factory_happy_test""" - -load("//kotlin/jvm/internal_do_not_use/util:file_factory.bzl", "FileFactory") -load("//:visibility.bzl", "RULES_KOTLIN") - -def _test_base_from_file(ctx, pkg_path): - base_file = ctx.actions.declare_file("file/base.txt") - factory = FileFactory(ctx, base_file) - - _assert_equals(pkg_path + "/file/base", factory.base_as_path) - - return [base_file] - -def _test_declare(ctx, pkg_path): - factory = FileFactory(ctx, "string/base") - - _assert_equals(pkg_path + "/string/base", factory.base_as_path) - - a_file = factory.declare_file("a.txt") - _assert_equals(pkg_path + "/string/basea.txt", a_file.path) - - b_dir = factory.declare_directory("b_dir") - _assert_equals(pkg_path + "/string/baseb_dir", b_dir.path) - - return [a_file, b_dir] - -def _test_derive(ctx, pkg_path): - factory = FileFactory(ctx, "") - - # Once - factory_once = factory.derive("once") - _assert_equals(pkg_path + "/once", factory_once.base_as_path) - - # Twice - factory_twice = factory_once.derive("/twice") - _assert_equals(pkg_path + "/once/twice", factory_twice.base_as_path) - -def _assert_equals(expected, actual): - if expected != actual: - fail("Expected '%s' but was '%s'" % (expected, actual)) - -def _file_factory_happy_test_impl(ctx): - pkg_path = ctx.bin_dir.path + "/" + ctx.label.package - all_files = [] - - all_files.extend(_test_base_from_file(ctx, pkg_path)) - all_files.extend(_test_declare(ctx, pkg_path)) - _test_derive(ctx, pkg_path) - - ctx.actions.run_shell( - outputs = all_files, - command = "exit 1", - ) - - test_script = ctx.actions.declare_file(ctx.label.name + "_test.sh") - ctx.actions.write(test_script, "#!/bin/bash", True) - return [ - DefaultInfo(executable = test_script), - ] - -file_factory_happy_test = rule( - implementation = _file_factory_happy_test_impl, - test = True, -) diff --git a/tests/analysis/internal_do_not_use/util/file_factory/sub/BUILD b/tests/analysis/internal_do_not_use/util/file_factory/sub/BUILD deleted file mode 100644 index db873cf..0000000 --- a/tests/analysis/internal_do_not_use/util/file_factory/sub/BUILD +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -licenses(["notice"]) - -genrule( - name = "sub", - outs = ["sub.txt"], - cmd = "touch $(OUTS)", - visibility = ["//tests/analysis/internal_do_not_use/util/file_factory:__pkg__"], -) diff --git a/tests/analysis/jvm_compile_test.bzl b/tests/analysis/jvm_compile_test.bzl deleted file mode 100644 index 83e722c..0000000 --- a/tests/analysis/jvm_compile_test.bzl +++ /dev/null @@ -1,391 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Kotlin kt_jvm_compile API test.""" - -load("//kotlin:traverse_exports.bzl", "kt_traverse_exports") -load("//kotlin:jvm_compile.bzl", "kt_jvm_compile") -load("//kotlin:common.bzl", "common") -load("//tests/analysis:util.bzl", "ONLY_FOR_ANALYSIS_TEST_TAGS", "create_dir", "create_file") -load("//toolchains/kotlin_jvm:java_toolchains.bzl", "java_toolchains") -load("//toolchains/kotlin_jvm:kt_jvm_toolchains.bzl", "kt_jvm_toolchains") -load("@bazel_skylib//rules:build_test.bzl", "build_test") -load(":assert_failure_test.bzl", "assert_failure_test") -load("//:visibility.bzl", "RULES_KOTLIN") - -def _impl(ctx): - # As additional capabilites need to be tested, this rule should support - # additional fields/attributes. - result = kt_jvm_compile( - ctx, - output = ctx.outputs.jar, - srcs = ctx.files.srcs, - common_srcs = ctx.files.common_srcs, - deps = ctx.attr.deps, - plugins = [], - exported_plugins = [], - runtime_deps = [], - exports = ctx.attr.exports, - javacopts = [], - kotlincopts = [], - neverlink = False, - testonly = False, - android_lint_plugins = [], - manifest = None, - merged_manifest = None, - resource_files = [], - rule_family = ctx.attr.rule_family, - kt_toolchain = kt_jvm_toolchains.get(ctx), - java_toolchain = java_toolchains.get(ctx), - disable_lint_checks = [], - r_java = ctx.attr.r_java[JavaInfo] if ctx.attr.r_java else None, - ) - return [result.java_info] - -_kt_jvm_compile = rule( - implementation = _impl, - attrs = dict( - srcs = attr.label_list( - allow_files = True, - ), - common_srcs = attr.label_list( - allow_files = True, - ), - deps = attr.label_list( - aspects = [kt_traverse_exports.aspect], - providers = [JavaInfo], - ), - exports = attr.label_list( - aspects = [kt_traverse_exports.aspect], - providers = [JavaInfo], - ), - rule_family = attr.int( - default = common.RULE_FAMILY.UNKNOWN, - ), - r_java = attr.label( - providers = [JavaInfo], - ), - _java_toolchain = attr.label( - default = Label( - "@bazel_tools//tools/jdk:current_java_toolchain", - ), - ), - ), - fragments = ["java"], - outputs = dict( - jar = "lib%{name}.jar", - ), - toolchains = [kt_jvm_toolchains.type, "@bazel_tools//tools/jdk:toolchain_type"], -) - -def _test_kt_jvm_compile_using_kt_jvm_compile_with_r_java(): - test_name = "kt_jvm_compile_using_kt_jvm_compile_with_r_java_test" - - native.java_library( - name = "foo_resources", - srcs = [create_file( - name = test_name + "/java/com/foo/R.java", - content = """ -package com.foo; - -public final class R { - public static final class string { - public static int a_string=0x00000001; - public static int b_string=0x00000002; - } -} -""", - )], - ) - - _kt_jvm_compile( - name = "kt_jvm_compile_with_r_java", - srcs = [create_file( - name = test_name + "/AString.kt", - content = """ -package test - -import com.foo.R.string.a_string - -fun aString(): String = "a_string=" + a_string -""", - )], - r_java = ":foo_resources", - ) - - _kt_jvm_compile( - name = "kt_jvm_compile_using_kt_jvm_compile_with_r_java", - srcs = [create_file( - name = test_name + "/ABString.kt", - content = """ -package test - -import com.foo.R.string.b_string - -fun bString(): String = "b_string=" + b_string - -fun abString(): String = aString() + bString() -""", - )], - deps = [":kt_jvm_compile_with_r_java"], - ) - - # If a failure occurs, it will be at build time. - build_test( - name = test_name, - targets = [":kt_jvm_compile_using_kt_jvm_compile_with_r_java"], - ) - return test_name - -def _test_kt_jvm_compile_with_illegal_r_java(): - test_name = "kt_jvm_compile_with_illegal_r_java_test" - - native.java_library( - name = "foo", - srcs = [create_file( - name = test_name + "/java/com/foo/Foo.java", - content = """ -package com.foo; - -public class Foo {} -""", - )], - ) - _kt_jvm_compile( - name = "kt_jvm_compile_with_illegal_r_java", - srcs = [create_file( - name = test_name + "/AString.kt", - content = """ -package test - -import com.foo.Foo - -fun bar(): String = "Bar" -""", - )], - tags = ONLY_FOR_ANALYSIS_TEST_TAGS, - r_java = ":foo", - ) - assert_failure_test( - name = test_name, - target_under_test = ":kt_jvm_compile_with_illegal_r_java", - msg_contains = "illegal dependency provided for r_java", - ) - return test_name - -def _test_kt_jvm_compile_with_r_java_as_first_dep(): - test_name = "kt_jvm_compile_with_r_java_as_first_dep_test" - - # Note: The R from an android_library must be the first dependency in - # the classpath to prevent another libraries R from being used for - # compilation. If the ordering is incorrect, compiletime failures will - # occur as the depot relies on this ordering. - - native.java_library( - name = "foo_with_symbol_resources", - srcs = [create_file( - name = test_name + "/with_symbol/java/com/foo/R.java", - content = """ -package com.foo; - -public final class R { - public static final class string { - public static int a_string=0x00000001; - } -} -""", - )], - ) - - native.java_library( - name = "foo_without_symbol_resources", - srcs = [create_file( - name = test_name + "/without_symbol/java/com/foo/R.java", - content = """ -package com.foo; - -public final class R { - public static final class string { - } -} -""", - )], - ) - - _kt_jvm_compile( - name = "kt_jvm_compile_with_r_java_as_first_dep", - srcs = [create_file( - name = test_name + "/AString.kt", - content = """ -package test - -import com.foo.R.string.a_string - -fun aString(): String = "a_string=" + a_string -""", - )], - r_java = ":foo_with_symbol_resources", - deps = [":foo_without_symbol_resources"], - ) - - # If a failure occurs, it will be at build time. - build_test( - name = test_name, - targets = [":kt_jvm_compile_with_r_java_as_first_dep"], - ) - return test_name - -def _test_kt_jvm_compile_without_srcs_for_android(): - test_name = "kt_jvm_compile_without_srcs_for_android_test" - - # This is a common case for rules like android_library where Kotlin sources - # could be empty, due to the rule being used for resource processing. For - # this scenario, historically, rules continue to produce empty Jars. - _kt_jvm_compile( - name = "kt_jvm_compile_without_srcs_for_android", - rule_family = common.RULE_FAMILY.ANDROID_LIBRARY, - ) - - # If a failure occurs, it will be at build time. - build_test( - name = test_name, - targets = [":kt_jvm_compile_without_srcs_for_android"], - ) - return test_name - -def _test_kt_jvm_compile_without_srcs_for_jvm(): - test_name = "kt_jvm_compile_without_srcs_for_jvm_test" - - _kt_jvm_compile( - name = "kt_jvm_compile_without_srcs_for_jvm", - srcs = [], - common_srcs = [], - exports = [], - tags = ONLY_FOR_ANALYSIS_TEST_TAGS, - ) - assert_failure_test( - name = test_name, - target_under_test = ":kt_jvm_compile_without_srcs_for_jvm", - msg_contains = "Expected one of (srcs, common_srcs, exports) is not empty", - ) - return test_name - -def _test_kt_jvm_compile_without_srcs_and_with_exports(): - test_name = "kt_jvm_compile_without_srcs_and_with_exports_test" - - _kt_jvm_compile( - name = "bar_lib", - srcs = [create_file( - name = test_name + "/Bar.kt", - content = """ -package test - -fun bar(): String = "Bar" -""", - )], - ) - - _kt_jvm_compile( - name = "kt_jvm_compile_without_srcs_and_with_exports", - exports = [":bar_lib"], - ) - - _kt_jvm_compile( - name = "foo_bar_lib", - srcs = [create_file( - name = test_name + "/FooBar.kt", - content = """ -package test - -fun fooBar(): String = "Foo" + bar() -""", - )], - deps = [":kt_jvm_compile_without_srcs_and_with_exports"], - ) - - # If a failure occurs, it will be at build time. - build_test( - name = test_name, - targets = [":foo_bar_lib"], - ) - return test_name - -def _test_kt_jvm_compile_unsupported_src_artifacts(): - test_name = "kt_jvm_compile_unsupported_src_artifacts_test" - - kt_src = create_file( - name = test_name + "/src.kt", - content = "", - ) - kt_dir = create_dir( - name = test_name + "/kotlin", - subdir = "", - srcs = [create_file( - name = test_name + "/dir.kt", - content = "", - )], - ) - java_src = create_file( - name = test_name + "/src.java", - content = "", - ) - java_dir = create_dir( - name = test_name + "/java", - subdir = "", - srcs = [create_file( - name = test_name + "/dir.java", - content = "", - )], - ) - java_srcjar = create_file( - name = test_name + "/java.srcjar", - content = "", - ) - _kt_jvm_compile( - name = test_name + "_expected_lib", - srcs = [kt_src, kt_dir, java_src, java_dir, java_srcjar], - tags = ONLY_FOR_ANALYSIS_TEST_TAGS, - ) - - unexpected_file = create_file( - name = test_name + "/src.unexpected", - content = "", - ) - _kt_jvm_compile( - name = test_name + "_unexpected_lib", - srcs = [unexpected_file], - deps = [test_name + "_expected_lib"], - tags = ONLY_FOR_ANALYSIS_TEST_TAGS, - ) - - assert_failure_test( - name = test_name, - target_under_test = test_name + "_unexpected_lib", - msg_contains = "/src.unexpected", - ) - return test_name - -def test_suite(name = None): - native.test_suite( - name = name, - tests = [ - _test_kt_jvm_compile_unsupported_src_artifacts(), - _test_kt_jvm_compile_using_kt_jvm_compile_with_r_java(), - _test_kt_jvm_compile_with_illegal_r_java(), - _test_kt_jvm_compile_with_r_java_as_first_dep(), - _test_kt_jvm_compile_without_srcs_for_android(), - _test_kt_jvm_compile_without_srcs_for_jvm(), - _test_kt_jvm_compile_without_srcs_and_with_exports(), - ], - ) diff --git a/tests/analysis/jvm_import_test.bzl b/tests/analysis/jvm_import_test.bzl deleted file mode 100644 index 6e56c02..0000000 --- a/tests/analysis/jvm_import_test.bzl +++ /dev/null @@ -1,169 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Kotlin kt_jvm_import rule tests.""" - -load("//kotlin:jvm_import.bzl", "kt_jvm_import") -load("//kotlin:jvm_library.bzl", "kt_jvm_library") -load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") -load("//tests/analysis:util.bzl", "ONLY_FOR_ANALYSIS_TEST_TAGS", "create_file") -load(":assert_failure_test.bzl", "assert_failure_test") -load("//:visibility.bzl", "RULES_KOTLIN") - -def _impl(ctx): - env = analysistest.begin(ctx) - asserts.true( - env, - JavaInfo in ctx.attr.target_under_test, - "kt_jvm_import did not produce JavaInfo provider.", - ) - asserts.true( - env, - ProguardSpecProvider in ctx.attr.target_under_test, - "kt_jvm_import did not produce ProguardSpecProvider provider.", - ) - return analysistest.end(env) - -_test = analysistest.make(_impl) - -def _test_kt_jvm_import(): - test_name = "kt_jvm_import_test" - native.java_library( - name = "jar1", - srcs = [], - ) - kt_jvm_import( - name = test_name + "_tut", - jars = [ - "libjar1.jar", - ], - srcjar = "libjar1-src.jar", - ) - _test( - name = test_name, - target_under_test = test_name + "_tut", - ) - return test_name - -def _test_kt_jvm_import_no_srcjar(): - test_name = "kt_jvm_import_no_srcjar_test" - native.java_library( - name = "jar3", - srcs = [], - ) - kt_jvm_import( - name = test_name + "_tut", - jars = [ - "libjar3.jar", - ], - ) - _test( - name = test_name, - target_under_test = test_name + "_tut", - ) - return test_name - -def _test_kt_jvm_import_with_srcjar_ext(): - test_name = "kt_jvm_import_test_with_srcjar_ext" - native.java_library( - name = "jar2", - srcs = [], - ) - native.genrule( - name = "gen_jar2_srcjar", - cmd = "touch $@", - outs = ["libjar2.srcjar"], - ) - kt_jvm_import( - name = test_name + "_tut", - jars = [ - "libjar2.jar", - ], - srcjar = ":libjar2.srcjar", - ) - _test( - name = test_name, - target_under_test = test_name + "_tut", - ) - return test_name - -def _test_kt_jvm_import_with_runtime_deps(): - test_name = "kt_jvm_import_with_runtime_deps" - native.java_library( - name = test_name + "_dep", - srcs = [], - ) - kt_jvm_import( - name = test_name + "_tut", - jars = [ - "lib%s_dep.jar" % test_name, - ], - runtime_deps = [ - test_name + "_dep", - ], - ) - _test( - name = test_name, - target_under_test = test_name + "_tut", - ) - return test_name - -def _test_kt_jvm_import_with_proguard_specs(): - test_name = "kt_jvm_import_with_proguard_specs" - native.java_library( - name = test_name + "_jar", - srcs = [], - ) - - kt_jvm_import( - name = test_name + "_tut", - jars = [ - "lib%s_jar.jar" % test_name, - ], - proguard_specs = [ - create_file( - name = test_name + "/salutations.pgcfg", - content = """ --keep class * { - *** greeting(); -} -""", - ), - ], - ) - _test( - name = test_name, - target_under_test = test_name + "_tut", - ) - return test_name - -def _mock_jar(test_name, i): - """Creates a Jar named after the given inputs and returns its name.""" - native.java_library( - name = "%s_mock%s" % (test_name, i), - srcs = [], - ) - return "lib%s_mock%s.jar" % (test_name, i) - -def test_suite(name = None): - native.test_suite( - name = name, - tests = [ - _test_kt_jvm_import(), - _test_kt_jvm_import_with_srcjar_ext(), - _test_kt_jvm_import_no_srcjar(), - _test_kt_jvm_import_with_runtime_deps(), - _test_kt_jvm_import_with_proguard_specs(), - ], - ) diff --git a/tests/analysis/jvm_library/data/BUILD b/tests/analysis/jvm_library/data/BUILD deleted file mode 100644 index e92a2e8..0000000 --- a/tests/analysis/jvm_library/data/BUILD +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("//tests/analysis:for_test.bzl", "rules_for_test") -load("//tests/analysis:jvm_library_test.bzl", "jvm_library_test") - -package( - default_testonly = True, -) - -licenses(["notice"]) - -jvm_library_test( - name = "data_test", - expected_runfile_names = [ - "data.txt", - # libX.jar is always in data_runfiles as well - just append it. - "libdata.jar", - ], - target_under_test = rules_for_test.kt_jvm_library( - name = "data", - srcs = [ - "Input.kt", - ], - data = [ - "data.txt", - ], - ), -) diff --git a/tests/analysis/jvm_library/data/Input.kt b/tests/analysis/jvm_library/data/Input.kt deleted file mode 100644 index e675bc1..0000000 --- a/tests/analysis/jvm_library/data/Input.kt +++ /dev/null @@ -1,16 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - diff --git a/tests/analysis/jvm_library/data/data.txt b/tests/analysis/jvm_library/data/data.txt deleted file mode 100644 index e3ba5e8..0000000 --- a/tests/analysis/jvm_library/data/data.txt +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License.
\ No newline at end of file diff --git a/tests/analysis/jvm_library/deps/BUILD b/tests/analysis/jvm_library/deps/BUILD deleted file mode 100644 index 6db53bd..0000000 --- a/tests/analysis/jvm_library/deps/BUILD +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("//tests/analysis:for_test.bzl", "rules_for_test") -load("//tests/analysis:jvm_library_test.bzl", "jvm_library_test") - -package( - default_testonly = True, -) - -licenses(["notice"]) - -rules_for_test.kt_jvm_library( - name = "deps_test_kt_dep", - srcs = [ - "Input.kt", - ], -) - -rules_for_test.java_library( - name = "deps_test_java_dep", - srcs = [ - "Input.java", - ], -) - -jvm_library_test( - name = "deps_test", - target_under_test = rules_for_test.kt_jvm_library( - name = "deps", - srcs = [ - "Foo.java", - ], - deps = [ - ":deps_test_java_dep", - ":deps_test_kt_dep", - ], - ), -) diff --git a/tests/analysis/jvm_library/deps/Foo.java b/tests/analysis/jvm_library/deps/Foo.java deleted file mode 100644 index e675bc1..0000000 --- a/tests/analysis/jvm_library/deps/Foo.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - diff --git a/tests/analysis/jvm_library/deps/Input.java b/tests/analysis/jvm_library/deps/Input.java deleted file mode 100644 index e675bc1..0000000 --- a/tests/analysis/jvm_library/deps/Input.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - diff --git a/tests/analysis/jvm_library/deps/Input.kt b/tests/analysis/jvm_library/deps/Input.kt deleted file mode 100644 index e675bc1..0000000 --- a/tests/analysis/jvm_library/deps/Input.kt +++ /dev/null @@ -1,16 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - diff --git a/tests/analysis/jvm_library/friends/BUILD b/tests/analysis/jvm_library/friends/BUILD deleted file mode 100644 index 538bdce..0000000 --- a/tests/analysis/jvm_library/friends/BUILD +++ /dev/null @@ -1,114 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("//kotlin:rules.bzl", "kt_jvm_library") -load("//tests/analysis:for_test.bzl", "rules_for_test") -load("//tests/analysis:jvm_library_test.bzl", "jvm_library_test") -load("//tests/analysis:util.bzl", "ONLY_FOR_ANALYSIS_TEST_TAGS") - -package( - default_testonly = True, - default_visibility = ["//tests/analysis/jvm_library/friends:__subpackages__"], -) - -licenses(["notice"]) - -jvm_library_test( - name = "no_kt_exported_friend_cross_package_test", - expected_friend_jar_names = [], - target_under_test = rules_for_test.kt_jvm_library( - name = "no_kt_exported_friend_cross_package", - srcs = ["Input.kt"], - deps = [ - # Exports :friend from this package - "//tests/analysis/jvm_library/friends/sub:kt_exports_friend", - ], - ), -) - -jvm_library_test( - name = "has_java_exported_friend_in_package_test", - expected_friend_jar_names = [ - "libjava_exports_friend-hjar.jar", - "libfriend-compile.jar", - ], - target_under_test = rules_for_test.kt_jvm_library( - name = "has_java_exported_friend_in_package", - srcs = ["Input.kt"], - deps = [":java_exports_friend"], - ), -) - -jvm_library_test( - name = "has_kt_exported_friend_in_package_test", - expected_friend_jar_names = [ - "libkt_exports_friend-compile.jar", - "libfriend-compile.jar", - ], - target_under_test = rules_for_test.kt_jvm_library( - name = "has_kt_exported_friend_in_package", - srcs = ["Input.kt"], - deps = [":kt_exports_friend"], - ), -) - -jvm_library_test( - name = "no_direct_friend_testing_package_test", - expected_friend_jar_names = [], - target_under_test = rules_for_test.kt_jvm_library( - name = "no_direct_friend_testing_package", - srcs = ["Input.kt"], - deps = ["//tests/analysis/jvm_library/friends/testing:testingfriend"], - ), -) - -jvm_library_test( - name = "no_direct_friend_subpackage_test", - expected_friend_jar_names = [], - target_under_test = rules_for_test.kt_jvm_library( - name = "no_direct_friend_subpackage", - srcs = ["Input.kt"], - deps = ["//tests/analysis/jvm_library/friends/sub:subfriend"], - ), -) - -jvm_library_test( - name = "has_direct_friend_in_package_test", - expected_friend_jar_names = ["libfriend-compile.jar"], - target_under_test = rules_for_test.kt_jvm_library( - name = "has_direct_friend_in_package", - srcs = ["Input.kt"], - deps = [":friend"], - ), -) - -java_library( - name = "java_exports_friend", - srcs = ["Input.java"], - tags = ONLY_FOR_ANALYSIS_TEST_TAGS, - exports = [":friend"], -) - -kt_jvm_library( - name = "kt_exports_friend", - srcs = ["Input.kt"], - tags = ONLY_FOR_ANALYSIS_TEST_TAGS, - exports = [":friend"], -) - -kt_jvm_library( - name = "friend", - srcs = ["Input.kt"], - tags = ONLY_FOR_ANALYSIS_TEST_TAGS, -) diff --git a/tests/analysis/jvm_library/friends/Input.java b/tests/analysis/jvm_library/friends/Input.java deleted file mode 100644 index 5bf1d18..0000000 --- a/tests/analysis/jvm_library/friends/Input.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package test; - -final class Input {} diff --git a/tests/analysis/jvm_library/friends/Input.kt b/tests/analysis/jvm_library/friends/Input.kt deleted file mode 100644 index b1a99cb..0000000 --- a/tests/analysis/jvm_library/friends/Input.kt +++ /dev/null @@ -1,17 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package test diff --git a/tests/analysis/jvm_library/friends/sub/BUILD b/tests/analysis/jvm_library/friends/sub/BUILD deleted file mode 100644 index e7c619f..0000000 --- a/tests/analysis/jvm_library/friends/sub/BUILD +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("//kotlin:rules.bzl", "kt_jvm_library") -load("//tests/analysis:for_test.bzl", "rules_for_test") -load("//tests/analysis:jvm_library_test.bzl", "jvm_library_test") -load("//tests/analysis:util.bzl", "ONLY_FOR_ANALYSIS_TEST_TAGS") - -package( - default_testonly = True, - default_visibility = ["//tests/analysis/jvm_library/friends:__subpackages__"], -) - -licenses(["notice"]) - -jvm_library_test( - name = "no_kt_exported_friend_cross_package_test", - expected_friend_jar_names = [ - "libkt_exports_friend-compile.jar", - # Absent # "libfriend-compile.jar" - ], - target_under_test = rules_for_test.kt_jvm_library( - name = "no_kt_exported_friend_cross_package", - srcs = ["Input.kt"], - deps = [":kt_exports_friend"], - ), -) - -jvm_library_test( - name = "no_direct_friend_cross_package_test", - expected_friend_jar_names = [], - target_under_test = rules_for_test.kt_jvm_library( - name = "no_direct_friend_cross_package", - srcs = ["Input.kt"], - deps = ["//tests/analysis/jvm_library/friends:friend"], - ), -) - -kt_jvm_library( - name = "kt_exports_friend", - srcs = ["Input.kt"], - tags = ONLY_FOR_ANALYSIS_TEST_TAGS, - exports = ["//tests/analysis/jvm_library/friends:friend"], -) - -kt_jvm_library( - name = "subfriend", - srcs = ["Input.kt"], - tags = ONLY_FOR_ANALYSIS_TEST_TAGS, -) diff --git a/tests/analysis/jvm_library/friends/sub/Input.kt b/tests/analysis/jvm_library/friends/sub/Input.kt deleted file mode 100644 index 4c87a1e..0000000 --- a/tests/analysis/jvm_library/friends/sub/Input.kt +++ /dev/null @@ -1,17 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package test.sub diff --git a/tests/analysis/jvm_library/friends/testing/BUILD b/tests/analysis/jvm_library/friends/testing/BUILD deleted file mode 100644 index 827aa30..0000000 --- a/tests/analysis/jvm_library/friends/testing/BUILD +++ /dev/null @@ -1,93 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("//kotlin:rules.bzl", "kt_jvm_library") -load("//tests/analysis:for_test.bzl", "rules_for_test") -load("//tests/analysis:jvm_library_test.bzl", "jvm_library_test") -load("//tests/analysis:util.bzl", "ONLY_FOR_ANALYSIS_TEST_TAGS") - -package( - default_testonly = True, - default_visibility = ["//tests/analysis/jvm_library/friends:__subpackages__"], -) - -licenses(["notice"]) - -jvm_library_test( - name = "has_kt_exported_friend_impl_package_test", - expected_friend_jar_names = [ - "libkt_exports_friend-compile.jar", - "libfriend-compile.jar", - ], - target_under_test = rules_for_test.kt_jvm_library( - name = "has_kt_exported_friend_impl_package", - srcs = ["Input.kt"], - deps = [":kt_exports_friend"], - ), -) - -jvm_library_test( - name = "has_direct_friend_impl_package_test", - expected_friend_jar_names = [ - "libfriend-compile.jar", - ], - target_under_test = rules_for_test.kt_jvm_library( - name = "has_direct_friend_impl_package", - srcs = ["Input.kt"], - deps = ["//tests/analysis/jvm_library/friends:friend"], - ), -) - -jvm_library_test( - name = "no_kt_exported_friend_sibling_package_test", - expected_friend_jar_names = [ - "libkt_exports_subfriend-compile.jar", - # Absent # "subfriend-compile.jar" - ], - target_under_test = rules_for_test.kt_jvm_library( - name = "no_kt_exported_friend_sibling_package", - srcs = ["Input.kt"], - deps = [":kt_exports_subfriend"], - ), -) - -jvm_library_test( - name = "no_direct_friend_sibling_package_test", - expected_friend_jar_names = [], - target_under_test = rules_for_test.kt_jvm_library( - name = "no_direct_friend_sibling_package", - srcs = ["Input.kt"], - deps = ["//tests/analysis/jvm_library/friends/sub:subfriend"], - ), -) - -kt_jvm_library( - name = "kt_exports_subfriend", - srcs = ["Input.kt"], - tags = ONLY_FOR_ANALYSIS_TEST_TAGS, - exports = ["//tests/analysis/jvm_library/friends/sub:subfriend"], -) - -kt_jvm_library( - name = "kt_exports_friend", - srcs = ["Input.kt"], - tags = ONLY_FOR_ANALYSIS_TEST_TAGS, - exports = ["//tests/analysis/jvm_library/friends:friend"], -) - -kt_jvm_library( - name = "testingfriend", - srcs = ["Input.kt"], - tags = ONLY_FOR_ANALYSIS_TEST_TAGS, -) diff --git a/tests/analysis/jvm_library/friends/testing/Input.kt b/tests/analysis/jvm_library/friends/testing/Input.kt deleted file mode 100644 index 2c65124..0000000 --- a/tests/analysis/jvm_library/friends/testing/Input.kt +++ /dev/null @@ -1,17 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package test.testing diff --git a/tests/analysis/jvm_library/no_java_srcs/BUILD b/tests/analysis/jvm_library/no_java_srcs/BUILD deleted file mode 100644 index f149c73..0000000 --- a/tests/analysis/jvm_library/no_java_srcs/BUILD +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("//tests/analysis:for_test.bzl", "rules_for_test") -load("//tests/analysis:jvm_library_test.bzl", "jvm_library_test") - -package( - default_testonly = True, -) - -licenses(["notice"]) - -jvm_library_test( - name = "no_java_srcs_test", - target_under_test = rules_for_test.kt_jvm_library( - name = "no_java_srcs", - srcs = [ - "Input.kt", - ], - ), -) diff --git a/tests/analysis/jvm_library/no_java_srcs/Input.kt b/tests/analysis/jvm_library/no_java_srcs/Input.kt deleted file mode 100644 index e675bc1..0000000 --- a/tests/analysis/jvm_library/no_java_srcs/Input.kt +++ /dev/null @@ -1,16 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - diff --git a/tests/analysis/jvm_library/no_kt_srcs/BUILD b/tests/analysis/jvm_library/no_kt_srcs/BUILD deleted file mode 100644 index d5aafcd..0000000 --- a/tests/analysis/jvm_library/no_kt_srcs/BUILD +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("//tests/analysis:for_test.bzl", "rules_for_test") -load("//tests/analysis:jvm_library_test.bzl", "jvm_library_test") - -package( - default_testonly = True, -) - -licenses(["notice"]) - -jvm_library_test( - name = "no_kt_srcs_test", - target_under_test = rules_for_test.kt_jvm_library( - name = "no_kt_srcs", - srcs = [ - "Input.java", - ], - ), -) diff --git a/tests/analysis/jvm_library/no_kt_srcs/Input.java b/tests/analysis/jvm_library/no_kt_srcs/Input.java deleted file mode 100644 index e675bc1..0000000 --- a/tests/analysis/jvm_library/no_kt_srcs/Input.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - diff --git a/tests/analysis/jvm_library/nodeps/BUILD b/tests/analysis/jvm_library/nodeps/BUILD deleted file mode 100644 index f2ae73b..0000000 --- a/tests/analysis/jvm_library/nodeps/BUILD +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("//tests/analysis:for_test.bzl", "rules_for_test") -load("//tests/analysis:jvm_library_test.bzl", "jvm_library_test") - -package( - default_testonly = True, -) - -licenses(["notice"]) - -jvm_library_test( - name = "nodeps_test", - target_under_test = rules_for_test.kt_jvm_library( - name = "nodeps", - srcs = [ - "Input.java", - "Input.kt", - ], - ), -) diff --git a/tests/analysis/jvm_library/nodeps/Input.java b/tests/analysis/jvm_library/nodeps/Input.java deleted file mode 100644 index e675bc1..0000000 --- a/tests/analysis/jvm_library/nodeps/Input.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - diff --git a/tests/analysis/jvm_library/nodeps/Input.kt b/tests/analysis/jvm_library/nodeps/Input.kt deleted file mode 100644 index e675bc1..0000000 --- a/tests/analysis/jvm_library/nodeps/Input.kt +++ /dev/null @@ -1,16 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - diff --git a/tests/analysis/jvm_library/only_common_srcs/BUILD b/tests/analysis/jvm_library/only_common_srcs/BUILD deleted file mode 100644 index aae3068..0000000 --- a/tests/analysis/jvm_library/only_common_srcs/BUILD +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("//tests/analysis:for_test.bzl", "rules_for_test") -load("//tests/analysis:jvm_library_test.bzl", "jvm_library_test") - -package( - default_testonly = True, -) - -licenses(["notice"]) - -jvm_library_test( - name = "only_common_srcs_test", - target_under_test = rules_for_test.kt_jvm_library( - name = "only_common_srcs", - common_srcs = [ - "Input.kt", - ], - ), -) diff --git a/tests/analysis/jvm_library/only_common_srcs/Input.kt b/tests/analysis/jvm_library/only_common_srcs/Input.kt deleted file mode 100644 index e675bc1..0000000 --- a/tests/analysis/jvm_library/only_common_srcs/Input.kt +++ /dev/null @@ -1,16 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - diff --git a/tests/analysis/jvm_library/runtime_deps/BUILD b/tests/analysis/jvm_library/runtime_deps/BUILD deleted file mode 100644 index 85f8b55..0000000 --- a/tests/analysis/jvm_library/runtime_deps/BUILD +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("//tests/analysis:for_test.bzl", "rules_for_test") -load("//tests/analysis:jvm_library_test.bzl", "jvm_library_test") - -package( - default_testonly = True, -) - -licenses(["notice"]) - -rules_for_test.java_library( - name = "runtime_deps_test_dep", - srcs = [], -) - -jvm_library_test( - name = "runtime_deps_test", - target_under_test = rules_for_test.kt_jvm_library( - name = "runtime_deps", - srcs = [ - "Input.kt", - ], - runtime_deps = [ - ":runtime_deps_test_dep", - ], - ), -) diff --git a/tests/analysis/jvm_library/runtime_deps/Input.java b/tests/analysis/jvm_library/runtime_deps/Input.java deleted file mode 100644 index e675bc1..0000000 --- a/tests/analysis/jvm_library/runtime_deps/Input.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - diff --git a/tests/analysis/jvm_library/runtime_deps/Input.kt b/tests/analysis/jvm_library/runtime_deps/Input.kt deleted file mode 100644 index e675bc1..0000000 --- a/tests/analysis/jvm_library/runtime_deps/Input.kt +++ /dev/null @@ -1,16 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - diff --git a/tests/analysis/jvm_library/treeartifacts_srcs/BUILD b/tests/analysis/jvm_library/treeartifacts_srcs/BUILD deleted file mode 100644 index 2ba8ecf..0000000 --- a/tests/analysis/jvm_library/treeartifacts_srcs/BUILD +++ /dev/null @@ -1,106 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -load("//tests/analysis:for_test.bzl", "rules_for_test") -load("//tests/analysis:assert_failure_test.bzl", "assert_failure_test") -load("//tests/analysis:jvm_library_test.bzl", "jvm_library_test") -load("//tests/analysis:util.bzl", "create_dir") - -package( - default_testonly = True, -) - -licenses(["notice"]) - -jvm_library_test( - name = "treeartifact_basename_kotlin_test", - target_under_test = rules_for_test.kt_jvm_library( - name = "treeartifact_basename_kotlin", - srcs = [ - create_dir( - name = "treeartifact_extension/kotlin", - srcs = [ - "Input.java", # TODO: Reject this source - ], - ), - ], - ), -) - -jvm_library_test( - name = "treeartifact_basename_java_test", - target_under_test = rules_for_test.kt_jvm_library( - name = "treeartifact_basename_java", - srcs = [ - create_dir( - name = "treeartifact_extension/java", - srcs = [ - "Input.kt", # TODO: Reject this source - ], - ), - ], - ), -) - -assert_failure_test( - name = "treeartifact_extension_kt_test", - msg_contains = "/treeartifact_extension.kt", - target_under_test = rules_for_test.kt_jvm_library( - name = "treeartifact_extension_kt", - srcs = [ - create_dir( - name = "treeartifact_extension.kt", - ), - ], - ), -) - -assert_failure_test( - name = "treeartifact_extension_java_test", - msg_contains = "/treeartifact_extension.java", - target_under_test = rules_for_test.kt_jvm_library( - name = "treeartifact_extension_java", - srcs = [ - create_dir( - name = "treeartifact_extension.java", - ), - ], - ), -) - -assert_failure_test( - name = "treeartifact_extension_srcjar_test", - msg_contains = "/treeartifact_extension.srcjar", - target_under_test = rules_for_test.kt_jvm_library( - name = "treeartifact_extension_srcjar", - srcs = [ - create_dir( - name = "treeartifact_extension.srcjar", - ), - ], - ), -) - -assert_failure_test( - name = "treeartifact_no_extension_test", - msg_contains = "/treeartifact_no_extension", - target_under_test = rules_for_test.kt_jvm_library( - name = "treeartifact_no_extension", - srcs = [ - create_dir( - name = "treeartifact_no_extension_dir", - ), - ], - ), -) diff --git a/tests/analysis/jvm_library/treeartifacts_srcs/Input.java b/tests/analysis/jvm_library/treeartifacts_srcs/Input.java deleted file mode 100644 index e675bc1..0000000 --- a/tests/analysis/jvm_library/treeartifacts_srcs/Input.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - diff --git a/tests/analysis/jvm_library/treeartifacts_srcs/Input.kt b/tests/analysis/jvm_library/treeartifacts_srcs/Input.kt deleted file mode 100644 index e675bc1..0000000 --- a/tests/analysis/jvm_library/treeartifacts_srcs/Input.kt +++ /dev/null @@ -1,16 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - diff --git a/tests/analysis/jvm_library_test.bzl b/tests/analysis/jvm_library_test.bzl deleted file mode 100644 index 1627c5f..0000000 --- a/tests/analysis/jvm_library_test.bzl +++ /dev/null @@ -1,660 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Kotlin kt_jvm_library rule tests.""" - -load("//:visibility.bzl", "RULES_KOTLIN") -load("//kotlin:jvm_library.bzl", "kt_jvm_library") -load("//tests/analysis:util.bzl", "ONLY_FOR_ANALYSIS_TEST_TAGS", "create_file", "get_action", "get_arg") -load("@bazel_skylib//lib:sets.bzl", "sets") -load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts") -load(":assert_failure_test.bzl", "assert_failure_test") - -_DEFAULT_LIST = ["__default__"] - -def _test_impl(ctx): - env = analysistest.begin(ctx) - actual = ctx.attr.target_under_test - - actions = analysistest.target_actions(env) - kt_al_action = get_action(actions, "KtAndroidLint") - - asserts.true( - env, - JavaInfo in actual, - "kt_jvm_library did not produce JavaInfo provider.", - ) - asserts.true( - env, - ProguardSpecProvider in actual, - "Expected a ProguardSpecProvider provider.", - ) - - if ctx.attr.expected_runfile_names != _DEFAULT_LIST: - asserts.set_equals( - env, - sets.make(ctx.attr.expected_runfile_names), - sets.make([ - f.basename - for f in actual[DefaultInfo].data_runfiles.files.to_list() - ]), - ) - - if ctx.attr.expected_compile_jar_names != _DEFAULT_LIST: - asserts.set_equals( - env, - sets.make(ctx.attr.expected_compile_jar_names), - sets.make([f.basename for f in actual[JavaInfo].compile_jars.to_list()]), - "kt_jvm_library JavaInfo::compile_jars", - ) - - if ctx.attr.expected_exported_processor_jar_names != _DEFAULT_LIST: - asserts.set_equals( - env, - sets.make(ctx.attr.expected_exported_processor_jar_names), - sets.make([f.basename for f in actual[JavaInfo].plugins.processor_jars.to_list()]), - ) - - asserts.set_equals( - env, - sets.make(ctx.attr.expected_exported_processor_classes), - sets.make(actual[JavaInfo].plugins.processor_classes.to_list()), - ) - - kt_2_java_compile = get_action(actions, "Kt2JavaCompile") - - if kt_2_java_compile: - asserts.true( - env, - kt_2_java_compile.outputs.to_list()[0].basename.endswith(".jar"), - "Expected first output to be a JAR (this affects the param file name).", - ) - - if ctx.attr.expected_friend_jar_names != _DEFAULT_LIST: - friend_paths_arg = get_arg(kt_2_java_compile, "-Xfriend-paths=") - friend_jar_names = [p.rsplit("/", 1)[1] for p in friend_paths_arg.split(",")] if friend_paths_arg else [] - asserts.set_equals(env, sets.make(ctx.attr.expected_friend_jar_names), sets.make(friend_jar_names)) - - asserts.equals( - env, - ctx.attr.expect_neverlink, - len(actual[JavaInfo].transitive_runtime_jars.to_list()) == 0, - "Mismatch: Expected transitive_runtime_jars iff (neverlink == False)", - ) - - return analysistest.end(env) - -_test = analysistest.make( - impl = _test_impl, - attrs = dict( - expected_al_ruleset_names = attr.string_list( - doc = "Android Lint rule JARs reported as run on the given target", - default = _DEFAULT_LIST, - ), - expected_compile_jar_names = attr.string_list( - doc = "Names of all JavaInfo::compile_jars for the given target", - default = _DEFAULT_LIST, - ), - expected_exported_processor_jar_names = attr.string_list( - doc = "Names of all JavaInfo.plugins JARs returned by the given target", - default = _DEFAULT_LIST, - ), - expected_exported_processor_classes = attr.string_list( - doc = "Annotation processors reported as to be run on depending targets", - ), - expected_processor_classes = attr.string_list( - doc = "Annotation processors reported as run on the given target", - ), - expected_friend_jar_names = attr.string_list( - doc = "Names of all -Xfriend-paths= JARs", - default = _DEFAULT_LIST, - ), - expected_runfile_names = attr.string_list( - doc = "Names of all runfiles", - default = _DEFAULT_LIST, - ), - expect_processor_classpath = attr.bool(), - expect_neverlink = attr.bool(), - ), -) - -jvm_library_test = _test - -def _coverage_test_impl(ctx): - env = analysistest.begin(ctx) - target_under_test = analysistest.target_under_test(env) - instrumented_files_info = target_under_test[InstrumentedFilesInfo] - instrumented_files = instrumented_files_info.instrumented_files.to_list() - asserts.equals( - env, - ctx.attr.expected_instrumented_file_basenames, - [file.basename for file in instrumented_files], - ) - return analysistest.end(env) - -_coverage_test = analysistest.make( - impl = _coverage_test_impl, - attrs = { - "expected_instrumented_file_basenames": attr.string_list(), - }, - config_settings = { - "//command_line_option:collect_code_coverage": "1", - "//command_line_option:instrument_test_targets": "1", - "//command_line_option:instrumentation_filter": "+tests/analysis[:/]", - }, -) - -def _test_kt_jvm_library_with_proguard_specs(): - test_name = "kt_jvm_library_with_proguard_specs_test" - create_file( - name = test_name + "/Salutations.kt", - content = """ -package test - -fun greeting(): String = "Hello World!" -""", - ) - create_file( - name = test_name + "/salutations.pgcfg", - content = """ --keep class * { - *** greeting(); -} -""", - ) - kt_jvm_library( - name = test_name + "_tut", - srcs = [ - test_name + "/Salutations.kt", - ], - proguard_specs = [ - test_name + "/salutations.pgcfg", - ], - ) - _test( - name = test_name, - target_under_test = test_name + "_tut", - ) - return test_name - -def _test_kt_jvm_library_with_resources(): - test_name = "kt_jvm_library_with_resources_test" - create_file( - name = test_name + "/Salutations.kt", - content = """ -package test - -fun greeting(): String = "Hello World!" -""", - ) - create_file( - name = test_name + "/salutations.txt", - content = """ -Hi! -""", - ) - kt_jvm_library( - name = test_name + "_tut", - srcs = [ - test_name + "/Salutations.kt", - "testinputs/Foo.java", - ], - resources = [ - test_name + "/salutations.txt", - ], - ) - _test( - name = test_name, - target_under_test = test_name + "_tut", - ) - return test_name - -def _test_kt_jvm_library_with_plugin(): - test_name = "kt_jvm_library_with_plugin_test" - create_file( - name = test_name + "/Salutations.kt", - content = """ -package test - -fun greeting(): String = "Hello World!" -""", - ) - - kt_jvm_library( - name = test_name + "_tut", - srcs = [ - test_name + "/Salutations.kt", - ], - # Need a working plugin so it can run for the test. - plugins = ["//bazel:auto_value_plugin"], - ) - - _test( - name = test_name, - target_under_test = test_name + "_tut", - expected_processor_classes = ["com.google.auto.value.processor.AutoValueProcessor"], - expect_processor_classpath = True, - ) - return test_name - -def _test_kt_jvm_library_no_kt_srcs_with_plugin(): - test_name = "kt_jvm_library_no_kt_srcs_with_plugin_test" - native.java_plugin( - name = "%s_plugin" % test_name, - processor_class = test_name, - srcs = ["testinputs/Foo.java"], # induce processor_classpath - ) - kt_jvm_library( - name = test_name + "_tut", - srcs = ["testinputs/Bar.java"], - plugins = [":%s_plugin" % test_name], - tags = ONLY_FOR_ANALYSIS_TEST_TAGS, - ) - _test( - name = test_name, - target_under_test = test_name + "_tut", - expected_processor_classes = [test_name], - expect_processor_classpath = True, - ) - return test_name - -def _test_kt_jvm_library_with_non_processor_plugin(): - test_name = "kt_jvm_library_with_non_processor_plugin_test" - create_file( - name = test_name + "/Salutations.kt", - content = """ -package test - -fun greeting(): String = "Hello World!" -""", - ) - - native.java_plugin( - # no processor_class - name = "%s_plugin" % test_name, - srcs = ["testinputs/Foo.java"], - ) - kt_jvm_library( - name = test_name + "_tut", - srcs = [ - test_name + "/Salutations.kt", - ], - plugins = [":%s_plugin" % test_name], - ) - - _test( - name = test_name, - target_under_test = test_name + "_tut", - expected_processor_classes = [], # no processor class so no processing - expect_processor_classpath = True, # expect java_plugin's Jar - ) - return test_name - -def _test_kt_jvm_library_with_exported_plugin(): - test_name = "kt_jvm_library_with_exported_plugin_test" - create_file( - name = test_name + "/Salutations.kt", - content = """ -package test - -fun greeting(): String = "Hello World!" -""", - ) - native.java_plugin( - name = "%s_plugin" % test_name, - processor_class = test_name, - ) - kt_jvm_library( - name = test_name + "_tut", - srcs = [ - test_name + "/Salutations.kt", - ], - exported_plugins = [":%s_plugin" % test_name], - ) - - _test( - name = test_name, - target_under_test = test_name + "_tut", - expected_exported_processor_classes = [test_name], - expected_processor_classes = [], # exported plugin should *not* run on _tut itself - ) - return test_name - -def _test_kt_jvm_library_dep_on_exported_plugin(): - test_name = "kt_jvm_library_dep_on_exported_plugin_test" - create_file( - name = test_name + "/Salutations.kt", - content = """ -package test - -fun greeting(): String = "Hello World!" -""", - ) - - native.java_plugin( - name = "%s_plugin" % test_name, - processor_class = test_name, - srcs = ["testinputs/Foo.java"], # induce processor_classpath - ) - kt_jvm_library( - name = "%s_exports_plugin" % test_name, - srcs = [test_name + "/Salutations.kt"], - exported_plugins = [":%s_plugin" % test_name], - ) - kt_jvm_library( - name = test_name + "_tut", - srcs = [ - test_name + "/Salutations.kt", - ], - deps = [":%s_exports_plugin" % test_name], - tags = ONLY_FOR_ANALYSIS_TEST_TAGS, - ) - - _test( - name = test_name, - target_under_test = test_name + "_tut", - expected_processor_classes = [test_name], - expect_processor_classpath = True, - ) - return test_name - -def _test_kt_jvm_library_java_dep_on_exported_plugin(): - test_name = "kt_jvm_library_java_dep_on_exported_plugin_test" - create_file( - name = test_name + "/Salutations.kt", - content = """ -package test - -fun greeting(): String = "Hello World!" -""", - ) - native.java_plugin( - name = "%s_plugin" % test_name, - processor_class = test_name, - srcs = ["testinputs/Foo.java"], # induce processor_classpath - ) - native.java_library( - name = "%s_exports_plugin" % test_name, - exported_plugins = [":%s_plugin" % test_name], - ) - kt_jvm_library( - name = test_name + "_tut", - srcs = [ - test_name + "/Salutations.kt", - ], - deps = [":%s_exports_plugin" % test_name], - tags = ONLY_FOR_ANALYSIS_TEST_TAGS, - ) - - _test( - name = test_name, - target_under_test = test_name + "_tut", - expected_processor_classes = [test_name], - expect_processor_classpath = True, - ) - return test_name - -def _test_kt_jvm_library_with_exports(): - test_name = "kt_jvm_library_with_exports_test" - create_file( - name = test_name + "/Salutations.kt", - content = """ -package test - -fun greeting(): String = "Hello World!" -""", - ) - kt_jvm_library( - name = test_name + "_exp", - srcs = [test_name + "/Salutations.kt"], - ) - native.java_library( - name = test_name + "_javaexp", - srcs = ["testinputs/Foo.java"], # need file here so we get a Jar - ) - kt_jvm_library( - name = test_name + "_tut", - srcs = [ - test_name + "/Salutations.kt", - ], - exports = [ - ":%s_exp" % test_name, - ":%s_javaexp" % test_name, - ], - ) - _test( - name = test_name, - target_under_test = test_name + "_tut", - expected_compile_jar_names = [ - "lib%s_tut-compile.jar" % test_name, - "lib%s_exp-compile.jar" % test_name, - "lib%s_javaexp-hjar.jar" % test_name, - ], - ) - return test_name - -def _test_kt_jvm_library_with_export_that_exports_plugin(): - test_name = "kt_jvm_library_with_export_that_exports_plugin_test" - create_file( - name = test_name + "/Salutations.kt", - content = """ -package test - -fun greeting(): String = "Hello World!" -""", - ) - native.java_plugin( - name = "%s_plugin" % test_name, - processor_class = test_name, - srcs = ["testinputs/Foo.java"], # induce processor_classpath - ) - kt_jvm_library( - name = "%s_exports_plugin" % test_name, - exported_plugins = [":%s_plugin" % test_name], - srcs = [test_name + "/Salutations.kt"], - ) - kt_jvm_library( - name = test_name + "_tut", - srcs = [ - test_name + "/Salutations.kt", - ], - exports = [":%s_exports_plugin" % test_name], - ) - _test( - name = test_name, - target_under_test = test_name + "_tut", - expected_compile_jar_names = [ - "lib%s_tut-compile.jar" % test_name, - "lib%s_exports_plugin-compile.jar" % test_name, - ], - expected_exported_processor_classes = [test_name], - ) - return test_name - -def _test_kt_jvm_library_with_java_export_that_exports_plugin(): - test_name = "kt_jvm_library_with_java_export_that_exports_plugin_test" - create_file( - name = test_name + "/Salutations.kt", - content = """ -package test - -fun greeting(): String = "Hello World!" -""", - ) - native.java_plugin( - name = "%s_plugin" % test_name, - processor_class = test_name, - srcs = ["testinputs/Foo.java"], # induce processor_classpath - ) - native.java_library( - name = "%s_exports_plugin" % test_name, - exported_plugins = [":%s_plugin" % test_name], - ) - kt_jvm_library( - name = test_name + "_tut", - srcs = [ - test_name + "/Salutations.kt", - ], - exports = [":%s_exports_plugin" % test_name], - ) - _test( - name = test_name, - target_under_test = test_name + "_tut", - expected_compile_jar_names = [ - # _exports_plugin has no compile/runtime Jars - "lib%s_tut-compile.jar" % test_name, - ], - expected_exported_processor_classes = [test_name], - ) - return test_name - -def _test_forbidden_nano_dep(): - test_name = "kt_jvm_library_forbidden_nano_test" - - kt_jvm_library( - name = test_name + "_tut", - srcs = [test_name + "/Ignored.kt"], - deps = [test_name + "_fake_nano_proto_lib"], - tags = [ - "manual", - "nobuilder", - ], - ) - native.java_library( - name = test_name + "_fake_nano_proto_lib", - srcs = [], - tags = ["nano_proto_library"], - ) - assert_failure_test( - name = test_name, - target_under_test = test_name + "_tut", - msg_contains = test_name + "_fake_nano_proto_lib : nano_proto_library", - ) - return test_name - -def _test_forbidden_nano_export(): - test_name = "kt_jvm_library_forbidden_nano_export_test" - - kt_jvm_library( - name = test_name + "_tut", - srcs = [test_name + "/Ignored.kt"], - deps = [test_name + "_export"], - tags = [ - "manual", - "nobuilder", - ], - ) - native.java_library( - name = test_name + "_export", - exports = [test_name + "_fake_nano_proto_lib"], - ) - native.java_library( - name = test_name + "_fake_nano_proto_lib", - srcs = [], - tags = ["nano_proto_library"], - ) - assert_failure_test( - name = test_name, - target_under_test = test_name + "_tut", - msg_contains = test_name + "_fake_nano_proto_lib : nano_proto_library", - ) - return test_name - -def _test_kt_jvm_library_with_no_sources(): - test_name = "kt_jvm_library_with_no_sources_test" - - kt_jvm_library( - name = test_name + "_tut", - tags = [ - "manual", - "nobuilder", - ], - ) - tut_label = str(Label("//tests/analysis:kt_jvm_library_with_no_sources_test_tut")) - assert_failure_test( - name = test_name, - target_under_test = test_name + "_tut", - msg_contains = "One of {srcs, common_srcs, exports, exported_plugins} of target " + tut_label + " must be non empty", - ) - return test_name - -def _test_kt_jvm_library_coverage(): - test_name = "kt_jvm_library_coverage" - kt_jvm_library( - name = test_name + "_tut", - srcs = ["testinputs/Srcs.kt"], - common_srcs = ["testinputs/CommonSrcs.kt"], - deps = [":{}_deps".format(test_name)], - runtime_deps = [":{}_runtime_deps".format(test_name)], - data = [":{}_data".format(test_name)], - resources = [":{}_resources".format(test_name)], - testonly = True, - ) - native.java_library( - name = test_name + "_deps", - srcs = ["testinputs/Deps.java"], - testonly = True, - ) - native.java_library( - name = test_name + "_runtime_deps", - srcs = ["testinputs/RuntimeDeps.java"], - testonly = True, - ) - native.java_binary( - name = test_name + "_data", - main_class = "Data", - srcs = ["testinputs/Data.java"], - testonly = True, - ) - native.java_binary( - name = test_name + "_resources", - main_class = "Resources", - srcs = ["testinputs/Resources.java"], - testonly = True, - ) - _coverage_test( - name = test_name, - target_under_test = test_name + "_tut", - expected_instrumented_file_basenames = [ - "Data.java", - "Deps.java", - "Resources.java", - "RuntimeDeps.java", - "Srcs.kt", - "CommonSrcs.kt", - ], - ) - return test_name - -def test_suite(name): - native.test_suite( - name = name, - tests = [ - _test_forbidden_nano_dep(), - _test_forbidden_nano_export(), - _test_kt_jvm_library_dep_on_exported_plugin(), - _test_kt_jvm_library_java_dep_on_exported_plugin(), - _test_kt_jvm_library_no_kt_srcs_with_plugin(), - _test_kt_jvm_library_with_export_that_exports_plugin(), - _test_kt_jvm_library_with_exported_plugin(), - _test_kt_jvm_library_with_exports(), - _test_kt_jvm_library_with_java_export_that_exports_plugin(), - _test_kt_jvm_library_with_no_sources(), - _test_kt_jvm_library_with_non_processor_plugin(), - _test_kt_jvm_library_with_plugin(), - _test_kt_jvm_library_with_proguard_specs(), - _test_kt_jvm_library_with_resources(), - _test_kt_jvm_library_coverage(), - ], - ) diff --git a/tests/analysis/testinputs/Bar.java b/tests/analysis/testinputs/Bar.java deleted file mode 100644 index c69a114..0000000 --- a/tests/analysis/testinputs/Bar.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package testinputs; - -public class Bar { - public Bar() {} -} diff --git a/tests/analysis/testinputs/CommonSrcs.kt b/tests/analysis/testinputs/CommonSrcs.kt deleted file mode 100644 index 932e704..0000000 --- a/tests/analysis/testinputs/CommonSrcs.kt +++ /dev/null @@ -1,19 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package testinputs - -class CommonSrcs diff --git a/tests/analysis/testinputs/Data.java b/tests/analysis/testinputs/Data.java deleted file mode 100644 index d8e161f..0000000 --- a/tests/analysis/testinputs/Data.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package testinputs; - -final class Data { - private Data() {} -} diff --git a/tests/analysis/testinputs/Deps.java b/tests/analysis/testinputs/Deps.java deleted file mode 100644 index 7f5237f..0000000 --- a/tests/analysis/testinputs/Deps.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package testinputs; - -final class Deps { - private Deps() {} -} diff --git a/tests/analysis/testinputs/Foo.java b/tests/analysis/testinputs/Foo.java deleted file mode 100644 index 249811a..0000000 --- a/tests/analysis/testinputs/Foo.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package testinputs; - -public class Foo { - public Foo() {} -} diff --git a/tests/analysis/testinputs/Resources.java b/tests/analysis/testinputs/Resources.java deleted file mode 100644 index cbf6e7c..0000000 --- a/tests/analysis/testinputs/Resources.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package testinputs; - -final class Resources { - private Resources() {} -} diff --git a/tests/analysis/testinputs/RuntimeDeps.java b/tests/analysis/testinputs/RuntimeDeps.java deleted file mode 100644 index 5515a7a..0000000 --- a/tests/analysis/testinputs/RuntimeDeps.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package testinputs; - -final class RuntimeDeps { - private RuntimeDeps() {} -} diff --git a/tests/analysis/testinputs/Srcs.kt b/tests/analysis/testinputs/Srcs.kt deleted file mode 100644 index 89ca40c..0000000 --- a/tests/analysis/testinputs/Srcs.kt +++ /dev/null @@ -1,19 +0,0 @@ -/* - * * Copyright 2022 Google LLC. All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package testinputs - -class Srcs diff --git a/tests/analysis/util.bzl b/tests/analysis/util.bzl deleted file mode 100644 index 653843b..0000000 --- a/tests/analysis/util.bzl +++ /dev/null @@ -1,125 +0,0 @@ -# Copyright 2022 Google LLC. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the License); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""Some utils""" - -load("//:visibility.bzl", "RULES_KOTLIN") - -# Mark targets that's aren't expected to build, but are needed for analysis test assertions. -ONLY_FOR_ANALYSIS_TEST_TAGS = ["manual", "nobuilder", "only_for_analysis_test"] - -def create_file(name, content): - if content.startswith("\n"): - content = content[1:-1] - - native.genrule( - name = "gen_" + name, - outs = [name], - cmd = """ -cat > $@ <<EOF -%s -EOF -""" % content, - ) - - return name - -def _create_dir_impl(ctx): - dir = ctx.actions.declare_directory(ctx.attr.name) - - command = "mkdir -p {0} " + ("&& cp {1} {0}" if ctx.files.srcs else "# {1}") - ctx.actions.run_shell( - command = command.format( - dir.path + "/" + ctx.attr.subdir, - " ".join([s.path for s in ctx.files.srcs]), - ), - inputs = ctx.files.srcs, - outputs = [dir], - ) - - return [DefaultInfo(files = depset([dir]))] - -_create_dir = rule( - implementation = _create_dir_impl, - attrs = dict( - subdir = attr.string(), - srcs = attr.label_list(allow_files = True), - ), -) - -def create_dir( - name, - subdir = None, - srcs = None): - _create_dir( - name = name, - subdir = subdir, - srcs = srcs, - ) - return name - -def get_action(actions, mnemonic): - """Get a specific action - - Args: - actions: [List[Action]] - mnemonic: [string] Identify the action whose args to search - - Returns: - [Optional[action]] The arg value, or None if it couldn't be found - """ - menmonic_actions = [a for a in actions if a.mnemonic == mnemonic] - if len(menmonic_actions) == 0: - return None - elif len(menmonic_actions) > 1: - fail("Expected a single '%s' action" % mnemonic) - - return menmonic_actions[0] - -def get_arg(action, arg_name, style = "trim"): - """Get a named arg from a specific action - - Args: - action: [Optional[Action]] - arg_name: [string] - style: [Optional[string]] The style of commandline arg - - Returns: - [Optional[string]] The arg value, or None if it couldn't be found - """ - if not action: - return None - - args = action.argv - matches = [(i, a) for (i, a) in enumerate(args) if a.startswith(arg_name)] - if len(matches) == 0: - return None - elif len(matches) > 1: - fail("Expected a single '%s' arg" % arg_name) - (index, arg) = matches[0] - - if style == "trim": - return arg[len(arg_name):] - elif style == "next": - return args[index + 1] - elif style == "list": - result = [] - for i in range(index + 1, len(args)): - if args[i].startswith("--"): - break - result.append(args[i]) - return result - - else: - fail("Unrecognized arg style '%s" % style) |