Skip to content

Commit

Permalink
Move tests to assertion test
Browse files Browse the repository at this point in the history
  • Loading branch information
raghulvelusamy committed Dec 19, 2023
1 parent d48cb0c commit 61d8eac
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 8 deletions.
13 changes: 13 additions & 0 deletions src/test/data/jvm/ksp/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
load("//kotlin:core.bzl", "kt_ksp_plugin")
load("//kotlin:jvm.bzl", "kt_jvm_library")

# 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"])

kt_ksp_plugin(
Expand Down
7 changes: 7 additions & 0 deletions src/test/kotlin/io/bazel/kotlin/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,20 @@ kt_rules_e2e_test(
srcs = ["KotlinJvm13Test.kt"],
)

kt_rules_e2e_test(
name = "KotlinJvmKspAssertionTest",
srcs = ["KotlinJvmKspAssertionTest.kt"],
data = ["//src/test/data/jvm/ksp"],
)

test_suite(
name = "assertion_tests",
tests = [
"KotlinJvm13Test",
"KotlinJvmAssociatesBasicVisibilityTest",
"KotlinJvmBasicAssertionTest",
"KotlinJvmKaptAssertionTest",
"KotlinJvmKspAssertionTest",
],
)

Expand Down
45 changes: 45 additions & 0 deletions src/test/kotlin/io/bazel/kotlin/KotlinJvmKspAssertionTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package io.bazel.kotlin

import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4

@RunWith(JUnit4::class)
class KotlinJvmKspAssertionTest: KotlinAssertionTestCase("src/test/data/jvm/ksp") {

@Test
fun testKSPCopiesAllFilesFromMetaINF() {
jarTestCase("coffee_lib.jar", description = "Generated jar with ksp plugin contains meta-inf contents") {
assertContainsExactEntries(
"src/",
"src/test/",
"src/test/data/",
"src/test/data/jvm/",
"src/test/data/jvm/ksp/",
"src/test/data/jvm/ksp/CoffeeAppService.class",
"META-INF/",
"META-INF/MANIFEST.MF"
)
}
}

@Test
fun testKSPCopiesAllFilesFromMetaINFInMoshiLib() {
jarTestCase("moshi_lib.jar", description = "Generated jar with ksp plugin contains meta-inf contents") {
assertContainsExactEntries(
"src/",
"src/test/",
"src/test/data/",
"src/test/data/jvm/",
"src/test/data/jvm/ksp/",
"src/test/data/jvm/ksp/CoffeeAppModel.class",
"src/test/data/jvm/ksp/CoffeeAppModelJsonAdapter.class",
"META-INF/",
"META-INF/MANIFEST.MF",
"META-INF/proguard/",
"META-INF/proguard/moshi-src.test.data.jvm.ksp.CoffeeAppModel.pro",
"META-INF/src_test_data_jvm_ksp-moshi_lib.kotlin_module"
)
}
}
}
9 changes: 1 addition & 8 deletions src/test/kotlin/io/bazel/kotlin/builder/tasks/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

load("@rules_java//java:defs.bzl", "java_library")
load("//src/test/kotlin/io/bazel/kotlin:defs.bzl", "kt_rules_e2e_test", "kt_rules_test")
load("//src/test/kotlin/io/bazel/kotlin:defs.bzl", "kt_rules_test")

java_library(
name = "JdepsParserTestFixtures",
Expand Down Expand Up @@ -107,12 +107,6 @@ kt_rules_test(
],
)

kt_rules_e2e_test(
name = "KotlinKSPMetaFilesCopyTest",
srcs = ["jvm/KotlinBuilderJvmKspTest.kt"],
data = ["//src/test/data/jvm/ksp"],
)

test_suite(
name = "tasks_tests",
tests = [
Expand All @@ -126,6 +120,5 @@ test_suite(
":KotlinBuilderJvmKaptTest",
":KotlinBuilderJvmStrictDepsTest",
":KotlinJvmTaskExecutorTest",
":KotlinKSPMetaFilesCopyTest",
],
)

0 comments on commit 61d8eac

Please sign in to comment.