consolate all srcs under src
diff --git a/.bazelproject b/.bazelproject
index af125c4..b5daf79 100644
--- a/.bazelproject
+++ b/.bazelproject
@@ -26,15 +26,14 @@
//examples/dagger/...
# These targets are built for the ide only. Primary purpose is to ensure the builder can build the targets, but it's
# also a good way of testing the intellij plugin.
- //kotlin/builder/src/io/bazel/kotlin/builder:builder_kt_for_ide
- //kotlin/builder:compiler_lib_for_ide
+ //src/main/kotlin/io/bazel/kotlin/builder:builder_kt_for_ide
+ //src/main/kotlin:compiler_lib_for_ide
test_sources:
- */unittests/*
- */integrationtests/*
+ src/test/*
additional_languages:
kotlin
import_run_configurations:
- tests/Bazel_all_local_tests.xml
\ No newline at end of file
+ src/test/Bazel_all_local_tests.xml
\ No newline at end of file
diff --git a/BUILD b/BUILD
index ed426b9..d8637e6 100644
--- a/BUILD
+++ b/BUILD
@@ -16,9 +16,8 @@
test_suite(
name = "all_tests",
tests = [
- "//kotlin/builder/integrationtests",
- "//kotlin/builder/unittests",
- "//tests/integrationtests",
+ "//src/test/kotlin/io/bazel/kotlin:assertion_tests",
+ "//src/test/kotlin/io/bazel/kotlin/builder:builder_tests",
],
)
@@ -27,6 +26,6 @@
name = "all_local_tests",
tests = [
":all_tests",
- "//tests/integrationtests:integrationtests_local",
+ "//src/test/kotlin/io/bazel/kotlin:local_assertion_tests",
],
)
diff --git a/kotlin/builder/integrationtests/BUILD b/kotlin/builder/integrationtests/BUILD
deleted file mode 100644
index 4485930..0000000
--- a/kotlin/builder/integrationtests/BUILD
+++ /dev/null
@@ -1,19 +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.
-java_test(
- name = "integrationtests",
- srcs = glob(["*.java"]),
- test_class = "io.bazel.kotlin.builder.KotlinBuilderTestSuite",
- deps = ["//kotlin/builder:builder_lib_for_tests"],
-)
diff --git a/kotlin/builder/integrationtests/KotlinBuilderActionTests.java b/kotlin/builder/integrationtests/KotlinBuilderActionTests.java
deleted file mode 100644
index 2c6a829..0000000
--- a/kotlin/builder/integrationtests/KotlinBuilderActionTests.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package io.bazel.kotlin.builder;
-
-import org.junit.Test;
-
-public class KotlinBuilderActionTests extends KotlinBuilderTestCase {
- @Test
- public void testCompileSimple() {
- addSource("AClass.kt", "package something;" + "class AClass{}");
- component().jvmTaskExecutor().compileKotlin(builderCommand(), context(), true);
- assertFileExists(DirectoryType.CLASSES, "something/AClass.class");
- assertFileDoesNotExist(outputs().getJar());
- }
-}
diff --git a/kotlin/builder/integrationtests/KotlinBuilderTestSuite.java b/kotlin/builder/integrationtests/KotlinBuilderTestSuite.java
deleted file mode 100644
index 649c0f2..0000000
--- a/kotlin/builder/integrationtests/KotlinBuilderTestSuite.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package io.bazel.kotlin.builder;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({KotlinBuilderActionTests.class, KotlinBuilderTests.class})
-public class KotlinBuilderTestSuite {}
diff --git a/kotlin/builder/unittests/BUILD b/kotlin/builder/unittests/BUILD
deleted file mode 100644
index aeaac28..0000000
--- a/kotlin/builder/unittests/BUILD
+++ /dev/null
@@ -1,26 +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.
-java_test(
- name = "unittests",
- size = "small",
- srcs = glob(["**/*.java"]),
- test_class = "io.bazel.kotlin.builder.BuilderUnitTestSuite",
- deps = [
- "//kotlin/builder:builder_lib_for_tests",
- "//third_party/jvm/com/google/truth",
- "@com_github_jetbrains_kotlin//:kotlin-stdlib",
- "@io_bazel_rules_kotlin//kotlin/builder/proto:deps",
- "@io_bazel_rules_kotlin_com_google_protobuf_protobuf_java//jar",
- ],
-)
diff --git a/kotlin/builder/unittests/io/bazel/kotlin/workers/BuilderUnitTestSuite.java b/kotlin/builder/unittests/io/bazel/kotlin/workers/BuilderUnitTestSuite.java
deleted file mode 100644
index 0830110..0000000
--- a/kotlin/builder/unittests/io/bazel/kotlin/workers/BuilderUnitTestSuite.java
+++ /dev/null
@@ -1,25 +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 io.bazel.kotlin.builder;
-
-import io.bazel.kotlin.builder.tasks.jvm.JdepsParserTest;
-import io.bazel.kotlin.builder.utils.jars.SourceJarCreatorUnitTests;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses({JdepsParserTest.class, SourceJarCreatorUnitTests.class})
-public class BuilderUnitTestSuite {}
diff --git a/kotlin/internal/toolchains.bzl b/kotlin/internal/toolchains.bzl
index 1f37feb..1631cbb 100644
--- a/kotlin/internal/toolchains.bzl
+++ b/kotlin/internal/toolchains.bzl
@@ -73,7 +73,7 @@
),
"kotlinbuilder": attr.label(
doc = "the kotlin builder executable",
- default = Label("//kotlin/builder"),
+ default = Label("//src/main/kotlin:builder"),
executable = True,
allow_files = True,
cfg = "host",
diff --git a/scripts/gen_proto_jars b/scripts/gen_proto_jars
index 217d1b3..1e71414 100755
--- a/scripts/gen_proto_jars
+++ b/scripts/gen_proto_jars
@@ -19,7 +19,7 @@
# If (when) Bazel distributes a host protoc this file can be removed.
WS_ROOT=$(bazel info workspace)
-PROTO_PATH=kotlin/builder/proto
+PROTO_PATH=src/main/protobuf
JAR_DIR=${WS_ROOT}/${PROTO_PATH}/jars
function build_lib() {
diff --git a/kotlin/builder/BUILD b/src/main/kotlin/BUILD
similarity index 80%
rename from kotlin/builder/BUILD
rename to src/main/kotlin/BUILD
index 234c3f9..ede4bea 100644
--- a/kotlin/builder/BUILD
+++ b/src/main/kotlin/BUILD
@@ -11,13 +11,13 @@
# 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/builder:bootstrap.bzl", "kt_bootstrap_library")
+load("//src/main/kotlin:bootstrap.bzl", "kt_bootstrap_library")
load("//kotlin:kotlin.bzl", "kt_jvm_library")
# The compiler library, this is co-located in the kotlin compiler classloader.
kt_bootstrap_library(
name = "compiler_lib",
- srcs = glob(["src/io/bazel/kotlin/compiler/**/*.kt"]),
+ srcs = glob(["io/bazel/kotlin/compiler/*.kt"]),
neverlink_deps = [
"@com_github_jetbrains_kotlin//:kotlin-compiler",
"@com_github_jetbrains_kotlin//:kotlin-annotation-processing",
@@ -31,7 +31,7 @@
data = [":compiler_lib.jar"],
main_class = "io.bazel.kotlin.builder.KotlinBuilderMain",
visibility = ["//visibility:public"],
- runtime_deps = ["//kotlin/builder/src/io/bazel/kotlin/builder"],
+ runtime_deps = ["//src/main/kotlin/io/bazel/kotlin/builder"],
)
filegroup(
@@ -51,15 +51,14 @@
testonly = 1,
data = [":data_for_tests"],
visibility = [
- "//kotlin/builder/integrationtests:__subpackages__",
- "//kotlin/builder/unittests:__subpackages__",
+ "//src/test:__subpackages__",
],
exports = [
- "//kotlin/builder/src/io/bazel/kotlin/builder",
+ "//src/main/kotlin/io/bazel/kotlin/builder:builder",
"//third_party/jvm/com/google/truth",
"//third_party/jvm/junit",
- "@io_bazel_rules_kotlin//kotlin/builder/proto:deps",
- "@io_bazel_rules_kotlin//kotlin/builder/proto:kotlin_model",
+ "//src/main/protobuf:deps",
+ "//src/main/protobuf:kotlin_model",
"@io_bazel_rules_kotlin_com_google_guava_guava//jar",
"@io_bazel_rules_kotlin_com_google_protobuf_protobuf_java//jar",
],
diff --git a/kotlin/builder/bootstrap.bzl b/src/main/kotlin/bootstrap.bzl
similarity index 90%
rename from kotlin/builder/bootstrap.bzl
rename to src/main/kotlin/bootstrap.bzl
index 663fd4e..02e184b 100644
--- a/kotlin/builder/bootstrap.bzl
+++ b/src/main/kotlin/bootstrap.bzl
@@ -16,7 +16,7 @@
_BOOTSTRAP_LIB_ARGS = ["-jvm-target", "1.8"]
def _resolve_dep_label(d):
- if d.startswith("//kotlin/builder/src/io/bazel/kotlin") and not d.endswith("_for_ide"):
+ if d.startswith("///src/main/kotlin/io/bazel/kotlin") and not d.endswith("_for_ide"):
prefix, _, target = d.rpartition(":")
if target == None:
# untested
@@ -32,7 +32,7 @@
Simple compilation of a kotlin library using a non-persistent worker. The target is a JavaInfo provider.
The target is tagged `"no-ide"` as intellij can't compile it. A seperate private target is created which is suffixed
- with `_for_ide`. If the dep is under the package `//kotlin/builder/src/io/bazel/kotlin/builder/...` then it will be
+ with `_for_ide`. If the dep is under the package `//src/main/kotlin/io/bazel/kotlin/builder/...` then it will be
added to the `_for_ide` target by adding a `_for_ide` prefix.
deps: the dependenices, the are setup as runtime_deps of the library.
@@ -87,13 +87,14 @@
jars = [jar_label],
tags = ["no-ide"],
runtime_deps = deps + runtime_deps,
- visibility = ["//visibility:public"],
+ visibility = ["//visibility:private"],
)
# hsyed todo this part of the graph should not be wired up outside of development.
_for_ide(
name = name + "_for_ide",
srcs = srcs,
+ neverlink = 1,
deps = [_resolve_dep_label(d) for d in deps] + neverlink_deps,
- visibility = ["//kotlin/builder:__subpackages__"],
+ visibility = ["//visibility:private"],
)
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/BUILD b/src/main/kotlin/io/bazel/kotlin/builder/BUILD
similarity index 81%
rename from kotlin/builder/src/io/bazel/kotlin/builder/BUILD
rename to src/main/kotlin/io/bazel/kotlin/builder/BUILD
index ca0cfa2..6957022 100644
--- a/kotlin/builder/src/io/bazel/kotlin/builder/BUILD
+++ b/src/main/kotlin/io/bazel/kotlin/builder/BUILD
@@ -11,7 +11,7 @@
# 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/builder:bootstrap.bzl", "kt_bootstrap_library")
+load("//src/main/kotlin:bootstrap.bzl", "kt_bootstrap_library")
kt_bootstrap_library(
name = "builder_kt",
@@ -22,9 +22,9 @@
]),
deps = [
"@com_github_jetbrains_kotlin//:kotlin-preloader",
- "@io_bazel_rules_kotlin//kotlin/builder/proto:deps",
- "@io_bazel_rules_kotlin//kotlin/builder/proto:kotlin_model",
- "@io_bazel_rules_kotlin//kotlin/builder/proto:worker",
+ "//src/main/protobuf:deps",
+ "//src/main/protobuf:kotlin_model",
+ "//src/main/protobuf:worker",
"@io_bazel_rules_kotlin_com_google_protobuf_protobuf_java//jar",
"@io_bazel_rules_kotlin_com_google_protobuf_protobuf_java_util//jar",
"@io_bazel_rules_kotlin_javax_inject_javax_inject//jar",
@@ -34,7 +34,7 @@
java_library(
name = "builder",
srcs = glob(["*.java"]),
- visibility = ["//kotlin/builder:__subpackages__"],
+ visibility = ["//src/main/kotlin:__subpackages__"],
exports = [":builder_kt"],
runtime_deps = [
"@com_github_jetbrains_kotlin//:kotlin-stdlib-jdk7",
@@ -43,7 +43,7 @@
],
deps = [
":builder_kt",
- "//kotlin/builder/proto:kotlin_model",
+ "//src/main/protobuf:kotlin_model",
"//third_party:dagger",
"@com_github_jetbrains_kotlin//:kotlin-stdlib",
"@io_bazel_rules_kotlin_com_google_protobuf_protobuf_java//jar",
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/KotlinBuilderComponent.java b/src/main/kotlin/io/bazel/kotlin/builder/KotlinBuilderComponent.java
similarity index 100%
rename from kotlin/builder/src/io/bazel/kotlin/builder/KotlinBuilderComponent.java
rename to src/main/kotlin/io/bazel/kotlin/builder/KotlinBuilderComponent.java
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/KotlinBuilderMain.java b/src/main/kotlin/io/bazel/kotlin/builder/KotlinBuilderMain.java
similarity index 100%
rename from kotlin/builder/src/io/bazel/kotlin/builder/KotlinBuilderMain.java
rename to src/main/kotlin/io/bazel/kotlin/builder/KotlinBuilderMain.java
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/tasks/BazelWorker.kt b/src/main/kotlin/io/bazel/kotlin/builder/tasks/BazelWorker.kt
similarity index 100%
rename from kotlin/builder/src/io/bazel/kotlin/builder/tasks/BazelWorker.kt
rename to src/main/kotlin/io/bazel/kotlin/builder/tasks/BazelWorker.kt
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/tasks/KotlinBuilder.kt b/src/main/kotlin/io/bazel/kotlin/builder/tasks/KotlinBuilder.kt
similarity index 100%
rename from kotlin/builder/src/io/bazel/kotlin/builder/tasks/KotlinBuilder.kt
rename to src/main/kotlin/io/bazel/kotlin/builder/tasks/KotlinBuilder.kt
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/tasks/js/Kotlin2JsTaskExecutor.kt b/src/main/kotlin/io/bazel/kotlin/builder/tasks/js/Kotlin2JsTaskExecutor.kt
similarity index 100%
rename from kotlin/builder/src/io/bazel/kotlin/builder/tasks/js/Kotlin2JsTaskExecutor.kt
rename to src/main/kotlin/io/bazel/kotlin/builder/tasks/js/Kotlin2JsTaskExecutor.kt
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/tasks/jvm/JDepsGenerator.kt b/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/JDepsGenerator.kt
similarity index 100%
rename from kotlin/builder/src/io/bazel/kotlin/builder/tasks/jvm/JDepsGenerator.kt
rename to src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/JDepsGenerator.kt
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/tasks/jvm/JavaCompiler.kt b/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/JavaCompiler.kt
similarity index 100%
rename from kotlin/builder/src/io/bazel/kotlin/builder/tasks/jvm/JavaCompiler.kt
rename to src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/JavaCompiler.kt
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/tasks/jvm/JdepsParser.kt b/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/JdepsParser.kt
similarity index 100%
rename from kotlin/builder/src/io/bazel/kotlin/builder/tasks/jvm/JdepsParser.kt
rename to src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/JdepsParser.kt
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/tasks/jvm/KotlinJvmTaskExecutor.kt b/src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinJvmTaskExecutor.kt
similarity index 100%
rename from kotlin/builder/src/io/bazel/kotlin/builder/tasks/jvm/KotlinJvmTaskExecutor.kt
rename to src/main/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinJvmTaskExecutor.kt
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/toolchain/KotlinToolException.kt b/src/main/kotlin/io/bazel/kotlin/builder/toolchain/KotlinToolException.kt
similarity index 100%
rename from kotlin/builder/src/io/bazel/kotlin/builder/toolchain/KotlinToolException.kt
rename to src/main/kotlin/io/bazel/kotlin/builder/toolchain/KotlinToolException.kt
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/toolchain/KotlinToolchain.kt b/src/main/kotlin/io/bazel/kotlin/builder/toolchain/KotlinToolchain.kt
similarity index 98%
rename from kotlin/builder/src/io/bazel/kotlin/builder/toolchain/KotlinToolchain.kt
rename to src/main/kotlin/io/bazel/kotlin/builder/toolchain/KotlinToolchain.kt
index 3b74053..167ba0f 100644
--- a/kotlin/builder/src/io/bazel/kotlin/builder/toolchain/KotlinToolchain.kt
+++ b/src/main/kotlin/io/bazel/kotlin/builder/toolchain/KotlinToolchain.kt
@@ -50,7 +50,7 @@
private fun createClassLoader(javaHome: Path, kotlinHome: Path): ClassLoader {
val preloadJars = mutableListOf<File>().also {
it += kotlinHome.resolveVerified("lib", "kotlin-compiler.jar")
- it += javaRunfiles.resolveVerified("io_bazel_rules_kotlin", "kotlin", "builder", "compiler_lib.jar")
+ it += javaRunfiles.resolveVerified("io_bazel_rules_kotlin", "src", "main", "kotlin", "compiler_lib.jar")
if (!isJdk9OrNewer) {
it += javaHome.resolveVerified("lib", "tools.jar")
}
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/utils/ArgMap.kt b/src/main/kotlin/io/bazel/kotlin/builder/utils/ArgMap.kt
similarity index 100%
rename from kotlin/builder/src/io/bazel/kotlin/builder/utils/ArgMap.kt
rename to src/main/kotlin/io/bazel/kotlin/builder/utils/ArgMap.kt
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/utils/CompilationTaskContext.kt b/src/main/kotlin/io/bazel/kotlin/builder/utils/CompilationTaskContext.kt
similarity index 100%
rename from kotlin/builder/src/io/bazel/kotlin/builder/utils/CompilationTaskContext.kt
rename to src/main/kotlin/io/bazel/kotlin/builder/utils/CompilationTaskContext.kt
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/utils/IOUtils.kt b/src/main/kotlin/io/bazel/kotlin/builder/utils/IOUtils.kt
similarity index 100%
rename from kotlin/builder/src/io/bazel/kotlin/builder/utils/IOUtils.kt
rename to src/main/kotlin/io/bazel/kotlin/builder/utils/IOUtils.kt
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/utils/KotlinCompilerPluginArgsEncoder.kt b/src/main/kotlin/io/bazel/kotlin/builder/utils/KotlinCompilerPluginArgsEncoder.kt
similarity index 100%
rename from kotlin/builder/src/io/bazel/kotlin/builder/utils/KotlinCompilerPluginArgsEncoder.kt
rename to src/main/kotlin/io/bazel/kotlin/builder/utils/KotlinCompilerPluginArgsEncoder.kt
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/utils/MiscUtils.kt b/src/main/kotlin/io/bazel/kotlin/builder/utils/MiscUtils.kt
similarity index 100%
rename from kotlin/builder/src/io/bazel/kotlin/builder/utils/MiscUtils.kt
rename to src/main/kotlin/io/bazel/kotlin/builder/utils/MiscUtils.kt
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/utils/TaskUtils.kt b/src/main/kotlin/io/bazel/kotlin/builder/utils/TaskUtils.kt
similarity index 100%
rename from kotlin/builder/src/io/bazel/kotlin/builder/utils/TaskUtils.kt
rename to src/main/kotlin/io/bazel/kotlin/builder/utils/TaskUtils.kt
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/utils/jars/JarCreator.kt b/src/main/kotlin/io/bazel/kotlin/builder/utils/jars/JarCreator.kt
similarity index 100%
rename from kotlin/builder/src/io/bazel/kotlin/builder/utils/jars/JarCreator.kt
rename to src/main/kotlin/io/bazel/kotlin/builder/utils/jars/JarCreator.kt
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/utils/jars/JarExtractor.kt b/src/main/kotlin/io/bazel/kotlin/builder/utils/jars/JarExtractor.kt
similarity index 100%
rename from kotlin/builder/src/io/bazel/kotlin/builder/utils/jars/JarExtractor.kt
rename to src/main/kotlin/io/bazel/kotlin/builder/utils/jars/JarExtractor.kt
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/utils/jars/JarHelper.kt b/src/main/kotlin/io/bazel/kotlin/builder/utils/jars/JarHelper.kt
similarity index 100%
rename from kotlin/builder/src/io/bazel/kotlin/builder/utils/jars/JarHelper.kt
rename to src/main/kotlin/io/bazel/kotlin/builder/utils/jars/JarHelper.kt
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/utils/jars/SourceJarCreator.kt b/src/main/kotlin/io/bazel/kotlin/builder/utils/jars/SourceJarCreator.kt
similarity index 100%
rename from kotlin/builder/src/io/bazel/kotlin/builder/utils/jars/SourceJarCreator.kt
rename to src/main/kotlin/io/bazel/kotlin/builder/utils/jars/SourceJarCreator.kt
diff --git a/kotlin/builder/src/io/bazel/kotlin/builder/utils/jars/SourceJarExtractor.kt b/src/main/kotlin/io/bazel/kotlin/builder/utils/jars/SourceJarExtractor.kt
similarity index 100%
rename from kotlin/builder/src/io/bazel/kotlin/builder/utils/jars/SourceJarExtractor.kt
rename to src/main/kotlin/io/bazel/kotlin/builder/utils/jars/SourceJarExtractor.kt
diff --git a/kotlin/builder/src/io/bazel/kotlin/compiler/BazelK2JVMCompiler.kt b/src/main/kotlin/io/bazel/kotlin/compiler/BazelK2JVMCompiler.kt
similarity index 100%
rename from kotlin/builder/src/io/bazel/kotlin/compiler/BazelK2JVMCompiler.kt
rename to src/main/kotlin/io/bazel/kotlin/compiler/BazelK2JVMCompiler.kt
diff --git a/kotlin/builder/proto/BUILD b/src/main/protobuf/BUILD
similarity index 100%
rename from kotlin/builder/proto/BUILD
rename to src/main/protobuf/BUILD
diff --git a/kotlin/builder/proto/deps.proto b/src/main/protobuf/deps.proto
similarity index 100%
rename from kotlin/builder/proto/deps.proto
rename to src/main/protobuf/deps.proto
diff --git a/kotlin/builder/proto/jars/libdeps_proto-speed.jar b/src/main/protobuf/jars/libdeps_proto-speed.jar
similarity index 92%
rename from kotlin/builder/proto/jars/libdeps_proto-speed.jar
rename to src/main/protobuf/jars/libdeps_proto-speed.jar
index 3749615..d3a8e29 100755
--- a/kotlin/builder/proto/jars/libdeps_proto-speed.jar
+++ b/src/main/protobuf/jars/libdeps_proto-speed.jar
Binary files differ
diff --git a/kotlin/builder/proto/jars/libkotlin_model_proto-speed.jar b/src/main/protobuf/jars/libkotlin_model_proto-speed.jar
similarity index 94%
rename from kotlin/builder/proto/jars/libkotlin_model_proto-speed.jar
rename to src/main/protobuf/jars/libkotlin_model_proto-speed.jar
index 5c04b63..38960a0 100755
--- a/kotlin/builder/proto/jars/libkotlin_model_proto-speed.jar
+++ b/src/main/protobuf/jars/libkotlin_model_proto-speed.jar
Binary files differ
diff --git a/kotlin/builder/proto/jars/libworker_protocol_proto-speed.jar b/src/main/protobuf/jars/libworker_protocol_proto-speed.jar
similarity index 91%
rename from kotlin/builder/proto/jars/libworker_protocol_proto-speed.jar
rename to src/main/protobuf/jars/libworker_protocol_proto-speed.jar
index 672d622..6fb7dc9 100755
--- a/kotlin/builder/proto/jars/libworker_protocol_proto-speed.jar
+++ b/src/main/protobuf/jars/libworker_protocol_proto-speed.jar
Binary files differ
diff --git a/kotlin/builder/proto/kotlin_model.proto b/src/main/protobuf/kotlin_model.proto
similarity index 100%
rename from kotlin/builder/proto/kotlin_model.proto
rename to src/main/protobuf/kotlin_model.proto
diff --git a/kotlin/builder/proto/worker_protocol.proto b/src/main/protobuf/worker_protocol.proto
similarity index 100%
rename from kotlin/builder/proto/worker_protocol.proto
rename to src/main/protobuf/worker_protocol.proto
diff --git a/tests/Bazel_all_local_tests.xml b/src/test/Bazel_all_local_tests.xml
similarity index 100%
rename from tests/Bazel_all_local_tests.xml
rename to src/test/Bazel_all_local_tests.xml
diff --git a/tests/integrationtests/jvm/basic/BUILD b/src/test/data/jvm/basic/BUILD
similarity index 85%
rename from tests/integrationtests/jvm/basic/BUILD
rename to src/test/data/jvm/basic/BUILD
index fdda127..16a016c 100644
--- a/tests/integrationtests/jvm/basic/BUILD
+++ b/src/test/data/jvm/basic/BUILD
@@ -11,6 +11,7 @@
# 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_binary", "kt_jvm_library", "kt_jvm_test")
kt_jvm_binary(
@@ -33,7 +34,7 @@
# a test resource library.
java_library(
name = "resourcejar",
- resource_strip_prefix = "tests/integrationtests/jvm/basic/resourcejar",
+ resource_strip_prefix = "src/test/data/jvm/basic/resourcejar",
resources = glob(["resourcejar/**"]),
)
@@ -54,7 +55,7 @@
kt_jvm_library(
name = "test_embed_resources_strip_prefix",
srcs = glob(["testresources/src/*.kt"]),
- resource_strip_prefix = "tests/integrationtests/jvm/basic/testresources/resources",
+ resource_strip_prefix = "src/test/data/jvm/basic/testresources/resources",
resources = glob(["testresources/resources/**/*"]),
)
@@ -103,21 +104,11 @@
kt_jvm_library(
name = "test_friends_library",
srcs = ["test_friends/Service.kt"],
-)
-
-# This test should be explicetly executed as module name mangling handling could regress otherwise.
-kt_jvm_test(
- name = "friends_tests",
- srcs = ["test_friends/TestFriendsTest.kt"],
- friends = [":test_friends_library"],
- test_class = "test.TestFriendsTest",
- deps = [
- "//third_party/jvm/junit",
- ],
+ visibility = ["//src/test/kotlin:__subpackages__"]
)
filegroup(
- name = "cases",
+ name = "basic",
srcs = [
":conventional_strip_resources.jar",
":propagation_ct_consumer",
@@ -131,5 +122,5 @@
":test_module_name_bin.jar",
":test_module_name_lib",
],
- visibility = ["//tests/integrationtests:__subpackages__"],
+ visibility = ["//visibility:public"],
)
diff --git a/tests/integrationtests/jvm/basic/conventional_strip_resources/src/main/resources/main.txt b/src/test/data/jvm/basic/conventional_strip_resources/src/main/resources/main.txt
similarity index 100%
rename from tests/integrationtests/jvm/basic/conventional_strip_resources/src/main/resources/main.txt
rename to src/test/data/jvm/basic/conventional_strip_resources/src/main/resources/main.txt
diff --git a/tests/integrationtests/jvm/basic/conventional_strip_resources/src/test/resources/test.txt b/src/test/data/jvm/basic/conventional_strip_resources/src/test/resources/test.txt
similarity index 100%
rename from tests/integrationtests/jvm/basic/conventional_strip_resources/src/test/resources/test.txt
rename to src/test/data/jvm/basic/conventional_strip_resources/src/test/resources/test.txt
diff --git a/tests/integrationtests/jvm/basic/helloworld/Main.kt b/src/test/data/jvm/basic/helloworld/Main.kt
similarity index 100%
rename from tests/integrationtests/jvm/basic/helloworld/Main.kt
rename to src/test/data/jvm/basic/helloworld/Main.kt
diff --git a/tests/integrationtests/jvm/basic/propagation/CompileTimeDependent.java b/src/test/data/jvm/basic/propagation/CompileTimeDependent.java
similarity index 100%
rename from tests/integrationtests/jvm/basic/propagation/CompileTimeDependent.java
rename to src/test/data/jvm/basic/propagation/CompileTimeDependent.java
diff --git a/tests/integrationtests/jvm/basic/propagation/RuntimeDependent.java b/src/test/data/jvm/basic/propagation/RuntimeDependent.java
similarity index 100%
rename from tests/integrationtests/jvm/basic/propagation/RuntimeDependent.java
rename to src/test/data/jvm/basic/propagation/RuntimeDependent.java
diff --git a/tests/integrationtests/jvm/basic/propagation/Stub.kt b/src/test/data/jvm/basic/propagation/Stub.kt
similarity index 100%
rename from tests/integrationtests/jvm/basic/propagation/Stub.kt
rename to src/test/data/jvm/basic/propagation/Stub.kt
diff --git a/tests/integrationtests/jvm/basic/resourcejar/pkg/file.txt b/src/test/data/jvm/basic/resourcejar/pkg/file.txt
similarity index 100%
rename from tests/integrationtests/jvm/basic/resourcejar/pkg/file.txt
rename to src/test/data/jvm/basic/resourcejar/pkg/file.txt
diff --git a/tests/integrationtests/jvm/basic/test_friends/Service.kt b/src/test/data/jvm/basic/test_friends/Service.kt
similarity index 100%
rename from tests/integrationtests/jvm/basic/test_friends/Service.kt
rename to src/test/data/jvm/basic/test_friends/Service.kt
diff --git a/tests/integrationtests/jvm/basic/testresources/resources/one/alsoAFile.txt b/src/test/data/jvm/basic/testresources/resources/one/alsoAFile.txt
similarity index 100%
rename from tests/integrationtests/jvm/basic/testresources/resources/one/alsoAFile.txt
rename to src/test/data/jvm/basic/testresources/resources/one/alsoAFile.txt
diff --git a/tests/integrationtests/jvm/basic/testresources/resources/one/two/aFile.txt b/src/test/data/jvm/basic/testresources/resources/one/two/aFile.txt
similarity index 100%
rename from tests/integrationtests/jvm/basic/testresources/resources/one/two/aFile.txt
rename to src/test/data/jvm/basic/testresources/resources/one/two/aFile.txt
diff --git a/tests/integrationtests/jvm/basic/testresources/src/AClass.kt b/src/test/data/jvm/basic/testresources/src/AClass.kt
similarity index 100%
rename from tests/integrationtests/jvm/basic/testresources/src/AClass.kt
rename to src/test/data/jvm/basic/testresources/src/AClass.kt
diff --git a/tests/integrationtests/jvm/kapt/BUILD b/src/test/data/jvm/kapt/BUILD
similarity index 97%
rename from tests/integrationtests/jvm/kapt/BUILD
rename to src/test/data/jvm/kapt/BUILD
index 9ab3b6f..358b6ed 100644
--- a/tests/integrationtests/jvm/kapt/BUILD
+++ b/src/test/data/jvm/kapt/BUILD
@@ -142,7 +142,7 @@
)
filegroup(
- name = "cases",
+ name = "kapt",
srcs = [
":ap_kotlin.jar",
":ap_kotlin_mixed",
@@ -153,5 +153,5 @@
":ap_kotlin_resources",
":ap_kotlin_resources_mixed",
],
- visibility = ["//tests/integrationtests:__subpackages__"],
+ visibility = ["//visibility:public"],
)
diff --git a/tests/integrationtests/jvm/kapt/java/TestAPNoGenReferences.java b/src/test/data/jvm/kapt/java/TestAPNoGenReferences.java
similarity index 100%
rename from tests/integrationtests/jvm/kapt/java/TestAPNoGenReferences.java
rename to src/test/data/jvm/kapt/java/TestAPNoGenReferences.java
diff --git a/tests/integrationtests/jvm/kapt/java/TestAutoValue.java b/src/test/data/jvm/kapt/java/TestAutoValue.java
similarity index 100%
rename from tests/integrationtests/jvm/kapt/java/TestAutoValue.java
rename to src/test/data/jvm/kapt/java/TestAutoValue.java
diff --git a/tests/integrationtests/jvm/kapt/java/TestJavaService.java b/src/test/data/jvm/kapt/java/TestJavaService.java
similarity index 100%
rename from tests/integrationtests/jvm/kapt/java/TestJavaService.java
rename to src/test/data/jvm/kapt/java/TestJavaService.java
diff --git a/tests/integrationtests/jvm/kapt/kotlin/TestKtAPNoGenReference.kt b/src/test/data/jvm/kapt/kotlin/TestKtAPNoGenReference.kt
similarity index 100%
rename from tests/integrationtests/jvm/kapt/kotlin/TestKtAPNoGenReference.kt
rename to src/test/data/jvm/kapt/kotlin/TestKtAPNoGenReference.kt
diff --git a/tests/integrationtests/jvm/kapt/kotlin/TestKtService.kt b/src/test/data/jvm/kapt/kotlin/TestKtService.kt
similarity index 100%
rename from tests/integrationtests/jvm/kapt/kotlin/TestKtService.kt
rename to src/test/data/jvm/kapt/kotlin/TestKtService.kt
diff --git a/tests/integrationtests/jvm/kapt/kotlin/TestKtValue.kt b/src/test/data/jvm/kapt/kotlin/TestKtValue.kt
similarity index 100%
rename from tests/integrationtests/jvm/kapt/kotlin/TestKtValue.kt
rename to src/test/data/jvm/kapt/kotlin/TestKtValue.kt
diff --git a/src/test/kotlin/io/bazel/kotlin/BUILD b/src/test/kotlin/io/bazel/kotlin/BUILD
new file mode 100644
index 0000000..d0b9697
--- /dev/null
+++ b/src/test/kotlin/io/bazel/kotlin/BUILD
@@ -0,0 +1,82 @@
+# 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")
+load(":defs.bzl", "kt_rules_e2e_test", "kt_rules_test")
+
+kt_jvm_library(
+ name = "assertion_test_case",
+ testonly = 1,
+ srcs = ["KotlinAssertionTestCase.kt"],
+ visibility = ["//visibility:public"],
+ deps = [
+ "@com_github_jetbrains_kotlin//:kotlin-test",
+ "@io_bazel_rules_kotlin_com_google_guava_guava//jar",
+ ],
+ exports = [
+ "//third_party/jvm/com/google/truth",
+ "//third_party/jvm/junit:junit",
+ "@com_github_jetbrains_kotlin//:kotlin-test",
+ "@io_bazel_rules_kotlin_com_google_guava_guava//jar",
+ ]
+)
+
+kt_rules_e2e_test(
+ name = "KotlinJvmBasicAssertionTest",
+ srcs = ["KotlinJvmBasicAssertionTest.kt"],
+ data = [ "//src/test/data/jvm/basic"]
+)
+
+kt_rules_e2e_test(
+ name = "KotlinNormalizationAssertionTest",
+ srcs =["KotlinNormalizationAssertionTest.kt"],
+ data = ["//src/test/data/jvm/basic"],
+)
+
+kt_rules_e2e_test(
+ name = "KotlinJvmKaptAssertionTest",
+ srcs = ["KotlinJvmKaptAssertionTest.kt"],
+ data = ["//src/test/data/jvm/kapt"]
+)
+
+kt_rules_e2e_test(
+ name = "KotlinJvmDaggerExampleTest",
+ srcs =["KotlinJvmDaggerExampleTest.kt"],
+ data = ["//examples/dagger:coffee_app"],
+)
+
+kt_rules_e2e_test(
+ name = "KotlinJvmFriendsVisibilityTest",
+ srcs = ["KotlinJvmFriendsVisibilityTest.kt"],
+ friends = ["//src/test/data/jvm/basic:test_friends_library"]
+)
+
+test_suite(
+ name = "assertion_tests",
+ tests = [
+ "KotlinJvmBasicAssertionTest",
+ "KotlinJvmKaptAssertionTest",
+ "KotlinJvmDaggerExampleTest",
+ "KotlinJvmFriendsVisibilityTest",
+ ]
+)
+
+test_suite(
+ name = "local_assertion_tests",
+ tests = [
+ ":assertion_tests",
+ ":KotlinNormalizationAssertionTest"
+ ]
+)
diff --git a/tests/rules/AssertionTestCase.kt b/src/test/kotlin/io/bazel/kotlin/KotlinAssertionTestCase.kt
similarity index 97%
rename from tests/rules/AssertionTestCase.kt
rename to src/test/kotlin/io/bazel/kotlin/KotlinAssertionTestCase.kt
index 3ecc098..ecaff2c 100644
--- a/tests/rules/AssertionTestCase.kt
+++ b/src/test/kotlin/io/bazel/kotlin/KotlinAssertionTestCase.kt
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package io.bazel.kotlin.testing
+package io.bazel.kotlin
import com.google.common.hash.Hashing
import java.io.File
@@ -34,7 +34,7 @@
class TestCaseFailedException(name: String? = null, description: String? = null, cause: Throwable) :
AssertionError(""""${name?.let { "jar: $it " } ?: ""} "$description" failed, error: ${cause.message}""", cause)
-abstract class AssertionTestCase(root: String) : BasicAssertionTestCase() {
+abstract class KotlinAssertionTestCase(root: String) : BasicAssertionTestCase() {
private lateinit var currentFile: File
private val testRunfileRoot: Path = Paths.get(root).also {
diff --git a/tests/integrationtests/jvm/JvmBasicFunctionalTests.kt b/src/test/kotlin/io/bazel/kotlin/KotlinJvmBasicAssertionTest.kt
similarity index 80%
rename from tests/integrationtests/jvm/JvmBasicFunctionalTests.kt
rename to src/test/kotlin/io/bazel/kotlin/KotlinJvmBasicAssertionTest.kt
index a92835a..0c3ae8d 100644
--- a/tests/integrationtests/jvm/JvmBasicFunctionalTests.kt
+++ b/src/test/kotlin/io/bazel/kotlin/KotlinJvmBasicAssertionTest.kt
@@ -13,21 +13,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package io.bazel.kotlin.testing.jvm
+package io.bazel.kotlin
-import io.bazel.kotlin.testing.AssertionTestCase
import org.junit.Test
-class JvmBasicFunctionalTests : AssertionTestCase("tests/integrationtests/jvm/basic") {
+class KotlinJvmBasicAssertionTest: KotlinAssertionTestCase("src/test/data/jvm/basic") {
@Test
fun testResourceMerging() {
jarTestCase("test_embed_resources.jar", description = "The rules should support including resource directories") {
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"
+ "src/test/data/jvm/basic/testresources/resources/one/alsoAFile.txt",
+ "src/test/data/jvm/basic/testresources/resources/one/two/aFile.txt"
)
}
jarTestCase("test_merge_resourcesjar.jar", description = "the rules should support merging jars") {
@@ -56,10 +55,10 @@
@Test
fun testModuleNaming() {
jarTestCase("test_module_name_bin.jar", description = "A binary rule should support default module naming") {
- assertContainsEntries("META-INF/tests_integrationtests_jvm_basic-test_module_name_bin.kotlin_module")
+ assertContainsEntries("META-INF/src_test_data_jvm_basic-test_module_name_bin.kotlin_module")
}
jarTestCase("test_module_name_lib.jar", description = "A library rule should support default module naming") {
- assertContainsEntries("META-INF/tests_integrationtests_jvm_basic-test_module_name_lib.kotlin_module")
+ assertContainsEntries("META-INF/src_test_data_jvm_basic-test_module_name_lib.kotlin_module")
}
jarTestCase("test_module_name_attr_lib.jar", description = "The kotlin rules should support the module_name attribute") {
assertContainsEntries("META-INF/hello-module.kotlin_module")
diff --git a/tests/integrationtests/jvm/JvmExampleTests.kt b/src/test/kotlin/io/bazel/kotlin/KotlinJvmDaggerExampleTest.kt
similarity index 86%
rename from tests/integrationtests/jvm/JvmExampleTests.kt
rename to src/test/kotlin/io/bazel/kotlin/KotlinJvmDaggerExampleTest.kt
index 0f7f7c2..f236eae 100644
--- a/tests/integrationtests/jvm/JvmExampleTests.kt
+++ b/src/test/kotlin/io/bazel/kotlin/KotlinJvmDaggerExampleTest.kt
@@ -13,15 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package io.bazel.kotlin.testing.jvm
+package io.bazel.kotlin
-import io.bazel.kotlin.testing.BasicAssertionTestCase
import org.junit.Test
/**
* These tests verify properties of the example.
*/
-class JvmExampleTests : BasicAssertionTestCase() {
+class KotlinJvmDaggerExampleTest : BasicAssertionTestCase() {
@Test
fun daggerExampleIsRunnable() {
assertExecutableRunfileSucceeds(
diff --git a/src/test/kotlin/io/bazel/kotlin/KotlinJvmFriendsVisibilityTest.kt b/src/test/kotlin/io/bazel/kotlin/KotlinJvmFriendsVisibilityTest.kt
new file mode 100644
index 0000000..a172dab
--- /dev/null
+++ b/src/test/kotlin/io/bazel/kotlin/KotlinJvmFriendsVisibilityTest.kt
@@ -0,0 +1,18 @@
+package io.bazel.kotlin
+
+import test.Service
+import test.DEFAULT_FRIEND
+
+/**
+ * This test validates that friend visibility is working. Services and DEFAULT_FRIEND are internal another compilation
+ * unit.
+ */
+class KotlinJvmFriendsVisibilityTest {
+ val service: Service = Service()
+
+ @org.junit.Test
+ fun testCanAccessFriendMembers() {
+ println(service.value)
+ println(service.iSayHolla(DEFAULT_FRIEND))
+ }
+}
\ No newline at end of file
diff --git a/tests/integrationtests/jvm/KaptTests.kt b/src/test/kotlin/io/bazel/kotlin/KotlinJvmKaptAssertionTest.kt
similarity index 95%
rename from tests/integrationtests/jvm/KaptTests.kt
rename to src/test/kotlin/io/bazel/kotlin/KotlinJvmKaptAssertionTest.kt
index 2e817c7..7d5fc5c 100644
--- a/tests/integrationtests/jvm/KaptTests.kt
+++ b/src/test/kotlin/io/bazel/kotlin/KotlinJvmKaptAssertionTest.kt
@@ -13,12 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package io.bazel.kotlin.testing.jvm
+package io.bazel.kotlin
-import io.bazel.kotlin.testing.AssertionTestCase
import org.junit.Test
-class KaptTests : AssertionTestCase("tests/integrationtests/jvm/kapt") {
+class KotlinJvmKaptAssertionTest : KotlinAssertionTestCase("src/test/data/jvm/kapt") {
@Test
fun testKotlinOnlyAnnotationProcessing() {
jarTestCase("ap_kotlin.jar", description = "annotation processing should work") {
diff --git a/tests/integrationtests/jvm/JvmBasicLocalTests.kt b/src/test/kotlin/io/bazel/kotlin/KotlinNormalizationAssertionTest.kt
similarity index 77%
rename from tests/integrationtests/jvm/JvmBasicLocalTests.kt
rename to src/test/kotlin/io/bazel/kotlin/KotlinNormalizationAssertionTest.kt
index 384a71d..df89bb6 100644
--- a/tests/integrationtests/jvm/JvmBasicLocalTests.kt
+++ b/src/test/kotlin/io/bazel/kotlin/KotlinNormalizationAssertionTest.kt
@@ -13,13 +13,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package io.bazel.kotlin.testing.jvm
+package io.bazel.kotlin
-import io.bazel.kotlin.testing.AssertionTestCase
import org.junit.Test
-class JvmBasicLocalTests : AssertionTestCase("tests/integrationtests/jvm/basic") {
+class KotlinNormalizationAssertionTest : KotlinAssertionTestCase("src/test/data/jvm/basic") {
/*
* (hsyed) This test is running locally because things hash differently on the ci servers. Don't have the time to
* look into it.
@@ -32,7 +31,7 @@
name = "test_module_name_lib.jar",
description = "Builder jars should be normalized with and include stamp data"
) {
- validateFileSha256("f26827dd09160adb436b31a12aa3b86f6da8ae1c317150c264ed8d1427a68dea")
+ validateFileSha256("1d26035bda6f384b9cc6bbe5a5bf0727b4da0aeec59545c421de32775149d4cf")
assertManifestStamped()
assertEntryCompressedAndNormalizedTimestampYear("helloworld/Main.class")
}
@@ -40,11 +39,11 @@
name = "test_embed_resources.jar",
description = "Merging resources into the main output jar should still result in a normalized jar"
) {
- validateFileSha256("270ea8758f38d9ef15013aea222cc8f609affaf9acc2f2cd206dbd73a4872082")
+ validateFileSha256("ff35e9779be25c5803ab74cd5cee46bfd35da9412fe78395d1ebc2fb2e20880a")
assertManifestStamped()
assertEntryCompressedAndNormalizedTimestampYear("testresources/AClass.class")
assertEntryCompressedAndNormalizedTimestampYear(
- "tests/integrationtests/jvm/basic/testresources/resources/one/two/aFile.txt"
+ "src/test/data/jvm/basic/testresources/resources/one/two/aFile.txt"
)
}
}
diff --git a/src/test/kotlin/io/bazel/kotlin/builder/BUILD b/src/test/kotlin/io/bazel/kotlin/builder/BUILD
new file mode 100644
index 0000000..599ac4a
--- /dev/null
+++ b/src/test/kotlin/io/bazel/kotlin/builder/BUILD
@@ -0,0 +1,49 @@
+# 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("//src/test/kotlin/io/bazel/kotlin:defs.bzl", "kt_rules_test")
+
+java_library(
+ name = "test_lib",
+ testonly = 1,
+ srcs = [":KotlinBuilderTestCase.java"],
+ exports = ["//src/main/kotlin:builder_lib_for_tests"],
+ deps = ["//src/main/kotlin:builder_lib_for_tests"],
+)
+
+kt_rules_test(
+ name = "SourceJarCreatorTest",
+ srcs = ["utils/jars/SourceJarCreatorTest.java"],
+)
+
+kt_rules_test(
+ name = "JdepsParserTest",
+ srcs = ["tasks/jvm/JdepsParserTest.java"],
+)
+
+kt_rules_test(
+ name = "KotlinBuilderJvmTest",
+ srcs = ["tasks/jvm/KotlinBuilderJvmTest.java"],
+)
+
+test_suite(
+ name = "builder_tests",
+ tests = [
+ ":SourceJarCreatorTest",
+ ":JdepsParserTest",
+ ":KotlinBuilderJvmTest"
+ ],
+ visibility = ["//visibility:public"]
+)
+
diff --git a/kotlin/builder/integrationtests/KotlinBuilderTestCase.java b/src/test/kotlin/io/bazel/kotlin/builder/KotlinBuilderTestCase.java
similarity index 95%
rename from kotlin/builder/integrationtests/KotlinBuilderTestCase.java
rename to src/test/kotlin/io/bazel/kotlin/builder/KotlinBuilderTestCase.java
index c5759b5..3a3b7de 100644
--- a/kotlin/builder/integrationtests/KotlinBuilderTestCase.java
+++ b/src/test/kotlin/io/bazel/kotlin/builder/KotlinBuilderTestCase.java
@@ -22,7 +22,7 @@
import static com.google.common.base.Charsets.UTF_8;
import static com.google.common.truth.Truth.assertWithMessage;
-abstract class KotlinBuilderTestCase {
+public abstract class KotlinBuilderTestCase {
private static final Path BAZEL_TEST_DIR =
Paths.get(Preconditions.checkNotNull(System.getenv("TEST_TMPDIR")));
private static final AtomicInteger counter = new AtomicInteger(0);
@@ -144,7 +144,7 @@
TEMP,
SOURCE_GEN;
- protected static Path select(DirectoryType type, JvmCompilationTask command) {
+ public static Path select(DirectoryType type, JvmCompilationTask command) {
Path ret;
switch (type) {
case CLASSES:
@@ -166,7 +166,7 @@
}
}
- void assertFileExists(DirectoryType dir, String filePath) {
+ protected void assertFileExists(DirectoryType dir, String filePath) {
Path file = DirectoryType.select(dir, builderCommand()).resolve(filePath);
assertFileExists(file.toString());
}
@@ -175,7 +175,7 @@
assertWithMessage("file exisst: " + filePath).that(new File(filePath).exists()).isFalse();
}
- void assertFileExists(String filePath) {
+ protected void assertFileExists(String filePath) {
assertWithMessage("file did not exist: " + filePath).that(new File(filePath).exists()).isTrue();
}
}
diff --git a/kotlin/builder/unittests/io/bazel/kotlin/workers/tasks/jvm/JdepsParserTest.java b/src/test/kotlin/io/bazel/kotlin/builder/tasks/jvm/JdepsParserTest.java
similarity index 100%
rename from kotlin/builder/unittests/io/bazel/kotlin/workers/tasks/jvm/JdepsParserTest.java
rename to src/test/kotlin/io/bazel/kotlin/builder/tasks/jvm/JdepsParserTest.java
diff --git a/kotlin/builder/integrationtests/KotlinBuilderTests.java b/src/test/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinBuilderJvmTest.java
similarity index 92%
rename from kotlin/builder/integrationtests/KotlinBuilderTests.java
rename to src/test/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinBuilderJvmTest.java
index df4ebea..e1e4373 100644
--- a/kotlin/builder/integrationtests/KotlinBuilderTests.java
+++ b/src/test/kotlin/io/bazel/kotlin/builder/tasks/jvm/KotlinBuilderJvmTest.java
@@ -1,7 +1,8 @@
-package io.bazel.kotlin.builder;
+package io.bazel.kotlin.builder.tasks.jvm;
import com.google.common.truth.Truth;
import com.google.devtools.build.lib.view.proto.Deps;
+import io.bazel.kotlin.builder.KotlinBuilderTestCase;
import io.bazel.kotlin.builder.utils.CompilationTaskContext;
import io.bazel.kotlin.model.JvmCompilationTask;
import org.junit.Test;
@@ -15,7 +16,7 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
-public class KotlinBuilderTests extends KotlinBuilderTestCase {
+public class KotlinBuilderJvmTest extends KotlinBuilderTestCase {
@Test
public void testSimpleCompile() {
addSource("AClass.kt", "package something;" + "class AClass{}");
diff --git a/kotlin/builder/unittests/io/bazel/kotlin/workers/utils/jars/SourceJarCreatorUnitTests.java b/src/test/kotlin/io/bazel/kotlin/builder/utils/jars/SourceJarCreatorTest.java
similarity index 97%
rename from kotlin/builder/unittests/io/bazel/kotlin/workers/utils/jars/SourceJarCreatorUnitTests.java
rename to src/test/kotlin/io/bazel/kotlin/builder/utils/jars/SourceJarCreatorTest.java
index c0ffa76..4f1093e 100644
--- a/kotlin/builder/unittests/io/bazel/kotlin/workers/utils/jars/SourceJarCreatorUnitTests.java
+++ b/src/test/kotlin/io/bazel/kotlin/builder/utils/jars/SourceJarCreatorTest.java
@@ -23,7 +23,7 @@
import static com.google.common.truth.Truth.assertWithMessage;
-public class SourceJarCreatorUnitTests {
+public class SourceJarCreatorTest {
private final String expectedPackage = "iO.some1.package";
private final List<String> cases =
diff --git a/src/test/kotlin/io/bazel/kotlin/defs.bzl b/src/test/kotlin/io/bazel/kotlin/defs.bzl
new file mode 100644
index 0000000..3272c8e
--- /dev/null
+++ b/src/test/kotlin/io/bazel/kotlin/defs.bzl
@@ -0,0 +1,39 @@
+# 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 _get_class_name(kwargs):
+ if len(kwargs.get("srcs", [])) == 1:
+ return (
+ native.package_name().replace("src/test/kotlin/", "") +
+ "." + kwargs["srcs"][0]
+ ).replace("/", ".").replace(".java", "").replace(".kt", "")
+ else:
+ return kwargs["test_classes"]
+
+def kt_rules_test(name, **kwargs):
+ kwargs.setdefault("size", "small")
+ kwargs["deps"] = kwargs.setdefault("deps", []) + ["//src/test/kotlin/io/bazel/kotlin/builder:test_lib"]
+ kwargs.setdefault("test_class", _get_class_name(kwargs))
+ for f in kwargs.get("srcs"):
+ if f.endswith(".kt"):
+ kt_jvm_test(name = name, **kwargs)
+ return
+ native.java_test(name = name, **kwargs)
+
+def kt_rules_e2e_test(name, **kwargs):
+ kwargs.setdefault("size", "small")
+ kwargs["deps"] = kwargs.setdefault("deps", []) + ["//src/test/kotlin/io/bazel/kotlin:assertion_test_case"]
+ kwargs.setdefault("test_class", _get_class_name(kwargs))
+ kt_jvm_test(name = name, **kwargs)
\ No newline at end of file
diff --git a/tests/integrationtests/BUILD b/tests/integrationtests/BUILD
deleted file mode 100644
index 6f22d63..0000000
--- a/tests/integrationtests/BUILD
+++ /dev/null
@@ -1,28 +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(default_visibility = ["//tests/integrationtests:__subpackages__"])
-
-test_suite(
- name = "integrationtests",
- tests = [
- "//tests/integrationtests/jvm",
- ],
-)
-
-test_suite(
- name = "integrationtests_local",
- tests = [
- "//tests/integrationtests/jvm:jvm_local",
- ],
-)
diff --git a/tests/integrationtests/jvm/BUILD b/tests/integrationtests/jvm/BUILD
deleted file mode 100644
index 27ad6f4..0000000
--- a/tests/integrationtests/jvm/BUILD
+++ /dev/null
@@ -1,58 +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(default_visibility = ["//visibility:private"])
-
-# The tests are written in Kotlin, so the tests inately test a lot of the rule functionality.
-load("//tests/rules:defs.bzl", "kt_it_assertion_test")
-
-kt_it_assertion_test(
- name = "basic_tests",
- cases = "//tests/integrationtests/jvm/basic:cases",
- test_class = "io.bazel.kotlin.testing.jvm.JvmBasicFunctionalTests",
-)
-
-kt_it_assertion_test(
- name = "basic_local_tests",
- cases = "//tests/integrationtests/jvm/basic:cases",
- test_class = "io.bazel.kotlin.testing.jvm.JvmBasicLocalTests",
-)
-
-kt_it_assertion_test(
- name = "kapt_tests",
- cases = "//tests/integrationtests/jvm/kapt:cases",
- test_class = "io.bazel.kotlin.testing.jvm.KaptTests",
-)
-
-kt_it_assertion_test(
- name = "example_tests",
- data = ["//examples/dagger:coffee_app"],
- test_class = "io.bazel.kotlin.testing.jvm.JvmExampleTests",
-)
-
-test_suite(
- name = "jvm",
- tests = [
- ":basic_tests",
- ":example_tests",
- ":kapt_tests",
- "//tests/integrationtests/jvm/basic:friends_tests",
- ],
-)
-
-test_suite(
- name = "jvm_local",
- tests = [
- ":basic_local_tests",
- ],
-)
diff --git a/tests/integrationtests/jvm/basic/test_friends/TestFriendsTest.kt b/tests/integrationtests/jvm/basic/test_friends/TestFriendsTest.kt
deleted file mode 100644
index ad25e2c..0000000
--- a/tests/integrationtests/jvm/basic/test_friends/TestFriendsTest.kt
+++ /dev/null
@@ -1,13 +0,0 @@
-package test
-
-import org.junit.Test
-
-class TestFriendsTest {
- val service: Service = Service()
-
- @Test
- fun testCanAccessFriendMembers() {
- println(service.value)
- println(service.iSayHolla(DEFAULT_FRIEND))
- }
-}
\ No newline at end of file
diff --git a/tests/rules/BUILD b/tests/rules/BUILD
deleted file mode 100644
index 780a73f..0000000
--- a/tests/rules/BUILD
+++ /dev/null
@@ -1,27 +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(default_visibility = ["//tests:__subpackages__"])
-
-load("//kotlin:kotlin.bzl", "kt_jvm_library")
-
-kt_jvm_library(
- name = "assertion_test_case",
- testonly = 1,
- srcs = ["AssertionTestCase.kt"],
- visibility = ["//tests:__subpackages__"],
- deps = [
- "@com_github_jetbrains_kotlin//:kotlin-test",
- "@io_bazel_rules_kotlin_com_google_guava_guava//jar",
- ],
-)
diff --git a/tests/rules/defs.bzl b/tests/rules/defs.bzl
deleted file mode 100644
index d72e4f5..0000000
--- a/tests/rules/defs.bzl
+++ /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.
-load("//kotlin:kotlin.bzl", "kt_jvm_test")
-
-TEST_COMMON_DEPS = [
- "//tests/rules:assertion_test_case",
- "//third_party/jvm/com/google/truth",
- "//third_party/jvm/junit:junit",
-]
-
-def kt_it_assertion_test(name, test_class, cases = None, data = [], deps = []):
- parts = test_class.split(".")
- if cases:
- data = data + [cases]
- kt_jvm_test(
- name = name,
- srcs = ["%s.kt" % parts[len(parts) - 1]],
- deps = TEST_COMMON_DEPS + deps,
- test_class = test_class,
- data = data,
- visibility = ["//visibility:private"],
- )