aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornickreid <nickreid@google.com>2023-10-13 12:16:05 -0700
committerCopybara-Service <copybara-worker@google.com>2023-10-13 12:16:34 -0700
commit49760f706b966db046a3150bb824e2baeec9ce75 (patch)
tree9dba98b8ff395ce18723c74ebaa07a1d6fb55eae
parent812380ce81d61f43119a767584624ecb3fc8aacd (diff)
downloadbazelbuild-kotlin-rules-49760f706b966db046a3150bb824e2baeec9ce75.tar.gz
Expand jvm_import_test.bzl into BUILD files.
PiperOrigin-RevId: 573288624 Change-Id: I4780f421ec04b7682100c79c8e94ce156e51b8b1
-rw-r--r--copy.bara.sky2
-rw-r--r--kotlin/jvm/testing/jvm_import_analysis_test.bzl39
-rw-r--r--tests/analysis/BUILD3
-rw-r--r--tests/analysis/jvm_import_test.bzl169
-rw-r--r--tests/jvm/analysis/jvm_import/jars/BUILD45
-rw-r--r--tests/jvm/analysis/jvm_import/runtime_deps/BUILD42
-rw-r--r--tests/jvm/analysis/jvm_import/srcjar/BUILD35
7 files changed, 162 insertions, 173 deletions
diff --git a/copy.bara.sky b/copy.bara.sky
index 0535f7d..2954923 100644
--- a/copy.bara.sky
+++ b/copy.bara.sky
@@ -12,4 +12,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
--167606518 \ No newline at end of file
+-685151712 \ No newline at end of file
diff --git a/kotlin/jvm/testing/jvm_import_analysis_test.bzl b/kotlin/jvm/testing/jvm_import_analysis_test.bzl
new file mode 100644
index 0000000..55df268
--- /dev/null
+++ b/kotlin/jvm/testing/jvm_import_analysis_test.bzl
@@ -0,0 +1,39 @@
+# 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.
+
+"""kt_jvm_import_analysis_test"""
+
+load("//:visibility.bzl", "RULES_KOTLIN")
+load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
+
+visibility(RULES_KOTLIN)
+
+kt_jvm_import_analysis_test = analysistest.make(
+ impl = lambda ctx: _kt_jvm_import_analysis_test_impl(ctx),
+ attrs = dict(),
+)
+
+def _kt_jvm_import_analysis_test_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)
diff --git a/tests/analysis/BUILD b/tests/analysis/BUILD
index e066ed1..5d07dd0 100644
--- a/tests/analysis/BUILD
+++ b/tests/analysis/BUILD
@@ -15,11 +15,8 @@
# 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("@bazel_skylib//:bzl_library.bzl", "bzl_library")
licenses(["notice"])
jvm_compile_test_suite(name = "jvm_compile_tests")
-
-jvm_import_test_suite(name = "jvm_import_tests")
diff --git a/tests/analysis/jvm_import_test.bzl b/tests/analysis/jvm_import_test.bzl
deleted file mode 100644
index c297fcc..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("//:visibility.bzl", "RULES_KOTLIN")
-load("//kotlin/common/testing:testing_rules.bzl", "kt_testing_rules")
-load("//kotlin/jvm/testing:for_analysis.bzl", ktfa = "kt_for_analysis")
-load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
-
-visibility(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 = [],
- )
- ktfa.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 = [],
- )
- ktfa.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"],
- )
- ktfa.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 = [],
- )
- ktfa.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 = [],
- )
-
- ktfa.kt_jvm_import(
- name = test_name + "_tut",
- jars = [
- "lib%s_jar.jar" % test_name,
- ],
- proguard_specs = [
- kt_testing_rules.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/jvm/analysis/jvm_import/jars/BUILD b/tests/jvm/analysis/jvm_import/jars/BUILD
new file mode 100644
index 0000000..38b0b62
--- /dev/null
+++ b/tests/jvm/analysis/jvm_import/jars/BUILD
@@ -0,0 +1,45 @@
+# 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", "kt_for_analysis")
+load("//kotlin/jvm/testing:jvm_import_analysis_test.bzl", "kt_jvm_import_analysis_test")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+kt_jvm_import_analysis_test(
+ name = "one_jar_test",
+ target_under_test = kt_for_analysis.kt_jvm_import(
+ name = "one_jar",
+ jars = [
+ kt_testing_rules.create_file(name = "one_jar.jar"),
+ ],
+ ),
+)
+
+kt_jvm_import_analysis_test(
+ name = "many_jar_test",
+ target_under_test = kt_for_analysis.kt_jvm_import(
+ name = "many_jar",
+ jars = [
+ kt_testing_rules.create_file(name = "many_jar_0.jar"),
+ kt_testing_rules.create_file(name = "many_jar_2.jar"),
+ ],
+ ),
+)
diff --git a/tests/jvm/analysis/jvm_import/runtime_deps/BUILD b/tests/jvm/analysis/jvm_import/runtime_deps/BUILD
new file mode 100644
index 0000000..a6692cc
--- /dev/null
+++ b/tests/jvm/analysis/jvm_import/runtime_deps/BUILD
@@ -0,0 +1,42 @@
+# 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", "kt_for_analysis")
+load("//kotlin/jvm/testing:jvm_import_analysis_test.bzl", "kt_jvm_import_analysis_test")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+kt_jvm_import_analysis_test(
+ name = "runtime_deps_test",
+ target_under_test = kt_for_analysis.kt_jvm_import(
+ name = "runtime_deps",
+ jars = [
+ kt_testing_rules.create_file(name = "runtime_deps.jar"),
+ ],
+ runtime_deps = [
+ ":runtime_deps_test_dep",
+ ],
+ ),
+)
+
+kt_for_analysis.java_library(
+ name = "runtime_deps_test_dep",
+ srcs = [],
+)
diff --git a/tests/jvm/analysis/jvm_import/srcjar/BUILD b/tests/jvm/analysis/jvm_import/srcjar/BUILD
new file mode 100644
index 0000000..ea1b23c
--- /dev/null
+++ b/tests/jvm/analysis/jvm_import/srcjar/BUILD
@@ -0,0 +1,35 @@
+# 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", "kt_for_analysis")
+load("//kotlin/jvm/testing:jvm_import_analysis_test.bzl", "kt_jvm_import_analysis_test")
+
+package(
+ default_applicable_licenses = ["//:license"],
+ default_testonly = True,
+)
+
+licenses(["notice"])
+
+kt_jvm_import_analysis_test(
+ name = "has_srcjar_test",
+ target_under_test = kt_for_analysis.kt_jvm_import(
+ name = "has_srcjar",
+ jars = [
+ kt_testing_rules.create_file(name = "has_srcjar.jar"),
+ ],
+ srcjar = kt_testing_rules.create_file(name = "has_srcjar.srcjar"),
+ ),
+)