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