Windows Add tests for msys gcc toolchain and mingw gcc toolchain
This will prevent https://github.com/bazelbuild/bazel/issues/6610 from happening again.
RELNOTES: None
PiperOrigin-RevId: 220423789
diff --git a/src/test/shell/bazel/bazel_windows_example_test.sh b/src/test/shell/bazel/bazel_windows_example_test.sh
index 12aeeb1..256f974 100755
--- a/src/test/shell/bazel/bazel_windows_example_test.sh
+++ b/src/test/shell/bazel/bazel_windows_example_test.sh
@@ -34,10 +34,6 @@
function set_up() {
copy_examples
setup_bazelrc
- cat >>"$TEST_TMPDIR/bazelrc" <<EOF
-# Workaround for https://github.com/bazelbuild/bazel/issues/2983
-startup --host_jvm_args=-Dbazel.windows_unix_root=C:/fake/msys
-EOF
export MSYS_NO_PATHCONV=1
export MSYS2_ARG_CONV_EXCL="*"
}
@@ -78,6 +74,40 @@
assert_test_fails "//examples/cpp:hello-fail_test"
}
+function test_cpp_with_msys_gcc() {
+ local cpp_pkg=examples/cpp
+ assert_build_output \
+ ./bazel-bin/${cpp_pkg}/libhello-lib.a ${cpp_pkg}:hello-world \
+ --compiler=msys-gcc
+ assert_build_output \
+ ./bazel-bin/${cpp_pkg}/libhello-lib.so ${cpp_pkg}:hello-lib\
+ --compiler=msys-gcc --output_groups=dynamic_library
+ assert_build ${cpp_pkg}:hello-world --compiler=msys-gcc
+ ./bazel-bin/${cpp_pkg}/hello-world foo >& $TEST_log \
+ || fail "./bazel-bin/${cpp_pkg}/hello-world foo execution failed"
+ expect_log "Hello foo"
+ assert_test_ok "//examples/cpp:hello-success_test" --compiler=msys-gcc
+ assert_test_fails "//examples/cpp:hello-fail_test" --compiler=msys-gcc
+}
+
+function test_cpp_with_mingw_gcc() {
+ local cpp_pkg=examples/cpp
+ ( # mingw gcc should be in PATH
+ export PATH="/mingw64/bin:$PATH"
+ assert_build_output \
+ ./bazel-bin/${cpp_pkg}/libhello-lib.a ${cpp_pkg}:hello-world \
+ --compiler=mingw-gcc
+ assert_build_output \
+ ./bazel-bin/${cpp_pkg}/libhello-lib.so ${cpp_pkg}:hello-lib\
+ --compiler=mingw-gcc --output_groups=dynamic_library
+ assert_build ${cpp_pkg}:hello-world --compiler=mingw-gcc
+ ./bazel-bin/${cpp_pkg}/hello-world foo >& $TEST_log \
+ || fail "./bazel-bin/${cpp_pkg}/hello-world foo execution failed"
+ expect_log "Hello foo"
+ assert_test_ok "//examples/cpp:hello-success_test" --compiler=mingw-gcc
+ assert_test_fails "//examples/cpp:hello-fail_test" --compiler=mingw-gcc )
+}
+
function test_cpp_alwayslink() {
mkdir -p cpp/main
cat >cpp/main/BUILD <<EOF