rules_kotlin
rules_kotlin copied to clipboard
`kt_test` targets fail on Windows
On Windows and with 1.5.0-beta-4, any kt_jvm_test target fails with an error of the following form:
Executing tests from //foobar:descriptor_utils_test
-----------------------------------------------------------------------------
ERROR(tools/test/windows/tw.cc:1293) ERROR: src/main/native/windows/process.cc(202): CreateProcessW("C:\users\runneradmin\_bazel_runneradmin\2gbstkcc\execroot\project\bazel-out\x64_windows-opt\bin\foobar\descriptor_utils_test"): %1 is not a valid Win32 application.
(error: 193)
ERROR(tools/test/windows/tw.cc:1450) Failed to start test process (arg: C:\users\runneradmin\_bazel_runneradmin\2gbstkcc\execroot\project\bazel-out\x64_windows-opt\bin\foobar\descriptor_utils_test)
When inspecting the test executable, it turns out to be a shell script generated from Bazel's java_stub_template.txt. While this could run on Windows via bash.exe, such a script cannot be launched directly via CreateProcessW, hence the error.
Does this mean that running Kotlin tests on Windows is not supported or is there a simple workaround for this problem? Wrapping every Kotlin test in a java_test may help.
+1 I'm seeing this bug here as well: https://buildkite.com/bazel/protobuf/builds/4038#a77575c0-a256-4ddd-9e5b-7410337bc054 with the same error message.
This is my current workaround: https://github.com/CodeIntelligenceTesting/jazzer/blob/main/bazel/kotlin.bzl
+1, seeing this as well. I'm not perfectly sure where the point is, where the file is called in the end, but could we fix this by ensuring this is called through cmd_bash, as I am aware of genrule for example (https://bazel.build/reference/be/general?hl=en#genrule.cmd)? If anyone could point out how to fix this potentially, one could more easily contribute a fix.