Merge pull request #26 from hsyed/ci-test-port
Rework the tests for Bazel CI testing.
diff --git a/.bazelproject b/.bazelproject
index 40b4537..ec0f427 100644
--- a/.bazelproject
+++ b/.bazelproject
@@ -18,10 +18,12 @@
targets:
//kotlin/workers:for_ide
+ //:all_tests
//examples/...
test_sources:
*/unittests/*
+ */integrationtests/*
kotlin_language_version: 1.2
diff --git a/BUILD b/BUILD
index 37e64eb..b5351ab 100644
--- a/BUILD
+++ b/BUILD
@@ -10,4 +10,11 @@
# 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
+# limitations under the License.
+test_suite(
+ name = "all_tests",
+ tests = [
+ "//kotlin/workers:unittests",
+ "//tests/integrationtests"
+ ]
+)
\ No newline at end of file
diff --git a/Makefile b/Makefile
index 21b4d4b..2ea059b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,5 @@
test.smoke:
- python -B -m unittest discover -s tests/smoke/ -p '*_tests.py'
- bazel test //kotlin/workers:unittests
+ bazel test all_tests
reformat:
buildifier -mode=fix -v kotlin/*.bzl
diff --git a/examples/dagger/BUILD b/examples/dagger/BUILD
index d3562a4..c68ec8e 100644
--- a/examples/dagger/BUILD
+++ b/examples/dagger/BUILD
@@ -46,4 +46,5 @@
name = "coffee_app",
main_class = "coffee.CoffeeApp",
runtime_deps = [":coffee_lib"],
+ visibility = ["//visibility:public"]
)
diff --git a/tests/integrationtests/BUILD b/tests/integrationtests/BUILD
new file mode 100644
index 0000000..3bb04b7
--- /dev/null
+++ b/tests/integrationtests/BUILD
@@ -0,0 +1,20 @@
+# Copyright 2018 The Bazel Authors. 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.
+test_suite(
+ name = "integrationtests",
+ tests=[
+ "//tests/integrationtests/jvm:basic_tests",
+ "//tests/integrationtests/jvm:annoation_processing_tests",
+ ]
+)
\ No newline at end of file
diff --git a/tests/integrationtests/jvm/BUILD b/tests/integrationtests/jvm/BUILD
new file mode 100644
index 0000000..fe6458f
--- /dev/null
+++ b/tests/integrationtests/jvm/BUILD
@@ -0,0 +1,30 @@
+# Copyright 2018 The Bazel Authors. 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(default_visibility=["//visibility:private"])
+# The tests are written in Kotlin, so the tests inately test a lot of the rule functionality.
+load("//tests/integrationtests/lib:kt_it_assertion_test.bzl", "kt_it_assertion_test")
+
+
+kt_it_assertion_test(
+ name = "basic_tests",
+ cases="//tests/integrationtests/jvm/basic:cases",
+ test_class="io.bazel.ruleskotlin.integrationtests.jvm.JvmBasicIntegrationTests",
+)
+
+kt_it_assertion_test(
+ name = "annoation_processing_tests",
+ cases = "//tests/integrationtests/jvm/kapt:cases",
+ test_class="io.bazel.ruleskotlin.integrationtests.jvm.JvmAnnotationProcessingIntegrationTests",
+ data = [ "//examples/dagger:coffee_app"]
+)
diff --git a/tests/integrationtests/jvm/JvmAnnotationProcessingIntegrationTests.kt b/tests/integrationtests/jvm/JvmAnnotationProcessingIntegrationTests.kt
new file mode 100644
index 0000000..dfee40f
--- /dev/null
+++ b/tests/integrationtests/jvm/JvmAnnotationProcessingIntegrationTests.kt
@@ -0,0 +1,89 @@
+/*
+ * Copyright 2018 The Bazel Authors. 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 io.bazel.ruleskotlin.integrationtests.jvm
+
+import io.bazel.ruleskotlin.integrationtests.lib.AssertionTestCase
+import org.junit.Test
+
+class JvmAnnotationProcessingIntegrationTests : AssertionTestCase("tests/integrationtests/jvm/kapt") {
+ @Test
+ fun kotlinOnly() = withTestCaseJar("ap_kotlin.jar") {
+ assertContainsEntries("tests/smoke/kapt/kotlin/AutoValue_TestKtValue.class")
+ }
+
+ @Test
+ fun noPluginProvided() = withTestCaseJar("ap_kotlin_mixed_no_plugin.jar") {
+ assertDoesNotContainEntries(
+ "tests/smoke/kapt/kotlin/AutoValue_TestKtValue.class",
+ "tests/smoke/kapt/java/TestAutoValue\$Builder.class"
+ )
+ }
+
+ @Test
+ fun mixedMode() = withTestCaseJar("ap_kotlin_mixed.jar") {
+ assertContainsEntries(
+ "tests/smoke/kapt/kotlin/AutoValue_TestKtValue.class",
+ "tests/smoke/kapt/java/TestAutoValue\$Builder.class"
+ )
+ }
+
+ @Test
+ fun withResources() = withTestCaseJar("ap_kotlin_resources.jar") {
+ assertContainsEntries("META-INF/services/tests.smoke.kapt.kotlin.TestKtService")
+ }
+
+ @Test
+ fun mixedModeWithResources() = withTestCaseJar("ap_kotlin_resources_mixed.jar") {
+ assertContainsEntries(
+ "META-INF/services/tests.smoke.kapt.kotlin.TestKtService",
+ "META-INF/services/tests.smoke.kapt.java.TestJavaService"
+ )
+ }
+
+ @Test
+ fun withMultiplePlugins() = withTestCaseJar("ap_kotlin_mixed_multiple_plugins.jar") {
+ assertContainsEntries(
+ "META-INF/services/tests.smoke.kapt.kotlin.TestKtService",
+ "META-INF/services/tests.smoke.kapt.java.TestJavaService",
+ "tests/smoke/kapt/kotlin/AutoValue_TestKtValue.class",
+ "tests/smoke/kapt/java/TestAutoValue\$Builder.class"
+ )
+ }
+
+ @Test
+ fun withMultiplePluginsOneWithoutProcessorClassAttribute() = withTestCaseJar("ap_kotlin_mixed_multiple_plugins_one_without_processor_class.jar") {
+ assertContainsEntries("META-INF/services/tests.smoke.kapt.kotlin.TestKtService", "META-INF/services/tests.smoke.kapt.java.TestJavaService")
+ assertDoesNotContainEntries(
+ "tests/smoke/kapt/java/AutoValue_TestAPNoGenReferences.class",
+ "tests/smoke/kapt/kotlin/AutoValue_TestKtValueNoReferences.class"
+ )
+ }
+
+ @Test
+ fun withTransitivelyInheritedPlugin() = withTestCaseJar("ap_kotlin_mixed_inherit_plugin_via_exported_deps.jar") {
+ assertContainsEntries(
+ "META-INF/services/tests.smoke.kapt.kotlin.TestKtService",
+ "META-INF/services/tests.smoke.kapt.java.TestJavaService",
+ "tests/smoke/kapt/kotlin/AutoValue_TestKtValue.class",
+ "tests/smoke/kapt/java/TestAutoValue\$Builder.class"
+ )
+ }
+
+ @Test
+ fun daggerExampleIsRunnable() {
+ assertExecutableRunfileSucceeds("//examples/dagger/coffee_app")
+ }
+}
\ No newline at end of file
diff --git a/tests/integrationtests/jvm/JvmBasicIntegrationTests.kt b/tests/integrationtests/jvm/JvmBasicIntegrationTests.kt
new file mode 100644
index 0000000..f7da49a
--- /dev/null
+++ b/tests/integrationtests/jvm/JvmBasicIntegrationTests.kt
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2018 The Bazel Authors. 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 io.bazel.ruleskotlin.integrationtests.jvm
+
+import io.bazel.ruleskotlin.integrationtests.lib.AssertionTestCase
+import org.junit.Test
+
+
+class JvmBasicIntegrationTests : AssertionTestCase("tests/integrationtests/jvm/basic") {
+ // Resources tests /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ @Test
+ fun mergeResourceJars() = withTestCaseJar("test_merge_resourcesjar.jar") {
+ assertContainsEntries("testresources/AClass.class", "testresources/BClass.class", "pkg/file.txt")
+ }
+
+ @Test
+ fun embedResources() = withTestCaseJar("test_embed_resources.jar") {
+ assertContainsEntries(
+ "testresources/AClass.class",
+ "testresources/BClass.class",
+ "tests/integrationtests/jvm/basic/testresources/resources/one/alsoAFile.txt",
+ "tests/integrationtests/jvm/basic/testresources/resources/one/two/aFile.txt"
+ )
+ }
+
+ @Test
+ fun resourcesStripPrefix() = withTestCaseJar("test_embed_resources_strip_prefix.jar") {
+ assertContainsEntries("testresources/AClass.class", "testresources/BClass.class", "one/two/aFile.txt", "one/alsoAFile.txt")
+ }
+
+ @Test
+ fun resourcesHaveConventionPathsStripped() = withTestCaseJar("conventional_strip_resources.jar") { assertContainsEntries("main.txt", "test.txt") }
+
+ // Dependency propogation tests ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ @Test
+ fun runtimeDepsArePropogatedViaExport() = assertExecutableRunfileSucceeds("propagation_rt_via_export_consumer")
+
+ @Test
+ fun runtimeDepsArePropogatedTransitively() = assertExecutableRunfileSucceeds("propagation_rt_via_runtime_deps_consumer")
+
+ // Module naming tests /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ @Test
+ fun moduleNameIsDervidedOnBin() = withTestCaseJar("test_module_name_bin.jar") {
+ assertContainsEntries("META-INF/tests_integrationtests_jvm_basic-test_module_name_bin.kotlin_module")
+ }
+
+ @Test
+ fun moduleNameIsUsedOnBin() = withTestCaseJar("test_module_name_attr_bin.jar") {
+ assertContainsEntries("META-INF/hello-module.kotlin_module")
+ }
+}
diff --git a/tests/integrationtests/jvm/basic/BUILD b/tests/integrationtests/jvm/basic/BUILD
new file mode 100644
index 0000000..24a9fcd
--- /dev/null
+++ b/tests/integrationtests/jvm/basic/BUILD
@@ -0,0 +1,111 @@
+# Copyright 2018 The Bazel Authors. 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:kotlin.bzl", "kt_jvm_test", "kt_jvm_library", "kt_jvm_binary")
+
+kt_jvm_binary(
+ name="test_module_name_bin",
+ srcs=glob(["helloworld/Main.kt"]),
+ main_class= "helloworld.Main",
+)
+
+kt_jvm_library(
+ name="test_module_name_attr_bin",
+ srcs=glob(["helloworld/Main.kt"]),
+ module_name = "hello-module"
+)
+
+# a test resource library.
+java_library(
+ name = "resourcejar",
+ resources = glob(["resourcejar/**"]),
+ resource_strip_prefix = "tests/integrationtests/jvm/basic/resourcejar"
+)
+
+kt_jvm_library(
+ name = "test_embed_resources",
+ srcs = glob(["testresources/src/*.kt"]),
+ resources = glob(["testresources/resources/**/*"]),
+ visibility = ["//visibility:public"]
+)
+
+kt_jvm_library(
+ name = "test_merge_resourcesjar",
+ srcs = glob(["testresources/src/*.kt"]),
+ resource_jars = [":resourcejar"],
+ visibility = ["//visibility:public"]
+)
+
+
+kt_jvm_library(
+ name = "test_embed_resources_strip_prefix",
+ srcs = glob(["testresources/src/*.kt"]),
+ resources = glob(["testresources/resources/**/*"]),
+ resource_strip_prefix = "tests/integrationtests/jvm/basic/testresources/resources"
+)
+
+kt_jvm_library(
+ name = "conventional_strip_resources",
+ srcs = glob(["testresources/src/*.kt"]),
+ resources = glob(["conventional_strip_resources/src/main/resources/**/*", "conventional_strip_resources/src/test/resources/**/*"])
+)
+
+kt_jvm_library(
+ name = "propagation_test_exporter_lib",
+ srcs = ["propagation/Stub.kt"],
+ exports = ["@junit_junit//jar"]
+)
+
+kt_jvm_library(
+ name = "propagation_test_runtime_lib",
+ srcs = ["propagation/Stub.kt"],
+ runtime_deps = ["@junit_junit//jar"]
+)
+
+java_binary(
+ name = "propagation_ct_consumer",
+ main_class = "testing.CompileTimeDependent",
+ srcs = ["propagation/CompileTimeDependent.java"],
+ deps = [":propagation_test_exporter_lib"]
+)
+
+java_binary(
+ name = "propagation_rt_via_export_consumer",
+ main_class = "testing.RuntimeDependent",
+ srcs = ["propagation/RuntimeDependent.java"],
+ deps = [":propagation_test_exporter_lib"]
+)
+
+java_binary(
+ name = "propagation_rt_via_runtime_deps_consumer",
+ main_class = "testing.RuntimeDependent",
+ srcs = ["propagation/RuntimeDependent.java"],
+ deps = [":propagation_test_runtime_lib"]
+)
+
+filegroup(
+ name="cases",
+ srcs = [
+ ":test_module_name_bin",
+ ":test_module_name_attr_bin",
+ ":test_embed_resources.jar",
+ ":test_merge_resourcesjar.jar",
+ ":test_embed_resources_strip_prefix.jar",
+ ":test_module_name_bin.jar",
+ ":conventional_strip_resources.jar",
+ ":propagation_ct_consumer",
+ ":propagation_rt_via_export_consumer",
+ ":propagation_rt_via_runtime_deps_consumer"
+ ],
+ visibility=["//tests/integrationtests:__subpackages__"]
+)
diff --git a/tests/smoke/conventional_strip_resources/src/main/resources/main.txt b/tests/integrationtests/jvm/basic/conventional_strip_resources/src/main/resources/main.txt
similarity index 100%
rename from tests/smoke/conventional_strip_resources/src/main/resources/main.txt
rename to tests/integrationtests/jvm/basic/conventional_strip_resources/src/main/resources/main.txt
diff --git a/tests/smoke/conventional_strip_resources/src/test/resources/test.txt b/tests/integrationtests/jvm/basic/conventional_strip_resources/src/test/resources/test.txt
similarity index 100%
rename from tests/smoke/conventional_strip_resources/src/test/resources/test.txt
rename to tests/integrationtests/jvm/basic/conventional_strip_resources/src/test/resources/test.txt
diff --git a/tests/smoke/helloworld/Main.kt b/tests/integrationtests/jvm/basic/helloworld/Main.kt
similarity index 100%
rename from tests/smoke/helloworld/Main.kt
rename to tests/integrationtests/jvm/basic/helloworld/Main.kt
diff --git a/tests/smoke/propagation/CompileTimeDependent.java b/tests/integrationtests/jvm/basic/propagation/CompileTimeDependent.java
similarity index 100%
rename from tests/smoke/propagation/CompileTimeDependent.java
rename to tests/integrationtests/jvm/basic/propagation/CompileTimeDependent.java
diff --git a/tests/smoke/propagation/RuntimeDependent.java b/tests/integrationtests/jvm/basic/propagation/RuntimeDependent.java
similarity index 100%
rename from tests/smoke/propagation/RuntimeDependent.java
rename to tests/integrationtests/jvm/basic/propagation/RuntimeDependent.java
diff --git a/tests/smoke/propagation/Stub.kt b/tests/integrationtests/jvm/basic/propagation/Stub.kt
similarity index 100%
rename from tests/smoke/propagation/Stub.kt
rename to tests/integrationtests/jvm/basic/propagation/Stub.kt
diff --git a/tests/smoke/resourcejar/pkg/file.txt b/tests/integrationtests/jvm/basic/resourcejar/pkg/file.txt
similarity index 100%
rename from tests/smoke/resourcejar/pkg/file.txt
rename to tests/integrationtests/jvm/basic/resourcejar/pkg/file.txt
diff --git a/tests/smoke/testresources/resources/one/alsoAFile.txt b/tests/integrationtests/jvm/basic/testresources/resources/one/alsoAFile.txt
similarity index 100%
rename from tests/smoke/testresources/resources/one/alsoAFile.txt
rename to tests/integrationtests/jvm/basic/testresources/resources/one/alsoAFile.txt
diff --git a/tests/smoke/testresources/resources/one/two/aFile.txt b/tests/integrationtests/jvm/basic/testresources/resources/one/two/aFile.txt
similarity index 100%
rename from tests/smoke/testresources/resources/one/two/aFile.txt
rename to tests/integrationtests/jvm/basic/testresources/resources/one/two/aFile.txt
diff --git a/tests/smoke/testresources/src/AClass.kt b/tests/integrationtests/jvm/basic/testresources/src/AClass.kt
similarity index 100%
rename from tests/smoke/testresources/src/AClass.kt
rename to tests/integrationtests/jvm/basic/testresources/src/AClass.kt
diff --git a/tests/integrationtests/jvm/kapt/BUILD b/tests/integrationtests/jvm/kapt/BUILD
new file mode 100644
index 0000000..b20b33a
--- /dev/null
+++ b/tests/integrationtests/jvm/kapt/BUILD
@@ -0,0 +1,114 @@
+# Copyright 2018 The Bazel Authors. 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(default_visibility=["//visibility:private"])
+load("//kotlin:kotlin.bzl", "kt_jvm_library")
+
+java_plugin(
+ name = "autovalue",
+ deps = ["@autovalue//jar"],
+ processor_class = "com.google.auto.value.processor.AutoValueProcessor",
+ generates_api = 1,
+)
+
+java_plugin(
+ name = "autoservice",
+ deps = [
+ "@autoservice//jar",
+ "@guava//jar",
+ "@auto_common//jar"
+ ],
+ processor_class = "com.google.auto.service.processor.AutoServiceProcessor",
+ generates_api = 0
+)
+
+java_plugin(
+ name = "autovalue_no_processor_class",
+ deps = ["@autovalue//jar"],
+ generates_api = 1,
+)
+
+kt_jvm_library(
+ name = "ap_kotlin",
+ srcs = ["kotlin/TestKtValue.kt"],
+ deps = ["@autovalue//jar"],
+ plugins = [":autovalue"]
+)
+
+kt_jvm_library(
+ name = "ap_kotlin_mixed_no_plugin",
+ srcs = ["kotlin/TestKtAPNoGenReference.kt", "java/TestAPNoGenReferences.java"],
+ deps = ["@autovalue//jar"]
+)
+
+kt_jvm_library(
+ name = "ap_kotlin_mixed",
+ srcs = ["kotlin/TestKtValue.kt", "java/TestAutoValue.java"],
+ deps = ["@autovalue//jar"],
+ plugins = [":autovalue"]
+)
+
+kt_jvm_library(
+ name = "ap_kotlin_resources",
+ srcs = ["kotlin/TestKtService.kt"],
+ deps = ["@autoservice//jar"],
+ plugins = [":autoservice"]
+)
+
+kt_jvm_library(
+ name = "ap_kotlin_resources_mixed",
+ srcs = ["kotlin/TestKtService.kt", "java/TestJavaService.java"],
+ deps = ["@autoservice//jar"],
+ plugins = [":autoservice"]
+)
+
+kt_jvm_library(
+ name = "ap_kotlin_mixed_multiple_plugins",
+ srcs = ["kotlin/TestKtService.kt", "java/TestJavaService.java", "java/TestAutoValue.java", "kotlin/TestKtValue.kt"],
+ deps = ["@autoservice//jar", "@autovalue//jar"],
+ plugins = [":autoservice", ":autovalue"]
+)
+
+kt_jvm_library(
+ name = "ap_kotlin_mixed_multiple_plugins_one_without_processor_class",
+ srcs = ["kotlin/TestKtService.kt", "java/TestJavaService.java", "java/TestAPNoGenReferences.java", "kotlin/TestKtAPNoGenReference.kt"],
+ deps = ["@autoservice//jar", "@autovalue//jar"],
+ plugins = [":autoservice", ":autovalue_no_processor_class"]
+)
+
+java_library(
+ name = "library_exporting_autovalue_and_junit",
+ exported_plugins = [":autovalue", ":autoservice"],
+)
+
+kt_jvm_library(
+ name = "ap_kotlin_mixed_inherit_plugin_via_exported_deps",
+ srcs = ["kotlin/TestKtService.kt", "java/TestJavaService.java", "java/TestAutoValue.java", "kotlin/TestKtValue.kt"],
+ deps = ["@autoservice//jar", "@autovalue//jar", "library_exporting_autovalue_and_junit"],
+ plugins = [":autovalue"]
+)
+
+filegroup(
+ name = "cases",
+ srcs = [
+ ":ap_kotlin.jar",
+ ":ap_kotlin_mixed_no_plugin",
+ ":ap_kotlin_mixed",
+ ":ap_kotlin_resources",
+ ":ap_kotlin_resources_mixed",
+ ":ap_kotlin_mixed_multiple_plugins",
+ ":ap_kotlin_mixed_multiple_plugins_one_without_processor_class",
+ ":ap_kotlin_mixed_inherit_plugin_via_exported_deps",
+ ],
+ visibility=["//tests/integrationtests:__subpackages__"]
+)
\ No newline at end of file
diff --git a/tests/smoke/kapt/java/TestAPNoGenReferences.java b/tests/integrationtests/jvm/kapt/java/TestAPNoGenReferences.java
similarity index 100%
rename from tests/smoke/kapt/java/TestAPNoGenReferences.java
rename to tests/integrationtests/jvm/kapt/java/TestAPNoGenReferences.java
diff --git a/tests/smoke/kapt/java/TestAutoValue.java b/tests/integrationtests/jvm/kapt/java/TestAutoValue.java
similarity index 100%
rename from tests/smoke/kapt/java/TestAutoValue.java
rename to tests/integrationtests/jvm/kapt/java/TestAutoValue.java
diff --git a/tests/smoke/kapt/java/TestJavaService.java b/tests/integrationtests/jvm/kapt/java/TestJavaService.java
similarity index 100%
rename from tests/smoke/kapt/java/TestJavaService.java
rename to tests/integrationtests/jvm/kapt/java/TestJavaService.java
diff --git a/tests/smoke/kapt/kotlin/TestKtAPNoGenReference.kt b/tests/integrationtests/jvm/kapt/kotlin/TestKtAPNoGenReference.kt
similarity index 100%
rename from tests/smoke/kapt/kotlin/TestKtAPNoGenReference.kt
rename to tests/integrationtests/jvm/kapt/kotlin/TestKtAPNoGenReference.kt
diff --git a/tests/smoke/kapt/kotlin/TestKtService.kt b/tests/integrationtests/jvm/kapt/kotlin/TestKtService.kt
similarity index 100%
rename from tests/smoke/kapt/kotlin/TestKtService.kt
rename to tests/integrationtests/jvm/kapt/kotlin/TestKtService.kt
diff --git a/tests/smoke/kapt/kotlin/TestKtValue.kt b/tests/integrationtests/jvm/kapt/kotlin/TestKtValue.kt
similarity index 100%
rename from tests/smoke/kapt/kotlin/TestKtValue.kt
rename to tests/integrationtests/jvm/kapt/kotlin/TestKtValue.kt
diff --git a/tests/integrationtests/lib/AssertionTestCase.kt b/tests/integrationtests/lib/AssertionTestCase.kt
new file mode 100644
index 0000000..a1baf36
--- /dev/null
+++ b/tests/integrationtests/lib/AssertionTestCase.kt
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2018 The Bazel Authors. 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 io.bazel.ruleskotlin.integrationtests.lib
+
+import java.io.File
+import java.nio.file.Path
+import java.nio.file.Paths
+import java.util.concurrent.TimeUnit
+import java.util.jar.JarFile
+
+abstract class AssertionTestCase(root: String) {
+ private val testRunfileRoot: Path = Paths.get(root).also {
+ it.toFile().also {
+ assert(it.exists()) { "runfile directory $root does not exist" }
+ assert(it.isDirectory) { "runfile directory $root is not a directory" }
+ }
+ }
+
+ private fun testCaseJar(jarName: String) = testRunfileRoot.resolve(jarName).toFile().let {
+ check(it.exists()) { "jar $jarName did not exist in test case root $testRunfileRoot" }
+ JarFile(it)
+ }
+
+ protected fun withTestCaseJar(name: String, op: JarFile.() -> Unit) {
+ testCaseJar(name).also { op(it) }
+ }
+
+ protected fun JarFile.assertContainsEntries(vararg entries: String) {
+ entries.forEach { assert(this.getJarEntry(it) != null) { "jar ${this.name} did not contain entry $it" } }
+ }
+
+ protected fun JarFile.assertDoesNotContainEntries(vararg entries: String) {
+ entries.forEach { assert(this.getJarEntry(it) == null) { "jar ${this.name} contained entry $it" } }
+ }
+
+ private fun String.resolveDirectory(): File =
+ if (startsWith("/"))
+ trimStart('/').split("/").let { File(it.take(it.size - 1).joinToString(File.separator)) }
+ else
+ testRunfileRoot.toFile()
+
+ protected fun assertExecutableRunfileSucceeds(executable: String) {
+ ProcessBuilder().command("bash", "-c", Paths.get(executable).fileName.toString())
+ .also { it.directory(executable.resolveDirectory()) }
+ .start().let {
+ it.waitFor(5, TimeUnit.SECONDS)
+ assert(it.exitValue() == 0) { "non-zero status code: ${it.exitValue()}" }
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/integrationtests/lib/BUILD b/tests/integrationtests/lib/BUILD
new file mode 100644
index 0000000..072083d
--- /dev/null
+++ b/tests/integrationtests/lib/BUILD
@@ -0,0 +1,23 @@
+# Copyright 2018 The Bazel Authors. 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(default_visibility=["//tests/integrationtests:__subpackages__"])
+load("//kotlin:kotlin.bzl", "kt_jvm_library")
+
+kt_jvm_library(
+ name = "lib",
+ srcs = ["AssertionTestCase.kt"],
+ visibility=["//tests/integrationtests:__subpackages__"],
+ deps=["@com_github_jetbrains_kotlin//:kotlin-test"],
+ testonly=1
+)
\ No newline at end of file
diff --git a/tests/integrationtests/lib/kt_it_assertion_test.bzl b/tests/integrationtests/lib/kt_it_assertion_test.bzl
new file mode 100644
index 0000000..1361109
--- /dev/null
+++ b/tests/integrationtests/lib/kt_it_assertion_test.bzl
@@ -0,0 +1,25 @@
+# Copyright 2018 The Bazel Authors. 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:kotlin.bzl", "kt_jvm_test")
+
+def kt_it_assertion_test(name, cases, test_class, data = [], deps=[]):
+ parts=test_class.split(".")
+ kt_jvm_test(
+ name=name,
+ srcs=["%s.kt" % parts[len(parts)-1]],
+ deps = ["//tests/integrationtests/lib:lib", "@junit_junit//jar"] + deps,
+ test_class=test_class,
+ data=[cases] + data,
+ visibility=["//visibility:private"]
+ )
\ No newline at end of file
diff --git a/tests/smoke/BUILD b/tests/smoke/BUILD
deleted file mode 100644
index 3d61449..0000000
--- a/tests/smoke/BUILD
+++ /dev/null
@@ -1,214 +0,0 @@
-# Copyright 2018 The Bazel Authors. 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:kotlin.bzl", "kt_jvm_library", "kt_jvm_binary", "kt_jvm_test")
-
-# a test resource library.
-java_library(
- name = "resourcejar",
- resources = glob(["resourcejar/**"]),
- resource_strip_prefix = "tests/smoke/resourcejar"
-)
-
-kt_jvm_test(
- name = "junittest",
- srcs = glob(["junittest/JunitTest.kt"]),
- test_class="tests.smoke.junittest.JunitTest",
- size="small",
- data=glob(["data/*"]),
- deps = ["@junit_junit//jar"]
-)
-
-kt_jvm_library(
- name = "test_merge_resourcesjar",
- srcs = glob(["testresources/src/*.kt"]),
- resource_jars = [":resourcejar"],
-)
-
-kt_jvm_library(
- name = "test_embed_resources",
- srcs = glob(["testresources/src/*.kt"]),
- resources = glob(["testresources/resources/**/*"]),
- visibility = ["//visibility:public"]
-)
-
-kt_jvm_library(
- name = "test_embed_resources_strip_prefix",
- srcs = glob(["testresources/src/*.kt"]),
- resources = glob(["testresources/resources/**/*"]),
- resource_strip_prefix = "tests/smoke/testresources/resources"
-)
-
-kt_jvm_library(
- name = "conventional_strip_resources",
- srcs = glob(["testresources/src/*.kt"]),
- resources = glob(["conventional_strip_resources/src/main/resources/**/*", "conventional_strip_resources/src/test/resources/**/*"])
-)
-
-kt_jvm_library(
- name = "propagation_test_exporter_lib",
- srcs = ["propagation/Stub.kt"],
- exports = ["@junit_junit//jar"]
-)
-
-kt_jvm_library(
- name = "propagation_test_runtime_lib",
- srcs = ["propagation/Stub.kt"],
- runtime_deps = ["@junit_junit//jar"]
-)
-
-java_binary(
- name = "propagation_ct_consumer",
- main_class = "testing.CompileTimeDependent",
- srcs = ["propagation/CompileTimeDependent.java"],
- deps = [":propagation_test_exporter_lib"]
-)
-
-java_binary(
- name = "propagation_ct_consumer_fail_on_runtime",
- main_class = "testing.CompileTimeDependent",
- srcs = ["propagation/CompileTimeDependent.java"],
- deps = [":propagation_test_runtime_lib"],
- tags = ["manual"]
-)
-
-java_binary(
- name = "propagation_rt_via_export_consumer",
- main_class = "testing.RuntimeDependent",
- srcs = ["propagation/RuntimeDependent.java"],
- deps = [":propagation_test_exporter_lib"]
-)
-
-java_binary(
- name = "propagation_rt_via_runtime_deps_consumer",
- main_class = "testing.RuntimeDependent",
- srcs = ["propagation/RuntimeDependent.java"],
- deps = [":propagation_test_runtime_lib"]
-)
-
-kt_jvm_binary(
- name="helloworld",
- srcs=glob(["helloworld/Main.kt"]),
- main_class= "helloworld.Main",
- data=glob(["data/*"]),
-)
-
-kt_jvm_library(
- name="modulename",
- srcs=glob(["helloworld/Main.kt"]),
- module_name = "hello-module"
-)
-
-genrule(
- name="helloworld_host_config_test",
- tools=["//tests/smoke:helloworld"],
- outs=["helloworld_output.txt"],
- cmd = """./$(location //tests/smoke:helloworld) > "$@" """
-)
-
-kt_jvm_library(
- name = "hellojava",
- srcs = glob(["hellojava/*.kt", "hellojava/*.java"]),
-)
-
-kt_jvm_library(
- name = "hellojava_withmerge",
- resources = glob(["resourcejar/**"]),
- srcs = glob(["hellojava/*.kt", "hellojava/*.java"]),
-)
-
-java_plugin(
- name = "autovalue",
- deps = ["@autovalue//jar"],
- processor_class = "com.google.auto.value.processor.AutoValueProcessor",
- generates_api = 1,
-)
-
-java_plugin(
- name = "autoservice",
- deps = [
- "@autoservice//jar",
- "@guava//jar",
- "@auto_common//jar"
- ],
- processor_class = "com.google.auto.service.processor.AutoServiceProcessor",
- generates_api = 0
-)
-
-java_plugin(
- name = "autovalue_no_processor_class",
- deps = ["@autovalue//jar"],
- generates_api = 1,
-)
-
-kt_jvm_library(
- name = "ap_kotlin",
- srcs = ["kapt/kotlin/TestKtValue.kt"],
- deps = ["@autovalue//jar"],
- plugins = [":autovalue"]
-)
-
-kt_jvm_library(
- name = "ap_kotlin_mixed_no_plugin",
- srcs = ["kapt/kotlin/TestKtAPNoGenReference.kt", "kapt/java/TestAPNoGenReferences.java"],
- deps = ["@autovalue//jar"]
-)
-
-kt_jvm_library(
- name = "ap_kotlin_mixed",
- srcs = ["kapt/kotlin/TestKtValue.kt", "kapt/java/TestAutoValue.java"],
- deps = ["@autovalue//jar"],
- plugins = [":autovalue"]
-)
-
-kt_jvm_library(
- name = "ap_kotlin_resources",
- srcs = ["kapt/kotlin/TestKtService.kt"],
- deps = ["@autoservice//jar"],
- plugins = [":autoservice"]
-)
-
-kt_jvm_library(
- name = "ap_kotlin_resources_mixed",
- srcs = ["kapt/kotlin/TestKtService.kt", "kapt/java/TestJavaService.java"],
- deps = ["@autoservice//jar"],
- plugins = [":autoservice"]
-)
-
-kt_jvm_library(
- name = "ap_kotlin_mixed_multiple_plugins",
- srcs = ["kapt/kotlin/TestKtService.kt", "kapt/java/TestJavaService.java", "kapt/java/TestAutoValue.java", "kapt/kotlin/TestKtValue.kt"],
- deps = ["@autoservice//jar", "@autovalue//jar"],
- plugins = [":autoservice", ":autovalue"]
-)
-
-kt_jvm_library(
- name = "ap_kotlin_mixed_multiple_plugins_one_without_processor_class",
- srcs = ["kapt/kotlin/TestKtService.kt", "kapt/java/TestJavaService.java", "kapt/java/TestAPNoGenReferences.java", "kapt/kotlin/TestKtAPNoGenReference.kt"],
- deps = ["@autoservice//jar", "@autovalue//jar"],
- plugins = [":autoservice", ":autovalue_no_processor_class"]
-)
-
-java_library(
- name = "library_exporting_autovalue_and_junit",
- exported_plugins = [":autovalue", ":autoservice"],
-)
-
-kt_jvm_library(
- name = "ap_kotlin_mixed_inherit_plugin_via_exported_deps",
- srcs = ["kapt/kotlin/TestKtService.kt", "kapt/java/TestJavaService.java", "kapt/java/TestAutoValue.java", "kapt/kotlin/TestKtValue.kt"],
- deps = ["@autoservice//jar", "@autovalue//jar", "library_exporting_autovalue_and_junit"],
- plugins = [":autovalue"]
-)
-
-
diff --git a/tests/smoke/annotation_processing_tests.py b/tests/smoke/annotation_processing_tests.py
deleted file mode 100644
index 7e6786f..0000000
--- a/tests/smoke/annotation_processing_tests.py
+++ /dev/null
@@ -1,136 +0,0 @@
-# Copyright 2018 The Bazel Authors. 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.
-import json
-import unittest
-
-from common import BazelKotlinTestCase
-
-_auto_value_processor_entry = {
- "label": "//tests/smoke:autovalue",
- "processor_class": "com.google.auto.value.processor.AutoValueProcessor",
- "classpath": ["external/autovalue/jar/auto-value-1.5.jar"],
- "generates_api": True
-}
-
-_auto_service_processor_entry = {
- 'label': '//tests/smoke:autoservice',
- 'classpath': [
- 'external/autoservice/jar/auto-service-1.0-rc4.jar',
- 'external/guava/jar/guava-24.0-jre.jar',
- 'external/auto_common/jar/auto-common-0.10.jar'
- ],
- 'processor_class': 'com.google.auto.service.processor.AutoServiceProcessor',
- 'generates_api': False,
-}
-
-
-class PluginAspectRendering(BazelKotlinTestCase):
- def test_annotation_processing(self):
- """Annotation processing should occur for Kotlin files when a java_plugin is provided."""
- jar = self.buildJarGetZipFile("ap_kotlin", "jar", silent=False)
- worker_args = self.getWorkerArgsMap()
- self.assertIn("--kt-plugins", worker_args)
- self.assertDictContainsSubset({
- "processors": [_auto_value_processor_entry]
- }, json.loads(worker_args["--kt-plugins"]))
- self.assertJarContains(
- jar,
- "tests/smoke/kapt/kotlin/AutoValue_TestKtValue.class"
- )
-
- def test_annotation_processing_no_plugin_provided(self):
- """If no plugins are provided in the rule annotation processing should not occur."""
- jar = self.buildJarGetZipFile("ap_kotlin_mixed_no_plugin", "jar")
- worker_args = self.getWorkerArgsMap()
- self.assertNotIn("--kt-plguins", worker_args)
- self.assertJarDoesNotContain(
- jar,
- "tests/smoke/kapt/kotlin/AutoValue_TestKtValue.class",
- "tests/smoke/kapt/java/TestAutoValue$Builder.class"
- )
-
- def test_annotation_processing_mixed(self):
- """If plugins are provided for a mixed mode library annotation processing should occur for both Kotlin and Java files."""
- jar = self.buildJarGetZipFile("ap_kotlin_mixed", "jar", silent=False)
- self.assertJarContains(
- jar,
- "tests/smoke/kapt/kotlin/AutoValue_TestKtValue.class",
- "tests/smoke/kapt/java/TestAutoValue$Builder.class"
- )
-
- def test_annotation_processing_with_resources(self):
- """If a plugin generating resources is provided it's resources should be embedded in the jar."""
- jar = self.buildJarGetZipFile("ap_kotlin_resources", "jar")
- self.assertJarContains(
- jar,
- "META-INF/services/tests.smoke.kapt.kotlin.TestKtService"
- )
-
- def test_annotation_processing_with_resources_mixed(self):
- """If a plugin generating resources is provided for a mixed mode library resources shsould be embedded in the jar for both Kotlin and Java Files."""
- jar = self.buildJarGetZipFile("ap_kotlin_resources_mixed", "jar")
- self.assertJarContains(
- jar,
- "META-INF/services/tests.smoke.kapt.kotlin.TestKtService",
- "META-INF/services/tests.smoke.kapt.java.TestJavaService"
- )
-
- def test_annotation_processing_with_mutliple_plugins_mixed(self):
- """Annotation processing should work for multiple plugins."""
- jar = self.buildJarGetZipFile("ap_kotlin_mixed_multiple_plugins", "jar")
- self.assertJarContains(
- jar,
- "META-INF/services/tests.smoke.kapt.kotlin.TestKtService",
- "META-INF/services/tests.smoke.kapt.java.TestJavaService",
- "tests/smoke/kapt/kotlin/AutoValue_TestKtValue.class",
- "tests/smoke/kapt/java/TestAutoValue$Builder.class"
- )
-
- def test_annotation_processing_with_mutliple_plugins_mixed_one_without_processor_class(self):
- """Annotation processing should not trigger for plugins which do not provide a java processor class."""
- jar = self.buildJarGetZipFile("ap_kotlin_mixed_multiple_plugins_one_without_processor_class", "jar")
- self.assertJarContains(
- jar,
- "META-INF/services/tests.smoke.kapt.kotlin.TestKtService",
- "META-INF/services/tests.smoke.kapt.java.TestJavaService",
- )
- self.assertJarDoesNotContain(
- jar,
- "tests/smoke/kapt/java/AutoValue_TestAPNoGenReferences.class",
- "tests/smoke/kapt/kotlin/AutoValue_TestKtValueNoReferences.class"
- )
-
- def test_annotation_processing_with_multiple_plugins_inherit_exported_plugin(self):
- """Annotation processing should work when a plugin is inherited from another library via expoted_plugins, and plugins should not be counted twice."""
- jar = self.buildJarGetZipFile("ap_kotlin_mixed_inherit_plugin_via_exported_deps", "jar")
- worker_args = self.getWorkerArgsMap()
- self.assertIn("--kt-plugins", worker_args)
- self.assertDictContainsSubset({
- "processors": [_auto_value_processor_entry, _auto_service_processor_entry]
- }, json.loads(worker_args["--kt-plugins"]))
- self.assertJarContains(
- jar,
- "META-INF/services/tests.smoke.kapt.kotlin.TestKtService",
- "META-INF/services/tests.smoke.kapt.java.TestJavaService",
- "tests/smoke/kapt/kotlin/AutoValue_TestKtValue.class",
- "tests/smoke/kapt/java/TestAutoValue$Builder.class"
- )
-
- def test_annotation_processing_compile_and_run_kapt_example(self):
- """A Self contained example annotation processing package should compile and launch without errors."""
- self.buildLaunchExpectingSuccess("//examples/dagger:coffee_app")
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/tests/smoke/basic_tests.py b/tests/smoke/basic_tests.py
deleted file mode 100644
index f9b1d5f..0000000
--- a/tests/smoke/basic_tests.py
+++ /dev/null
@@ -1,93 +0,0 @@
-# Copyright 2018 The Bazel Authors. 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.
-import unittest
-
-from common import BazelKotlinTestCase
-
-
-class TestRules(BazelKotlinTestCase):
- def test_merge_resource_jar(self):
- jar = self.buildJarGetZipFile("test_merge_resourcesjar", "jar")
- self.assertJarContains(jar, "testresources/AClass.class", "testresources/BClass.class")
- self.assertJarContains(jar, "pkg/file.txt")
-
- def test_embed_resources(self):
- jar = self.buildJarGetZipFile("test_embed_resources", "jar")
- self.assertJarContains(jar, "testresources/AClass.class", "testresources/BClass.class")
- self.assertJarContains(jar, "tests/smoke/testresources/resources/one/two/aFile.txt", "tests/smoke/testresources/resources/one/alsoAFile.txt")
-
- def test_embed_resources_strip_prefix(self):
- jar = self.buildJarGetZipFile("test_embed_resources_strip_prefix", "jar")
- self.assertJarContains(jar, "testresources/AClass.class", "testresources/BClass.class")
- self.assertJarContains(jar, "one/two/aFile.txt", "one/alsoAFile.txt")
-
- def test_test_targets_launch_correctly(self):
- self.buildLaunchExpectingSuccess("junittest", command="test")
-
- def test_bin_targets_launch_correctly_with_data(self):
- self.buildLaunchExpectingSuccess("helloworld")
-
- def test_uses_target_name_as_default_module_name(self):
- """tests that the target name is used as the default module name."""
- jar = self.buildJarGetZipFile("helloworld", "jar")
- self.assertJarContains(jar, "META-INF/tests_smoke-helloworld.kotlin_module")
-
- def test_module_name_is_used_if_provided(self):
- """tests that the target name is used as the default module name."""
- jar = self.buildJarGetZipFile("modulename", "jar")
- self.assertJarContains(jar, "META-INF/hello-module.kotlin_module")
-
- def test_conventional_strip_resources(self):
- jar = self.buildJarGetZipFile("conventional_strip_resources", "jar")
- self.assertJarContains(jar, "main.txt", "test.txt")
-
- def test_export_ct_propagation(self):
- self.build("propagation_ct_consumer")
-
- def test_export_ct_propagation_fail_on_runtime(self):
- self.buildJarExpectingFail("propagation_ct_consumer_fail_on_runtime")
-
- def test_export_rt_propagation(self):
- self.buildLaunchExpectingSuccess("propagation_rt_via_export_consumer")
-
- def test_export_rt_propagation_via_dep(self):
- self.buildLaunchExpectingSuccess("propagation_rt_via_runtime_deps_consumer")
-
-
-class MixedModeCompilation(BazelKotlinTestCase):
- def test_mixed_mode_compilation(self):
- jar = self.buildJarGetZipFile("hellojava", "jar")
-
- self.assertJarContains(
- jar,
- "hellojava/HelloWorldJava.class",
- "hellojava/MessageHolderKotlin.class",
- "hellojava/MessageHolder.class",
- "hellojava/HelloWorldKt.class"
- )
-
- def test_mixed_mode_compilation_with_merge(self):
- jar = self.buildJarGetZipFile("hellojava_withmerge", "jar")
- self.assertJarContains(
- jar,
- "hellojava/HelloWorldJava.class",
- "hellojava/MessageHolderKotlin.class",
- "hellojava/MessageHolder.class",
- "hellojava/HelloWorldKt.class",
- "tests/smoke/resourcejar/pkg/file.txt"
- )
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/tests/smoke/common.py b/tests/smoke/common.py
deleted file mode 100644
index cce3f81..0000000
--- a/tests/smoke/common.py
+++ /dev/null
@@ -1,126 +0,0 @@
-# Copyright 2018 The Bazel Authors. 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.
-import os
-import subprocess
-import sys
-import unittest
-import zipfile
-
-DEVNULL = open(os.devnull, 'wb')
-
-
-def _do_exec(command, ignore_error=False, silent=True):
- if silent:
- retcode = subprocess.call(command, stdout=DEVNULL, stderr=DEVNULL)
- else:
- retcode = subprocess.call(command)
- if retcode != 0 and not ignore_error:
- raise Exception("command " + " ".join(command) + " failed")
-
-
-def _do_exec_expect_fail(command, silent=True):
- if silent:
- retcode = subprocess.call(command, stdout=DEVNULL, stderr=DEVNULL)
- else:
- retcode = subprocess.call(command)
- if retcode == 0:
- raise Exception("command " + " ".join(command) + " should have failed")
-
-
-class BazelKotlinTestCase(unittest.TestCase):
- _pkg = None
- _last_built_target = ""
-
- def __init__(self, methodName='runTest'):
- super(BazelKotlinTestCase, self).__init__(methodName)
- os.chdir(subprocess.check_output(["bazel", "info", "workspace"]).replace("\n", ""))
- self._pkg = os.path.dirname(os.path.relpath(sys.modules[self.__module__].__file__))
-
- def _target(self, target_name):
- if target_name.startswith("//"):
- return target_name
- else:
- return "//%s:%s" % (self._pkg, target_name)
-
- def _bazel_bin(self, file):
- return "bazel-bin/" + self._pkg + "/" + file
-
- def _open_bazel_bin(self, file):
- return open(self._bazel_bin(file))
-
- def _query(self, query, implicits=False):
- res = []
- q = ['bazel', 'query', query]
- if not implicits:
- q.append('--noimplicit_deps')
- self._last_command = " ".join(q)
-
- p = subprocess.Popen(self._last_command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- for line in p.stdout.readlines():
- res.append(line.replace("\n", ""))
- ret = p.wait()
- if ret != 0:
- raise Exception("error (%d) evaluating query: %s" % (ret, self._last_command))
- else:
- return res
-
- def libQuery(self, label, implicits=False):
- return self._query('\'kind("java_import|.*_library", deps(%s))\'' % label, implicits)
-
- def assertJarContains(self, jar, *files):
- curr = ""
- try:
- for f in files:
- curr = f
- jar.getinfo(f)
- except Exception as ex:
- self.fail("jar does not contain file [%s]" % curr)
-
- def assertJarDoesNotContain(self, jar, *files):
- tally = {}
- for n in jar.namelist():
- tally[n] = True
- for f in files:
- self.assertNotIn(f, tally, "jar should not contain file " + f)
-
- def build(self, target, ignore_error=False, silent=True):
-
- _do_exec(["bazel", "build", self._target(target)], ignore_error, silent)
-
- def getWorkerArgsMap(self):
- arg_map = {}
- key = None
- for line in self._open_bazel_bin(self._last_built_target + "-worker.args"):
- line = line.rstrip("\n")
- if not key:
- key = line
- else:
- arg_map[key] = line
- key = None
- return arg_map
-
- def buildJarExpectingFail(self, target, silent=True):
- self._last_built_target = target
- _do_exec_expect_fail(["bazel", "build", self._target(target)], silent)
-
- def buildJarGetZipFile(self, target, extension, silent=True):
- jar_file = target + "." + extension
- self._last_built_target = target
- self.build(jar_file, silent=silent)
- return zipfile.ZipFile(self._open_bazel_bin(jar_file))
-
- def buildLaunchExpectingSuccess(self, target, command="run", ignore_error=False, silent=True):
- self._last_built_target = target
- self.build(target, silent)
- _do_exec(["bazel", command, self._target(target)], ignore_error=ignore_error, silent=silent)
diff --git a/tests/smoke/data/datafile.txt b/tests/smoke/data/datafile.txt
deleted file mode 100644
index 2e166c8..0000000
--- a/tests/smoke/data/datafile.txt
+++ /dev/null
@@ -1 +0,0 @@
-boom
\ No newline at end of file
diff --git a/tests/smoke/hellojava/HelloWorld.kt b/tests/smoke/hellojava/HelloWorld.kt
deleted file mode 100644
index 3004b28..0000000
--- a/tests/smoke/hellojava/HelloWorld.kt
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2018 The Bazel Authors. 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 hellojava
-
-fun main(args: Array<String>) {
- println(MessageHolder.message)
-}
diff --git a/tests/smoke/hellojava/HelloWorldJava.java b/tests/smoke/hellojava/HelloWorldJava.java
deleted file mode 100644
index 4aae5ae..0000000
--- a/tests/smoke/hellojava/HelloWorldJava.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2018 The Bazel Authors. 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 hellojava;
-
-public class HelloWorldJava {
- public static void main(String[] args) {
- System.out.println(MessageHolderKotlin.INSTANCE.hello());
- }
-}
diff --git a/tests/smoke/hellojava/MessageHolder.java b/tests/smoke/hellojava/MessageHolder.java
deleted file mode 100644
index 510680f..0000000
--- a/tests/smoke/hellojava/MessageHolder.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2018 The Bazel Authors. 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 hellojava;
-
-public class MessageHolder {
- public static final String message = "hello java ";
- static {
- System.out.println("boom la ");
- }
-}
diff --git a/tests/smoke/hellojava/MessageHolderKotlin.kt b/tests/smoke/hellojava/MessageHolderKotlin.kt
deleted file mode 100644
index d7e5112..0000000
--- a/tests/smoke/hellojava/MessageHolderKotlin.kt
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2018 The Bazel Authors. 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 hellojava
-
-object MessageHolderKotlin {
- fun hello() = "hello from kotlin"
-}
\ No newline at end of file
diff --git a/tests/smoke/junittest/JunitTest.kt b/tests/smoke/junittest/JunitTest.kt
deleted file mode 100644
index 84329e0..0000000
--- a/tests/smoke/junittest/JunitTest.kt
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright 2018 The Bazel Authors. 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 tests.smoke.junittest
-
-import org.junit.*
-import org.junit.runner.RunWith
-import org.junit.runners.JUnit4
-import org.junit.runners.Suite
-import java.nio.file.Paths
-
-
-@RunWith(JUnit4::class)
-class JunitTest {
- @Test
- fun dummyTest() {
- if(!Paths.get("tests", "smoke", "data" ,"datafile.txt").toFile().exists()) {
- throw RuntimeException("could not read datafile")
- }
- }
-}