• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2021 Code Intelligence GmbH
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_test")
16
17# A kt_jvm_test wrapped in a java_test for Windows compatibility.
18# Workaround for https://github.com/bazelbuild/rules_kotlin/issues/599: rules_kotlin can only create
19# a shell wrapper script for Java targets, no native executable as is required on Windows.
20def wrapped_kt_jvm_test(
21        name,
22        test_class,
23        size = None,
24        tags = None,
25        timeout = None,
26        visibility = None,
27        **kt_jvm_test_args):
28    kt_jvm_test_name = name + "_kt_"
29
30    # Modify a copy of the tags.
31    kt_jvm_test_tags = list(tags) if tags != None else []
32    kt_jvm_test_tags.append("manual")
33    kt_jvm_test(
34        name = kt_jvm_test_name,
35        test_class = test_class,
36        visibility = ["//visibility:private"],
37        tags = kt_jvm_test_tags,
38        **kt_jvm_test_args
39    )
40
41    native.java_test(
42        name = name,
43        size = size,
44        tags = tags,
45        test_class = test_class,
46        timeout = timeout,
47        visibility = visibility,
48        runtime_deps = [
49            ":" + kt_jvm_test_name,
50        ],
51    )
52