diff options
author | Alix <agespino@google.com> | 2023-10-18 17:47:00 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2023-10-18 17:47:00 +0000 |
commit | bc9301ae0742c5d330b612e3c69a026dae027512 (patch) | |
tree | e968506d73bb4e836fb854580b90cd3920fc013d /tests/jvm/analysis/jvm_library | |
parent | 0a8252429cb93e7cb96b69fe51dbe974bacc567b (diff) | |
parent | fb2b420b89bfa8cb112f05bb8a4450f36c0b54b0 (diff) | |
download | bazelbuild-kotlin-rules-bc9301ae0742c5d330b612e3c69a026dae027512.tar.gz |
Merge remote-tracking branch 'aosp/upstream-main' into aosp am: fb2b420b89
Original change: https://android-review.googlesource.com/c/platform/external/bazelbuild-kotlin-rules/+/2795413
Change-Id: I491aabdf6920f5b16d46983ad453bf0a06a8f553
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'tests/jvm/analysis/jvm_library')
42 files changed, 1455 insertions, 0 deletions
diff --git a/tests/jvm/analysis/jvm_library/coverage/BUILD b/tests/jvm/analysis/jvm_library/coverage/BUILD new file mode 100644 index 0000000..284a7a8 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/coverage/BUILD @@ -0,0 +1,66 @@ +# 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/common/testing:testing_rules.bzl", "kt_testing_rules") +load("//kotlin/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis") + +package( + default_applicable_licenses = ["//:license"], + default_testonly = True, +) + +licenses(["notice"]) + +kt_testing_rules.coverage_instrumentation_test( + name = "has_coverage_test", + expected_instrumented_file_names = [ + "Data.java", + "Dep.java", + "Resource.java", + "RuntimeDep.java", + "Src.kt", + "CommonSrc.kt", + ], + target_under_test = ktfa.kt_jvm_library( + name = "has_coverage", + srcs = ["Src.kt"], + common_srcs = ["CommonSrc.kt"], + data = [":data"], + resources = [":resource"], + runtime_deps = [":runtime_dep"], + deps = [":dep"], + ), +) + +ktfa.java_library( + name = "dep", + srcs = ["Dep.java"], +) + +ktfa.java_library( + name = "runtime_dep", + srcs = ["RuntimeDep.java"], +) + +ktfa.java_binary( + name = "data", + srcs = ["Data.java"], + main_class = "Data", +) + +ktfa.java_binary( + name = "resource", + srcs = ["Resource.java"], + main_class = "Resources", +) diff --git a/tests/jvm/analysis/jvm_library/coverage/CommonSrc.kt b/tests/jvm/analysis/jvm_library/coverage/CommonSrc.kt new file mode 100644 index 0000000..963d749 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/coverage/CommonSrc.kt @@ -0,0 +1,17 @@ +/* + * * 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/jvm/analysis/jvm_library/coverage/Data.java b/tests/jvm/analysis/jvm_library/coverage/Data.java new file mode 100644 index 0000000..e675bc1 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/coverage/Data.java @@ -0,0 +1,16 @@ +/* + * * 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/jvm/analysis/jvm_library/coverage/Dep.java b/tests/jvm/analysis/jvm_library/coverage/Dep.java new file mode 100644 index 0000000..e675bc1 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/coverage/Dep.java @@ -0,0 +1,16 @@ +/* + * * 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/jvm/analysis/jvm_library/coverage/Resource.java b/tests/jvm/analysis/jvm_library/coverage/Resource.java new file mode 100644 index 0000000..e675bc1 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/coverage/Resource.java @@ -0,0 +1,16 @@ +/* + * * 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/jvm/analysis/jvm_library/coverage/RuntimeDep.java b/tests/jvm/analysis/jvm_library/coverage/RuntimeDep.java new file mode 100644 index 0000000..e675bc1 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/coverage/RuntimeDep.java @@ -0,0 +1,16 @@ +/* + * * 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/jvm/analysis/jvm_library/coverage/Src.kt b/tests/jvm/analysis/jvm_library/coverage/Src.kt new file mode 100644 index 0000000..963d749 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/coverage/Src.kt @@ -0,0 +1,17 @@ +/* + * * 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/jvm/analysis/jvm_library/data/BUILD b/tests/jvm/analysis/jvm_library/data/BUILD new file mode 100644 index 0000000..92350c0 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/data/BUILD @@ -0,0 +1,41 @@ +# 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/jvm/testing:for_analysis.bzl", "kt_for_analysis") +load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test") + +package( + default_applicable_licenses = ["//:license"], + default_testonly = True, +) + +licenses(["notice"]) + +kt_jvm_library_analysis_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 = kt_for_analysis.kt_jvm_library( + name = "data", + srcs = [ + "Input.kt", + ], + data = [ + "data.txt", + ], + ), +) diff --git a/tests/jvm/analysis/jvm_library/data/Input.kt b/tests/jvm/analysis/jvm_library/data/Input.kt new file mode 100644 index 0000000..963d749 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/data/Input.kt @@ -0,0 +1,17 @@ +/* + * * 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/jvm/analysis/jvm_library/data/data.txt b/tests/jvm/analysis/jvm_library/data/data.txt new file mode 100644 index 0000000..d146a73 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/data/data.txt @@ -0,0 +1,27 @@ +# 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. + +# 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/jvm/analysis/jvm_library/deps/BUILD b/tests/jvm/analysis/jvm_library/deps/BUILD new file mode 100644 index 0000000..fb01c01 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/deps/BUILD @@ -0,0 +1,62 @@ +# 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/jvm/testing:for_analysis.bzl", "kt_for_analysis") +load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test") + +package( + default_applicable_licenses = ["//:license"], + default_testonly = True, +) + +licenses(["notice"]) + +kt_jvm_library_analysis_test( + name = "no_deps_test", + target_under_test = kt_for_analysis.kt_jvm_library( + name = "no_deps", + srcs = [ + "Input.java", + "Input.kt", + ], + ), +) + +kt_jvm_library_analysis_test( + name = "deps_test", + target_under_test = kt_for_analysis.kt_jvm_library( + name = "deps", + srcs = [ + "Input.java", + ], + deps = [ + ":deps_test_java_dep", + ":deps_test_kt_dep", + ], + ), +) + +kt_for_analysis.kt_jvm_library( + name = "deps_test_kt_dep", + srcs = [ + "Input.kt", + ], +) + +kt_for_analysis.java_library( + name = "deps_test_java_dep", + srcs = [ + "Input.java", + ], +) diff --git a/tests/jvm/analysis/jvm_library/deps/Input.java b/tests/jvm/analysis/jvm_library/deps/Input.java new file mode 100644 index 0000000..e675bc1 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/deps/Input.java @@ -0,0 +1,16 @@ +/* + * * 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/jvm/analysis/jvm_library/deps/Input.kt b/tests/jvm/analysis/jvm_library/deps/Input.kt new file mode 100644 index 0000000..963d749 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/deps/Input.kt @@ -0,0 +1,17 @@ +/* + * * 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/jvm/analysis/jvm_library/exports/BUILD b/tests/jvm/analysis/jvm_library/exports/BUILD new file mode 100644 index 0000000..b2bb9c7 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/exports/BUILD @@ -0,0 +1,66 @@ +# 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/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis") +load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test") + +package( + default_applicable_licenses = ["//:license"], + default_testonly = True, +) + +licenses(["notice"]) + +kt_jvm_library_analysis_test( + name = "has_exports_test", + expected_compile_jar_names = [ + # go/keep-sorted start + "libexports_transitive-compile.jar", + "libhas_exports-compile.jar", + "libjava_library-hjar.jar", + "libkt_jvm_library-compile.jar", + "libtransitive-compile.jar", + # go/keep-sorted end + ], + target_under_test = ktfa.kt_jvm_library( + name = "has_exports", + srcs = ["Input.kt"], + exports = [ + ":exports_transitive", + ":java_library", + ":kt_jvm_library", + ], + ), +) + +ktfa.kt_jvm_library( + name = "exports_transitive", + srcs = ["Input.kt"], + exports = [ + ktfa.kt_jvm_library( + name = "transitive", + srcs = ["Input.kt"], + ), + ], +) + +ktfa.kt_jvm_library( + name = "kt_jvm_library", + srcs = ["Input.kt"], +) + +ktfa.java_library( + name = "java_library", + srcs = ["Input.java"], # need file here so we get a Jar +) diff --git a/tests/jvm/analysis/jvm_library/exports/Input.java b/tests/jvm/analysis/jvm_library/exports/Input.java new file mode 100644 index 0000000..e675bc1 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/exports/Input.java @@ -0,0 +1,16 @@ +/* + * * 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/jvm/analysis/jvm_library/exports/Input.kt b/tests/jvm/analysis/jvm_library/exports/Input.kt new file mode 100644 index 0000000..963d749 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/exports/Input.kt @@ -0,0 +1,17 @@ +/* + * * 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/jvm/analysis/jvm_library/forbidden_deps/BUILD b/tests/jvm/analysis/jvm_library/forbidden_deps/BUILD new file mode 100644 index 0000000..5fcc02f --- /dev/null +++ b/tests/jvm/analysis/jvm_library/forbidden_deps/BUILD @@ -0,0 +1,54 @@ +# 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/common/testing:testing_rules.bzl", "kt_testing_rules") +load("//kotlin/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis") + +package( + default_applicable_licenses = ["//:license"], + default_testonly = True, +) + +licenses(["notice"]) + +kt_testing_rules.assert_failure_test( + name = "has_forbidden_nano_dep_test", + msg_contains = "fake_nano_proto_lib", + target_under_test = ktfa.kt_jvm_library( + name = "has_forbidden_nano_dep", + srcs = ["Inputs.kt"], + deps = [":fake_nano_proto_lib"], + ), +) + +kt_testing_rules.assert_failure_test( + name = "dep_on_has_forbidden_nano_export_test", + msg_contains = "fake_nano_proto_lib", + target_under_test = ktfa.kt_jvm_library( + name = "dep_on_has_forbidden_nano_export", + srcs = ["Input.kt"], + deps = [ + ktfa.java_library( + name = "has_forbidden_nano_export", + exports = [":fake_nano_proto_lib"], + ), + ], + ), +) + +ktfa.java_library( + name = "fake_nano_proto_lib", + srcs = [], + tags = ["nano_proto_library"], +) diff --git a/tests/jvm/analysis/jvm_library/forbidden_deps/Input.kt b/tests/jvm/analysis/jvm_library/forbidden_deps/Input.kt new file mode 100644 index 0000000..963d749 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/forbidden_deps/Input.kt @@ -0,0 +1,17 @@ +/* + * * 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/jvm/analysis/jvm_library/friends/BUILD b/tests/jvm/analysis/jvm_library/friends/BUILD new file mode 100644 index 0000000..f2454f4 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/friends/BUILD @@ -0,0 +1,110 @@ +# 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/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis") +load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test") + +package( + default_applicable_licenses = ["//:license"], + default_testonly = True, + default_visibility = ["//tests/jvm/analysis/jvm_library/friends:__subpackages__"], +) + +licenses(["notice"]) + +kt_jvm_library_analysis_test( + name = "no_kt_exported_friend_cross_package_test", + expected_friend_jar_names = [], + target_under_test = ktfa.kt_jvm_library( + name = "no_kt_exported_friend_cross_package", + srcs = ["Input.kt"], + deps = [ + # Exports :friend from this package + "//tests/jvm/analysis/jvm_library/friends/sub:kt_exports_friend", + ], + ), +) + +kt_jvm_library_analysis_test( + name = "has_java_exported_friend_in_package_test", + expected_friend_jar_names = [ + "libjava_exports_friend-hjar.jar", + "libfriend-compile.jar", + ], + target_under_test = ktfa.kt_jvm_library( + name = "has_java_exported_friend_in_package", + srcs = ["Input.kt"], + deps = [":java_exports_friend"], + ), +) + +kt_jvm_library_analysis_test( + name = "has_kt_exported_friend_in_package_test", + expected_friend_jar_names = [ + "libkt_exports_friend-compile.jar", + "libfriend-compile.jar", + ], + target_under_test = ktfa.kt_jvm_library( + name = "has_kt_exported_friend_in_package", + srcs = ["Input.kt"], + deps = [":kt_exports_friend"], + ), +) + +kt_jvm_library_analysis_test( + name = "no_direct_friend_testing_package_test", + expected_friend_jar_names = [], + target_under_test = ktfa.kt_jvm_library( + name = "no_direct_friend_testing_package", + srcs = ["Input.kt"], + deps = ["//tests/jvm/analysis/jvm_library/friends/testing:testingfriend"], + ), +) + +kt_jvm_library_analysis_test( + name = "no_direct_friend_subpackage_test", + expected_friend_jar_names = [], + target_under_test = ktfa.kt_jvm_library( + name = "no_direct_friend_subpackage", + srcs = ["Input.kt"], + deps = ["//tests/jvm/analysis/jvm_library/friends/sub:subfriend"], + ), +) + +kt_jvm_library_analysis_test( + name = "has_direct_friend_in_package_test", + expected_friend_jar_names = ["libfriend-compile.jar"], + target_under_test = ktfa.kt_jvm_library( + name = "has_direct_friend_in_package", + srcs = ["Input.kt"], + deps = [":friend"], + ), +) + +ktfa.java_library( + name = "java_exports_friend", + srcs = ["Input.java"], + exports = [":friend"], +) + +ktfa.kt_jvm_library( + name = "kt_exports_friend", + srcs = ["Input.kt"], + exports = [":friend"], +) + +ktfa.kt_jvm_library( + name = "friend", + srcs = ["Input.kt"], +) diff --git a/tests/jvm/analysis/jvm_library/friends/Input.java b/tests/jvm/analysis/jvm_library/friends/Input.java new file mode 100644 index 0000000..5bf1d18 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/friends/Input.java @@ -0,0 +1,19 @@ +/* + * * 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/jvm/analysis/jvm_library/friends/Input.kt b/tests/jvm/analysis/jvm_library/friends/Input.kt new file mode 100644 index 0000000..b1a99cb --- /dev/null +++ b/tests/jvm/analysis/jvm_library/friends/Input.kt @@ -0,0 +1,17 @@ +/* + * * 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/jvm/analysis/jvm_library/friends/sub/BUILD b/tests/jvm/analysis/jvm_library/friends/sub/BUILD new file mode 100644 index 0000000..7f4a38e --- /dev/null +++ b/tests/jvm/analysis/jvm_library/friends/sub/BUILD @@ -0,0 +1,58 @@ +# 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/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis") +load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test") + +package( + default_applicable_licenses = ["//:license"], + default_testonly = True, + default_visibility = ["//tests/jvm/analysis/jvm_library/friends:__subpackages__"], +) + +licenses(["notice"]) + +kt_jvm_library_analysis_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 = ktfa.kt_jvm_library( + name = "no_kt_exported_friend_cross_package", + srcs = ["Input.kt"], + deps = [":kt_exports_friend"], + ), +) + +kt_jvm_library_analysis_test( + name = "no_direct_friend_cross_package_test", + expected_friend_jar_names = [], + target_under_test = ktfa.kt_jvm_library( + name = "no_direct_friend_cross_package", + srcs = ["Input.kt"], + deps = ["//tests/jvm/analysis/jvm_library/friends:friend"], + ), +) + +ktfa.kt_jvm_library( + name = "kt_exports_friend", + srcs = ["Input.kt"], + exports = ["//tests/jvm/analysis/jvm_library/friends:friend"], +) + +ktfa.kt_jvm_library( + name = "subfriend", + srcs = ["Input.kt"], +) diff --git a/tests/jvm/analysis/jvm_library/friends/sub/Input.kt b/tests/jvm/analysis/jvm_library/friends/sub/Input.kt new file mode 100644 index 0000000..4c87a1e --- /dev/null +++ b/tests/jvm/analysis/jvm_library/friends/sub/Input.kt @@ -0,0 +1,17 @@ +/* + * * 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/jvm/analysis/jvm_library/friends/testing/BUILD b/tests/jvm/analysis/jvm_library/friends/testing/BUILD new file mode 100644 index 0000000..0ab1bba --- /dev/null +++ b/tests/jvm/analysis/jvm_library/friends/testing/BUILD @@ -0,0 +1,89 @@ +# 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/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis") +load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test") + +package( + default_applicable_licenses = ["//:license"], + default_testonly = True, + default_visibility = ["//tests/jvm/analysis/jvm_library/friends:__subpackages__"], +) + +licenses(["notice"]) + +kt_jvm_library_analysis_test( + name = "has_kt_exported_friend_impl_package_test", + expected_friend_jar_names = [ + "libkt_exports_friend-compile.jar", + "libfriend-compile.jar", + ], + target_under_test = ktfa.kt_jvm_library( + name = "has_kt_exported_friend_impl_package", + srcs = ["Input.kt"], + deps = [":kt_exports_friend"], + ), +) + +kt_jvm_library_analysis_test( + name = "has_direct_friend_impl_package_test", + expected_friend_jar_names = [ + "libfriend-compile.jar", + ], + target_under_test = ktfa.kt_jvm_library( + name = "has_direct_friend_impl_package", + srcs = ["Input.kt"], + deps = ["//tests/jvm/analysis/jvm_library/friends:friend"], + ), +) + +kt_jvm_library_analysis_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 = ktfa.kt_jvm_library( + name = "no_kt_exported_friend_sibling_package", + srcs = ["Input.kt"], + deps = [":kt_exports_subfriend"], + ), +) + +kt_jvm_library_analysis_test( + name = "no_direct_friend_sibling_package_test", + expected_friend_jar_names = [], + target_under_test = ktfa.kt_jvm_library( + name = "no_direct_friend_sibling_package", + srcs = ["Input.kt"], + deps = ["//tests/jvm/analysis/jvm_library/friends/sub:subfriend"], + ), +) + +ktfa.kt_jvm_library( + name = "kt_exports_subfriend", + srcs = ["Input.kt"], + exports = ["//tests/jvm/analysis/jvm_library/friends/sub:subfriend"], +) + +ktfa.kt_jvm_library( + name = "kt_exports_friend", + srcs = ["Input.kt"], + exports = ["//tests/jvm/analysis/jvm_library/friends:friend"], +) + +ktfa.kt_jvm_library( + name = "testingfriend", + srcs = ["Input.kt"], +) diff --git a/tests/jvm/analysis/jvm_library/friends/testing/Input.kt b/tests/jvm/analysis/jvm_library/friends/testing/Input.kt new file mode 100644 index 0000000..2c65124 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/friends/testing/Input.kt @@ -0,0 +1,17 @@ +/* + * * 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/jvm/analysis/jvm_library/no_srcs/BUILD b/tests/jvm/analysis/jvm_library/no_srcs/BUILD new file mode 100644 index 0000000..004d160 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/no_srcs/BUILD @@ -0,0 +1,69 @@ +# 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/common/testing:testing_rules.bzl", "kt_testing_rules") +load("//kotlin/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis") +load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test") + +package( + default_applicable_licenses = ["//:license"], + default_testonly = True, +) + +licenses(["notice"]) + +kt_testing_rules.assert_failure_test( + name = "no_srcs_test", + msg_contains = "Expected a source-bearing or an export-oriented target", + target_under_test = ktfa.kt_jvm_library( + name = "no_srcs", + srcs = [], + ), +) + +kt_jvm_library_analysis_test( + name = "no_srcs_with_exports_test", + expect_jdeps = False, + required_mnemonic_counts = {"KtAndroidLint": "0"}, + target_under_test = ktfa.kt_jvm_library( + name = "no_srcs_with_exports", + srcs = [], + exports = [ + ktfa.kt_jvm_library( + name = "no_srcs_with_exports_export", + srcs = ["Input.kt"], + ), + ], + ), +) + +kt_jvm_library_analysis_test( + name = "only_kt_srcs_test", + target_under_test = ktfa.kt_jvm_library( + name = "only_kt_srcs", + srcs = [ + "Input.kt", + ], + ), +) + +kt_jvm_library_analysis_test( + name = "only_java_srcs_test", + target_under_test = ktfa.kt_jvm_library( + name = "only_java_srcs", + srcs = [ + "Input.java", + ], + ), +) diff --git a/tests/jvm/analysis/jvm_library/no_srcs/Input.java b/tests/jvm/analysis/jvm_library/no_srcs/Input.java new file mode 100644 index 0000000..e675bc1 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/no_srcs/Input.java @@ -0,0 +1,16 @@ +/* + * * 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/jvm/analysis/jvm_library/no_srcs/Input.kt b/tests/jvm/analysis/jvm_library/no_srcs/Input.kt new file mode 100644 index 0000000..963d749 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/no_srcs/Input.kt @@ -0,0 +1,17 @@ +/* + * * 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/jvm/analysis/jvm_library/only_common_srcs/BUILD b/tests/jvm/analysis/jvm_library/only_common_srcs/BUILD new file mode 100644 index 0000000..a91cff7 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/only_common_srcs/BUILD @@ -0,0 +1,33 @@ +# 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/jvm/testing:for_analysis.bzl", "kt_for_analysis") +load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test") + +package( + default_applicable_licenses = ["//:license"], + default_testonly = True, +) + +licenses(["notice"]) + +kt_jvm_library_analysis_test( + name = "only_common_srcs_test", + target_under_test = kt_for_analysis.kt_jvm_library( + name = "only_common_srcs", + common_srcs = [ + "Input.kt", + ], + ), +) diff --git a/tests/jvm/analysis/jvm_library/only_common_srcs/Input.kt b/tests/jvm/analysis/jvm_library/only_common_srcs/Input.kt new file mode 100644 index 0000000..963d749 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/only_common_srcs/Input.kt @@ -0,0 +1,17 @@ +/* + * * 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/jvm/analysis/jvm_library/plugins/BUILD b/tests/jvm/analysis/jvm_library/plugins/BUILD new file mode 100644 index 0000000..3694233 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/plugins/BUILD @@ -0,0 +1,153 @@ +# 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/common/testing:testing_rules.bzl", "kt_testing_rules") +load("//kotlin/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis") +load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test") + +package( + default_applicable_licenses = ["//:license"], + default_testonly = True, +) + +licenses(["notice"]) + +DEFAULT_KOTLINC_PLUGINS = [ + "jvm-abi-gen.jar", +] + +kt_jvm_library_analysis_test( + name = "has_plugin_and_only_kt_srcs_test", + expect_processor_classpath = True, + expected_exported_processor_classes = [], + expected_kotlinc_plugin_jar_names = DEFAULT_KOTLINC_PLUGINS + ["kt_compiler_plugin.jar"], + expected_processor_classes = ["java.plugin.class"], + target_under_test = ktfa.kt_jvm_library( + name = "has_plugin_and_only_kt_srcs", + srcs = ["Input.kt"], + plugins = [ + ":java_plugin", + ":kt_compiler_plugin", + ], + ), +) + +kt_jvm_library_analysis_test( + name = "has_plugin_and_only_java_srcs_test", + expect_processor_classpath = True, + expected_exported_processor_classes = [], + expected_kotlinc_plugin_jar_names = [], # No kotlinc action + expected_processor_classes = ["java.plugin.class"], + target_under_test = ktfa.kt_jvm_library( + name = "has_plugin_and_only_java_srcs", + srcs = ["Input.java"], + plugins = [ + ":java_plugin", + ":kt_compiler_plugin", + ], + ), +) + +kt_jvm_library_analysis_test( + name = "has_plugin_without_processor_class_test", + expect_processor_classpath = True, + expected_exported_processor_classes = [], + target_under_test = ktfa.kt_jvm_library( + name = "has_plugin_without_processor_class", + srcs = ["Input.java"], + plugins = [ + ktfa.java_plugin( + name = "java_plugin_without_processor_class", + srcs = ["Input.java"], + ), + ], + ), +) + +[ + kt_jvm_library_analysis_test( + name = "dep_on_" + exporter + "_test", + expect_processor_classpath = True, + expected_kotlinc_plugin_jar_names = DEFAULT_KOTLINC_PLUGINS + ["kt_compiler_plugin.jar"], + expected_processor_classes = ["java.plugin.class"], + target_under_test = ktfa.kt_jvm_library( + name = "dep_on_" + exporter, + srcs = ["Input.kt"], + deps = [exporter], + ), + ) + for exporter in [ + "java_library_with_exported_plugin", + "kt_jvm_library_with_exported_plugin", + ] + [ + "kt_jvm_library_exporting_java_library_with_exported_plugin", + "kt_jvm_library_exporting_kt_jvm_library_with_exported_plugin", + ] +] + +[ + kt_jvm_library_analysis_test( + name = "kt_jvm_library_exporting_" + export + "_test", + expect_processor_classpath = False, + expected_exported_processor_classes = ["java.plugin.class"], + expected_kotlinc_plugin_jar_names = DEFAULT_KOTLINC_PLUGINS, + expected_processor_classes = [], + target_under_test = ktfa.kt_jvm_library( + name = "kt_jvm_library_exporting_" + export, + srcs = ["Input.kt"], + exports = [export], + ), + ) + for export in [ + "java_library_with_exported_plugin", + "kt_jvm_library_with_exported_plugin", + ] +] + +ktfa.java_library( + name = "java_library_with_exported_plugin", + srcs = ["Input.java"], + exported_plugins = [ + ":java_plugin", + ":kt_compiler_plugin", + ], +) + +kt_jvm_library_analysis_test( + name = "kt_jvm_library_with_exported_plugin_test", + expect_processor_classpath = False, + expected_exported_processor_classes = ["java.plugin.class"], + expected_kotlinc_plugin_jar_names = DEFAULT_KOTLINC_PLUGINS, + expected_processor_classes = [], # exported plugin should *not* run on exporter itself + target_under_test = ktfa.kt_jvm_library( + name = "kt_jvm_library_with_exported_plugin", + srcs = ["Input.kt"], + exported_plugins = [ + ":java_plugin", + ":kt_compiler_plugin", + ], + ), +) + +ktfa.java_plugin( + name = "java_plugin", + srcs = ["Input.java"], + processor_class = "java.plugin.class", +) + +ktfa.kt_compiler_plugin( + name = "kt_compiler_plugin", + jar = kt_testing_rules.create_file(name = "kt_compiler_plugin.jar"), + plugin_id = "kt.plugin", +) diff --git a/tests/jvm/analysis/jvm_library/plugins/Input.java b/tests/jvm/analysis/jvm_library/plugins/Input.java new file mode 100644 index 0000000..e675bc1 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/plugins/Input.java @@ -0,0 +1,16 @@ +/* + * * 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/jvm/analysis/jvm_library/plugins/Input.kt b/tests/jvm/analysis/jvm_library/plugins/Input.kt new file mode 100644 index 0000000..963d749 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/plugins/Input.kt @@ -0,0 +1,17 @@ +/* + * * 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/jvm/analysis/jvm_library/resources/BUILD b/tests/jvm/analysis/jvm_library/resources/BUILD new file mode 100644 index 0000000..1c4797f --- /dev/null +++ b/tests/jvm/analysis/jvm_library/resources/BUILD @@ -0,0 +1,32 @@ +# 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/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis") +load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test") + +package( + default_applicable_licenses = ["//:license"], + default_testonly = True, +) + +licenses(["notice"]) + +kt_jvm_library_analysis_test( + name = "has_resources_test", + target_under_test = ktfa.kt_jvm_library( + name = "has_resources", + srcs = ["Input.kt"], + resources = ["resource.txt"], + ), +) diff --git a/tests/jvm/analysis/jvm_library/resources/Input.kt b/tests/jvm/analysis/jvm_library/resources/Input.kt new file mode 100644 index 0000000..963d749 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/resources/Input.kt @@ -0,0 +1,17 @@ +/* + * * 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/jvm/analysis/jvm_library/resources/resource.txt b/tests/jvm/analysis/jvm_library/resources/resource.txt new file mode 100644 index 0000000..b986da2 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/resources/resource.txt @@ -0,0 +1,14 @@ +# 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/jvm/analysis/jvm_library/runtime_deps/BUILD b/tests/jvm/analysis/jvm_library/runtime_deps/BUILD new file mode 100644 index 0000000..aaea117 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/runtime_deps/BUILD @@ -0,0 +1,41 @@ +# 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/jvm/testing:for_analysis.bzl", "kt_for_analysis") +load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test") + +package( + default_applicable_licenses = ["//:license"], + default_testonly = True, +) + +licenses(["notice"]) + +kt_for_analysis.java_library( + name = "runtime_deps_test_dep", + srcs = [], +) + +kt_jvm_library_analysis_test( + name = "runtime_deps_test", + target_under_test = kt_for_analysis.kt_jvm_library( + name = "runtime_deps", + srcs = [ + "Input.kt", + ], + runtime_deps = [ + ":runtime_deps_test_dep", + ], + ), +) diff --git a/tests/jvm/analysis/jvm_library/runtime_deps/Input.java b/tests/jvm/analysis/jvm_library/runtime_deps/Input.java new file mode 100644 index 0000000..e675bc1 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/runtime_deps/Input.java @@ -0,0 +1,16 @@ +/* + * * 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/jvm/analysis/jvm_library/runtime_deps/Input.kt b/tests/jvm/analysis/jvm_library/runtime_deps/Input.kt new file mode 100644 index 0000000..963d749 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/runtime_deps/Input.kt @@ -0,0 +1,17 @@ +/* + * * 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/jvm/analysis/jvm_library/treeartifacts_srcs/BUILD b/tests/jvm/analysis/jvm_library/treeartifacts_srcs/BUILD new file mode 100644 index 0000000..6151a43 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/treeartifacts_srcs/BUILD @@ -0,0 +1,106 @@ +# 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/common/testing:testing_rules.bzl", "kt_testing_rules") +load("//kotlin/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis") +load("//kotlin/jvm/testing:jvm_library_analysis_test.bzl", "kt_jvm_library_analysis_test") + +package( + default_applicable_licenses = ["//:license"], + default_testonly = True, +) + +licenses(["notice"]) + +kt_jvm_library_analysis_test( + name = "treeartifact_basename_kotlin_test", + target_under_test = ktfa.kt_jvm_library( + name = "treeartifact_basename_kotlin", + srcs = [ + kt_testing_rules.create_dir( + name = "treeartifact_extension/kotlin", + srcs = [ + "Input.java", # TODO: Reject this source + ], + ), + ], + ), +) + +kt_jvm_library_analysis_test( + name = "treeartifact_basename_java_test", + target_under_test = ktfa.kt_jvm_library( + name = "treeartifact_basename_java", + srcs = [ + kt_testing_rules.create_dir( + name = "treeartifact_extension/java", + srcs = [ + "Input.kt", # TODO: Reject this source + ], + ), + ], + ), +) + +kt_testing_rules.assert_failure_test( + name = "treeartifact_extension_kt_test", + msg_contains = "/treeartifact_extension.kt", + target_under_test = ktfa.kt_jvm_library( + name = "treeartifact_extension_kt", + srcs = [ + kt_testing_rules.create_dir( + name = "treeartifact_extension.kt", + ), + ], + ), +) + +kt_testing_rules.assert_failure_test( + name = "treeartifact_extension_java_test", + msg_contains = "/treeartifact_extension.java", + target_under_test = ktfa.kt_jvm_library( + name = "treeartifact_extension_java", + srcs = [ + kt_testing_rules.create_dir( + name = "treeartifact_extension.java", + ), + ], + ), +) + +kt_testing_rules.assert_failure_test( + name = "treeartifact_extension_srcjar_test", + msg_contains = "/treeartifact_extension.srcjar", + target_under_test = ktfa.kt_jvm_library( + name = "treeartifact_extension_srcjar", + srcs = [ + kt_testing_rules.create_dir( + name = "treeartifact_extension.srcjar", + ), + ], + ), +) + +kt_testing_rules.assert_failure_test( + name = "treeartifact_no_extension_test", + msg_contains = "/treeartifact_no_extension", + target_under_test = ktfa.kt_jvm_library( + name = "treeartifact_no_extension", + srcs = [ + kt_testing_rules.create_dir( + name = "treeartifact_no_extension_dir", + ), + ], + ), +) diff --git a/tests/jvm/analysis/jvm_library/treeartifacts_srcs/Input.java b/tests/jvm/analysis/jvm_library/treeartifacts_srcs/Input.java new file mode 100644 index 0000000..e675bc1 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/treeartifacts_srcs/Input.java @@ -0,0 +1,16 @@ +/* + * * 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/jvm/analysis/jvm_library/treeartifacts_srcs/Input.kt b/tests/jvm/analysis/jvm_library/treeartifacts_srcs/Input.kt new file mode 100644 index 0000000..963d749 --- /dev/null +++ b/tests/jvm/analysis/jvm_library/treeartifacts_srcs/Input.kt @@ -0,0 +1,17 @@ +/* + * * 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. + */ + + |