Disable MSYS path conversion for Bazel integration tests as part of test setup; remove this from individual integration tests.

This prevents issues like https://stackoverflow.com/questions/48953956/building-bazel-on-a-windows-machine/49004265 for Windows integration tests.

PiperOrigin-RevId: 676022619
Change-Id: I8405baede1a2722505dcf65fc8d10c6e16a723a2
diff --git a/compile.sh b/compile.sh
index 41cd86e..4712355 100755
--- a/compile.sh
+++ b/compile.sh
@@ -29,6 +29,10 @@
 # a chance of overriding this in case they want to do so.
 : ${VERBOSE:=no}
 
+# Reset MSYS path conversion on Windows.
+unset MSYS_NO_PATHCONV
+unset MSYS2_ARG_CONV_EXCL
+
 source scripts/bootstrap/buildenv.sh
 
 mkdir -p output
diff --git a/src/main/starlark/tests/builtins_bzl/cc_builtin_tests.sh b/src/main/starlark/tests/builtins_bzl/cc_builtin_tests.sh
index 0adbd9b..2a9e331 100755
--- a/src/main/starlark/tests/builtins_bzl/cc_builtin_tests.sh
+++ b/src/main/starlark/tests/builtins_bzl/cc_builtin_tests.sh
@@ -56,13 +56,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 function test_starlark_cc() {
   setup_tests src/main/starlark/tests/builtins_bzl/cc
   mkdir -p "src/conditions"
diff --git a/src/test/shell/bazel/archive_contents_test.sh b/src/test/shell/bazel/archive_contents_test.sh
index 5ff714d..9f5955e 100755
--- a/src/test/shell/bazel/archive_contents_test.sh
+++ b/src/test/shell/bazel/archive_contents_test.sh
@@ -51,11 +51,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 #### SETUP #############################################################
 
 test_tar_utf8() {
diff --git a/src/test/shell/bazel/bazel_build_event_stream_test.sh b/src/test/shell/bazel/bazel_build_event_stream_test.sh
index 4a63b42..f477296 100755
--- a/src/test/shell/bazel/bazel_build_event_stream_test.sh
+++ b/src/test/shell/bazel/bazel_build_event_stream_test.sh
@@ -58,13 +58,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 function set_up() {
   mkdir -p pkg
   touch remote_file
diff --git a/src/test/shell/bazel/bazel_java17_test.sh b/src/test/shell/bazel/bazel_java17_test.sh
index a1cb3e3..c836759 100755
--- a/src/test/shell/bazel/bazel_java17_test.sh
+++ b/src/test/shell/bazel/bazel_java17_test.sh
@@ -49,11 +49,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 RULES_JAVA_REPO_NAME=$(cat "$(rlocation io_bazel/src/test/shell/bazel/RULES_JAVA_REPO_NAME)")
 JAVA_TOOLS_ZIP="$1"; shift
 JAVA_TOOLS_PREBUILT_ZIP="$1"; shift
diff --git a/src/test/shell/bazel/bazel_java_test.sh b/src/test/shell/bazel/bazel_java_test.sh
index d078df4..0fbe383 100755
--- a/src/test/shell/bazel/bazel_java_test.sh
+++ b/src/test/shell/bazel/bazel_java_test.sh
@@ -50,11 +50,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 JAVA_TOOLCHAIN="@bazel_tools//tools/jdk:toolchain"
 
 JAVA_TOOLCHAIN_TYPE="@bazel_tools//tools/jdk:toolchain_type"
diff --git a/src/test/shell/bazel/bazel_java_test_defaults.sh b/src/test/shell/bazel/bazel_java_test_defaults.sh
index 0d5b223..81889ab 100755
--- a/src/test/shell/bazel/bazel_java_test_defaults.sh
+++ b/src/test/shell/bazel/bazel_java_test_defaults.sh
@@ -52,11 +52,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 # Java source files version shall match --java_language_version_flag version.
 # Output class files shall be created in corresponding version (JDK 8, class version is 52).
 function test_default_java_toolchain_target_version() {
diff --git a/src/test/shell/bazel/bazel_java_test_defaults_prebuilt.sh b/src/test/shell/bazel/bazel_java_test_defaults_prebuilt.sh
index 7c33727..0750a607 100755
--- a/src/test/shell/bazel/bazel_java_test_defaults_prebuilt.sh
+++ b/src/test/shell/bazel/bazel_java_test_defaults_prebuilt.sh
@@ -52,10 +52,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
 
 # PREBUILT_TOOLCHAIN_CONFIGURATION shall use prebuilt ijar and singlejar binaries.
 function test_default_java_toolchain_prebuiltToolchain() {
diff --git a/src/test/shell/bazel/bazel_java_tools_dist_test.sh b/src/test/shell/bazel/bazel_java_tools_dist_test.sh
index a9c99cf..776dcb7 100755
--- a/src/test/shell/bazel/bazel_java_tools_dist_test.sh
+++ b/src/test/shell/bazel/bazel_java_tools_dist_test.sh
@@ -59,13 +59,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 function expect_path_in_java_tools() {
   path="$1"; shift
 
diff --git a/src/test/shell/bazel/bazel_java_tools_test.sh b/src/test/shell/bazel/bazel_java_tools_test.sh
index 08edf6f..22f3771 100755
--- a/src/test/shell/bazel/bazel_java_tools_test.sh
+++ b/src/test/shell/bazel/bazel_java_tools_test.sh
@@ -56,13 +56,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 function set_up() {
   local java_tools_rlocation=$(rlocation io_bazel/src/java_tools.zip)
   local java_tools_zip_file_url="file://${java_tools_rlocation}"
diff --git a/src/test/shell/bazel/bazel_rules_cc_test.sh b/src/test/shell/bazel/bazel_rules_cc_test.sh
index 55b7aa7..e034044 100755
--- a/src/test/shell/bazel/bazel_rules_cc_test.sh
+++ b/src/test/shell/bazel/bazel_rules_cc_test.sh
@@ -50,11 +50,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 function test_rules_cc_can_be_overridden() {
   # The bazelrc file might contain an --override_repository flag for rules_cc,
   # which would cause this test to fail to override the repo via a WORKSPACE file.
diff --git a/src/test/shell/bazel/bazel_rules_java_override_test.sh b/src/test/shell/bazel/bazel_rules_java_override_test.sh
index dc90641..bedf869 100755
--- a/src/test/shell/bazel/bazel_rules_java_override_test.sh
+++ b/src/test/shell/bazel/bazel_rules_java_override_test.sh
@@ -47,11 +47,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 RULES_JAVA_REPO_NAME=$(cat "$(rlocation io_bazel/src/test/shell/bazel/RULES_JAVA_REPO_NAME)")
 
 function setup_java_library_target() {
diff --git a/src/test/shell/bazel/bazel_rules_java_test.sh b/src/test/shell/bazel/bazel_rules_java_test.sh
index f1ad5ae..ecb340f 100755
--- a/src/test/shell/bazel/bazel_rules_java_test.sh
+++ b/src/test/shell/bazel/bazel_rules_java_test.sh
@@ -50,11 +50,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 function test_rules_java_can_be_overridden() {
   # The bazelrc file might contain an --override_repository flag for rules_java,
   # which would cause this test to fail to override the repo via a WORKSPACE file.
diff --git a/src/test/shell/bazel/bazel_rules_test.sh b/src/test/shell/bazel/bazel_rules_test.sh
index c0919ce..e350d05 100755
--- a/src/test/shell/bazel/bazel_rules_test.sh
+++ b/src/test/shell/bazel/bazel_rules_test.sh
@@ -59,13 +59,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 function test_sh_test() {
   mkdir -p a
   cat > a/BUILD <<EOF
diff --git a/src/test/shell/bazel/bazel_symlink_test.sh b/src/test/shell/bazel/bazel_symlink_test.sh
index e8dd789..3a875cb 100755
--- a/src/test/shell/bazel/bazel_symlink_test.sh
+++ b/src/test/shell/bazel/bazel_symlink_test.sh
@@ -61,13 +61,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 function expect_symlink() {
   local file=$1
 
diff --git a/src/test/shell/bazel/bazel_ui_test.sh b/src/test/shell/bazel/bazel_ui_test.sh
index f8da11f..fe84f58 100755
--- a/src/test/shell/bazel/bazel_ui_test.sh
+++ b/src/test/shell/bazel/bazel_ui_test.sh
@@ -56,13 +56,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 #### SETUP #############################################################
 
 add_to_bazelrc "build --genrule_strategy=local"
diff --git a/src/test/shell/bazel/bazel_windows_example_test.sh b/src/test/shell/bazel/bazel_windows_example_test.sh
index 401dede..cfb7caa 100755
--- a/src/test/shell/bazel/bazel_windows_example_test.sh
+++ b/src/test/shell/bazel/bazel_windows_example_test.sh
@@ -58,13 +58,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 if ! "$is_windows"; then
   echo "This test suite requires running on Windows. But now is ${PLATFORM}" >&2
   exit 0
@@ -75,8 +68,6 @@
 function set_up() {
   copy_examples
   setup_bazelrc
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
   add_platforms "MODULE.bazel"
   mkdir platforms
   cat >platforms/BUILD <<EOF
diff --git a/src/test/shell/bazel/bazel_with_jdk_test.sh b/src/test/shell/bazel/bazel_with_jdk_test.sh
index 1f5ccf7..b82efa8 100755
--- a/src/test/shell/bazel/bazel_with_jdk_test.sh
+++ b/src/test/shell/bazel/bazel_with_jdk_test.sh
@@ -58,13 +58,6 @@
 esac
 
 if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
-if "$is_windows"; then
   EXE_EXT=".exe"
 else
   EXE_EXT=""
diff --git a/src/test/shell/bazel/check_external_files_test.sh b/src/test/shell/bazel/check_external_files_test.sh
index 7e0f37c..0b791a7 100755
--- a/src/test/shell/bazel/check_external_files_test.sh
+++ b/src/test/shell/bazel/check_external_files_test.sh
@@ -51,11 +51,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 function get_extrepourl() {
   if $is_windows; then
     echo "file:///$(cygpath -m $1)"
diff --git a/src/test/shell/bazel/external_patching_test.sh b/src/test/shell/bazel/external_patching_test.sh
index 809b882..ba20b7c 100755
--- a/src/test/shell/bazel/external_patching_test.sh
+++ b/src/test/shell/bazel/external_patching_test.sh
@@ -56,19 +56,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
-
-if $is_windows; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 set_up() {
   WRKDIR=$(mktemp -d "${TEST_TMPDIR}/testXXXXXX")
   cd "${WRKDIR}"
diff --git a/src/test/shell/bazel/external_remote_file_test.sh b/src/test/shell/bazel/external_remote_file_test.sh
index 51c6abe..203ebb5 100755
--- a/src/test/shell/bazel/external_remote_file_test.sh
+++ b/src/test/shell/bazel/external_remote_file_test.sh
@@ -56,19 +56,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
-
-if $is_windows; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 function set_up() {
   WRKDIR=$(mktemp -d "${TEST_TMPDIR}/testXXXXXX")
   cd "${WRKDIR}"
diff --git a/src/test/shell/bazel/new_local_repo_test.sh b/src/test/shell/bazel/new_local_repo_test.sh
index 7447e0c..8aff660 100755
--- a/src/test/shell/bazel/new_local_repo_test.sh
+++ b/src/test/shell/bazel/new_local_repo_test.sh
@@ -55,13 +55,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 # Regression test for GitHub issue #6351, see
 # https://github.com/bazelbuild/bazel/issues/6351#issuecomment-465488344
 function test_glob_in_synthesized_build_file() {
diff --git a/src/test/shell/bazel/python_version_test.sh b/src/test/shell/bazel/python_version_test.sh
index eb8bd32..748d065 100755
--- a/src/test/shell/bazel/python_version_test.sh
+++ b/src/test/shell/bazel/python_version_test.sh
@@ -58,13 +58,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 #### TESTS #############################################################
 
 # Check that our environment setup works.
diff --git a/src/test/shell/bazel/remote/build_without_the_bytes_test.sh b/src/test/shell/bazel/remote/build_without_the_bytes_test.sh
index 45fdd65..a9ae20e 100755
--- a/src/test/shell/bazel/remote/build_without_the_bytes_test.sh
+++ b/src/test/shell/bazel/remote/build_without_the_bytes_test.sh
@@ -63,8 +63,6 @@
 esac
 
 if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
   declare -r EXE_EXT=".exe"
 else
   declare -r EXE_EXT=""
diff --git a/src/test/shell/bazel/remote/remote_build_event_uploader_test.sh b/src/test/shell/bazel/remote/remote_build_event_uploader_test.sh
index c647f3a..2c2a3db 100755
--- a/src/test/shell/bazel/remote/remote_build_event_uploader_test.sh
+++ b/src/test/shell/bazel/remote/remote_build_event_uploader_test.sh
@@ -64,8 +64,6 @@
 esac
 
 if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
   declare -r EXE_EXT=".exe"
 else
   declare -r EXE_EXT=""
diff --git a/src/test/shell/bazel/remote/remote_execution_test.sh b/src/test/shell/bazel/remote/remote_execution_test.sh
index 266f6f3..04030f4 100755
--- a/src/test/shell/bazel/remote/remote_execution_test.sh
+++ b/src/test/shell/bazel/remote/remote_execution_test.sh
@@ -65,8 +65,6 @@
 esac
 
 if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
   declare -r EXE_EXT=".exe"
 else
   declare -r EXE_EXT=""
diff --git a/src/test/shell/bazel/resource_compiler_toolchain_test.sh b/src/test/shell/bazel/resource_compiler_toolchain_test.sh
index 11ba203..7cc6084 100755
--- a/src/test/shell/bazel/resource_compiler_toolchain_test.sh
+++ b/src/test/shell/bazel/resource_compiler_toolchain_test.sh
@@ -49,13 +49,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 function _create_pkg() {
   # Define dummy CPU and OS constraints (cpu1 and cpu2, and os1 and os2).
   # Also define platforms for each combination.
diff --git a/src/test/shell/bazel/rule_test_test.sh b/src/test/shell/bazel/rule_test_test.sh
index a398b9f..fd219f3 100755
--- a/src/test/shell/bazel/rule_test_test.sh
+++ b/src/test/shell/bazel/rule_test_test.sh
@@ -42,11 +42,6 @@
 source "$(rlocation "io_bazel/src/test/shell/integration_test_setup.sh")" \
   || { echo "integration_test_setup.sh not found!" >&2; exit 1; }
 
-function set_up() {
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-}
-
 function test_local_rule_test_in_root() {
   cat > BUILD <<EOF
 genrule(
diff --git a/src/test/shell/bazel/run_test.sh b/src/test/shell/bazel/run_test.sh
index a7e6e8b..ae3d011 100755
--- a/src/test/shell/bazel/run_test.sh
+++ b/src/test/shell/bazel/run_test.sh
@@ -49,11 +49,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 # ------------------------------------------------------------------------------
 # TESTS
 # ------------------------------------------------------------------------------
diff --git a/src/test/shell/bazel/starlark_git_repository_test.sh b/src/test/shell/bazel/starlark_git_repository_test.sh
index 910b641..ba4cc37 100755
--- a/src/test/shell/bazel/starlark_git_repository_test.sh
+++ b/src/test/shell/bazel/starlark_git_repository_test.sh
@@ -58,8 +58,6 @@
 esac
 
 if $is_windows; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
   # Enable symlink runfiles tree to make bazel run work
   add_to_bazelrc "build --enable_runfiles"
 fi
diff --git a/src/test/shell/bazel/starlark_repository_test.sh b/src/test/shell/bazel/starlark_repository_test.sh
index fe2ea91..83c9bee 100755
--- a/src/test/shell/bazel/starlark_repository_test.sh
+++ b/src/test/shell/bazel/starlark_repository_test.sh
@@ -56,13 +56,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 source "$(rlocation "io_bazel/src/test/shell/bazel/remote_helpers.sh")" \
   || { echo "remote_helpers.sh not found!" >&2; exit 1; }
 
diff --git a/src/test/shell/bazel/unicode_filenames_test.sh b/src/test/shell/bazel/unicode_filenames_test.sh
index 75ce8ff..0db4934 100755
--- a/src/test/shell/bazel/unicode_filenames_test.sh
+++ b/src/test/shell/bazel/unicode_filenames_test.sh
@@ -50,10 +50,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
 
 #### SETUP #############################################################
 
diff --git a/src/test/shell/bazel/windows_arg_esc_test.sh b/src/test/shell/bazel/windows_arg_esc_test.sh
index 0377f14..fcc4f2d 100755
--- a/src/test/shell/bazel/windows_arg_esc_test.sh
+++ b/src/test/shell/bazel/windows_arg_esc_test.sh
@@ -55,14 +55,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
-
 function create_pkg() {
   if [[ -d foo ]]; then
     return
diff --git a/src/test/shell/integration/action_aspect_test.sh b/src/test/shell/integration/action_aspect_test.sh
index bab9b46..775c8ae 100755
--- a/src/test/shell/integration/action_aspect_test.sh
+++ b/src/test/shell/integration/action_aspect_test.sh
@@ -51,11 +51,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 add_to_bazelrc "build --package_path=%workspace%"
 
 function test_directory_args_inspection() {
diff --git a/src/test/shell/integration/analysis_phase_options_test.sh b/src/test/shell/integration/analysis_phase_options_test.sh
index a09b89e..877fbce 100755
--- a/src/test/shell/integration/analysis_phase_options_test.sh
+++ b/src/test/shell/integration/analysis_phase_options_test.sh
@@ -52,11 +52,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 #### HELPER FUNCTIONS ##################################################
 
 if ! type try_with_timeout >&/dev/null; then
diff --git a/src/test/shell/integration/analysis_test_test.sh b/src/test/shell/integration/analysis_test_test.sh
index 032d9bd..044e4c5 100755
--- a/src/test/shell/integration/analysis_test_test.sh
+++ b/src/test/shell/integration/analysis_test_test.sh
@@ -52,11 +52,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 function test_passing_test() {
   mkdir -p package
   cat > package/test.bzl <<EOF
diff --git a/src/test/shell/integration/aquery_test.sh b/src/test/shell/integration/aquery_test.sh
index 38a31f5..65a1eab 100755
--- a/src/test/shell/integration/aquery_test.sh
+++ b/src/test/shell/integration/aquery_test.sh
@@ -43,11 +43,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 add_to_bazelrc "build --package_path=%workspace%"
 
 function has_iso_8859_1_locale() {
diff --git a/src/test/shell/integration/aspect_test.sh b/src/test/shell/integration/aspect_test.sh
index 03e8bb4..1d2782b 100755
--- a/src/test/shell/integration/aspect_test.sh
+++ b/src/test/shell/integration/aspect_test.sh
@@ -50,8 +50,6 @@
 esac
 
 if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
   declare -r EXE_EXT=".exe"
 else
   declare -r EXE_EXT=""
diff --git a/src/test/shell/integration/bazel_aquery_test.sh b/src/test/shell/integration/bazel_aquery_test.sh
index cb21812..4759798 100755
--- a/src/test/shell/integration/bazel_aquery_test.sh
+++ b/src/test/shell/integration/bazel_aquery_test.sh
@@ -43,11 +43,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 add_to_bazelrc "build --package_path=%workspace%"
 
 
diff --git a/src/test/shell/integration/bazel_javabase_test.sh b/src/test/shell/integration/bazel_javabase_test.sh
index e71302d..bd585da 100755
--- a/src/test/shell/integration/bazel_javabase_test.sh
+++ b/src/test/shell/integration/bazel_javabase_test.sh
@@ -56,14 +56,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
-
 function test_use_depot_javabase() {
   bazel --batch version >& $TEST_log || fail "Couldn't run ${PRODUCT_NAME}"
   expect_not_log "Couldn't find java at"
diff --git a/src/test/shell/integration/bazel_query_test.sh b/src/test/shell/integration/bazel_query_test.sh
index 2d6b3e2..b7a428d 100755
--- a/src/test/shell/integration/bazel_query_test.sh
+++ b/src/test/shell/integration/bazel_query_test.sh
@@ -57,13 +57,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 function set_up() {
   add_to_bazelrc "build --package_path=%workspace%"
   add_bazel_skylib "MODULE.bazel"
diff --git a/src/test/shell/integration/bazel_testjobs_test.sh b/src/test/shell/integration/bazel_testjobs_test.sh
index 880c3ce..b3b06a1 100755
--- a/src/test/shell/integration/bazel_testjobs_test.sh
+++ b/src/test/shell/integration/bazel_testjobs_test.sh
@@ -49,11 +49,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 add_to_bazelrc "test --nocache_test_results"
 
 # End of preamble.
diff --git a/src/test/shell/integration/builtins_injection_test.sh b/src/test/shell/integration/builtins_injection_test.sh
index 8c68fce..2771691 100755
--- a/src/test/shell/integration/builtins_injection_test.sh
+++ b/src/test/shell/integration/builtins_injection_test.sh
@@ -58,13 +58,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 # override rules_java in bazel otherwise no build succeeds without injection
 [[ $(type -t mock_rules_java_to_avoid_downloading) == function ]] && mock_rules_java_to_avoid_downloading
 
diff --git a/src/test/shell/integration/configured_query_test.sh b/src/test/shell/integration/configured_query_test.sh
index c8d0fde..1a2932f 100755
--- a/src/test/shell/integration/configured_query_test.sh
+++ b/src/test/shell/integration/configured_query_test.sh
@@ -53,11 +53,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 add_to_bazelrc "build --package_path=%workspace%"
 
 #### TESTS #############################################################
diff --git a/src/test/shell/integration/cpp_test.sh b/src/test/shell/integration/cpp_test.sh
index 28076f1..96c5399 100755
--- a/src/test/shell/integration/cpp_test.sh
+++ b/src/test/shell/integration/cpp_test.sh
@@ -49,11 +49,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 if ! type try_with_timeout >&/dev/null; then
   # Bazel's testenv.sh defines try_with_timeout but the Google-internal version
   # uses a different testenv.sh.
diff --git a/src/test/shell/integration/dump_test.sh b/src/test/shell/integration/dump_test.sh
index 50b63e6..594bb06 100755
--- a/src/test/shell/integration/dump_test.sh
+++ b/src/test/shell/integration/dump_test.sh
@@ -51,11 +51,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 function set_up() {
   # So that each test starts with a clean slate. Important so that the output of
   # dumping various things is predictable.
diff --git a/src/test/shell/integration/execution_phase_tests.sh b/src/test/shell/integration/execution_phase_tests.sh
index 1c8e5e5..f4f47bf 100755
--- a/src/test/shell/integration/execution_phase_tests.sh
+++ b/src/test/shell/integration/execution_phase_tests.sh
@@ -41,11 +41,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 #### HELPER FUNCTIONS ##################################################
 
 if ! type try_with_timeout >&/dev/null; then
diff --git a/src/test/shell/integration/execution_strategies_test.sh b/src/test/shell/integration/execution_strategies_test.sh
index 14a57ba..4ecb548 100755
--- a/src/test/shell/integration/execution_strategies_test.sh
+++ b/src/test/shell/integration/execution_strategies_test.sh
@@ -53,11 +53,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 # Tests that you can set the spawn strategy flags to a list of strategies.
 function test_multiple_strategies() {
   SERVER_LOG=$(bazel info server_log)
diff --git a/src/test/shell/integration/focus_test.sh b/src/test/shell/integration/focus_test.sh
index 478846c..6291c5e 100755
--- a/src/test/shell/integration/focus_test.sh
+++ b/src/test/shell/integration/focus_test.sh
@@ -50,11 +50,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 add_to_bazelrc "build --experimental_enable_skyfocus"
 add_to_bazelrc "build --genrule_strategy=local"
 add_to_bazelrc "test --test_strategy=standalone"
diff --git a/src/test/shell/integration/implicit_dependency_reporting_test.sh b/src/test/shell/integration/implicit_dependency_reporting_test.sh
index 0bf759d..c431f03 100755
--- a/src/test/shell/integration/implicit_dependency_reporting_test.sh
+++ b/src/test/shell/integration/implicit_dependency_reporting_test.sh
@@ -50,11 +50,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 #### SETUP #############################################################
 
 test_custom_message() {
diff --git a/src/test/shell/integration/jvm_flags_escaping_test.sh b/src/test/shell/integration/jvm_flags_escaping_test.sh
index 768b507..dc37a37 100755
--- a/src/test/shell/integration/jvm_flags_escaping_test.sh
+++ b/src/test/shell/integration/jvm_flags_escaping_test.sh
@@ -56,10 +56,6 @@
 esac
 
 if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
   declare -r EXE_EXT=".exe"
 else
   declare -r EXE_EXT=""
diff --git a/src/test/shell/integration/loading_phase_test.sh b/src/test/shell/integration/loading_phase_test.sh
index 7298c1a..48a37f1 100755
--- a/src/test/shell/integration/loading_phase_test.sh
+++ b/src/test/shell/integration/loading_phase_test.sh
@@ -52,11 +52,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 output_base=$TEST_TMPDIR/out
 TEST_stderr=$(dirname $TEST_log)/stderr
 
diff --git a/src/test/shell/integration/modify_execution_info_test.sh b/src/test/shell/integration/modify_execution_info_test.sh
index 5038e42..d8b16fb 100755
--- a/src/test/shell/integration/modify_execution_info_test.sh
+++ b/src/test/shell/integration/modify_execution_info_test.sh
@@ -51,11 +51,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 #### HELPER FUNCTIONS ##################################################
 
 if ! type try_with_timeout >&/dev/null; then
diff --git a/src/test/shell/integration/nestedset_as_skykey_test.sh b/src/test/shell/integration/nestedset_as_skykey_test.sh
index 567aca2..b651069 100755
--- a/src/test/shell/integration/nestedset_as_skykey_test.sh
+++ b/src/test/shell/integration/nestedset_as_skykey_test.sh
@@ -52,11 +52,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 #### HELPER FUNCTIONS ##################################################
 
 if ! type try_with_timeout >&/dev/null; then
diff --git a/src/test/shell/integration/nojdk_startup_options_test.sh b/src/test/shell/integration/nojdk_startup_options_test.sh
index 3332d85..cd8c0ba 100755
--- a/src/test/shell/integration/nojdk_startup_options_test.sh
+++ b/src/test/shell/integration/nojdk_startup_options_test.sh
@@ -55,11 +55,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 # Test that nojdk bazel works with --autodetect_server_javabase
 function test_autodetect_server_javabase() {
   bazel --autodetect_server_javabase version &> $TEST_log || fail "Should pass"
diff --git a/src/test/shell/integration/nonincremental_builds_test.sh b/src/test/shell/integration/nonincremental_builds_test.sh
index 9bb3fe6..d208c9b 100755
--- a/src/test/shell/integration/nonincremental_builds_test.sh
+++ b/src/test/shell/integration/nonincremental_builds_test.sh
@@ -57,13 +57,6 @@
 esac
 
 if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
-if "$is_windows"; then
   EXE_EXT=".exe"
 else
   EXE_EXT=""
diff --git a/src/test/shell/integration/output_filter_test.sh b/src/test/shell/integration/output_filter_test.sh
index f17d9f2..aa0b630 100755
--- a/src/test/shell/integration/output_filter_test.sh
+++ b/src/test/shell/integration/output_filter_test.sh
@@ -52,11 +52,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 function test_output_filter_cc() {
   # "test warning filter for C compilation"
   local -r pkg=$FUNCNAME
diff --git a/src/test/shell/integration/outputs_test.sh b/src/test/shell/integration/outputs_test.sh
index 6dbb62b..d35cb6c 100755
--- a/src/test/shell/integration/outputs_test.sh
+++ b/src/test/shell/integration/outputs_test.sh
@@ -58,13 +58,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 #### TESTS #############################################################
 
 function test_plain_outputs() {
diff --git a/src/test/shell/integration/param_file_flag_per_line_test.sh b/src/test/shell/integration/param_file_flag_per_line_test.sh
index dad652b..97f63d6 100755
--- a/src/test/shell/integration/param_file_flag_per_line_test.sh
+++ b/src/test/shell/integration/param_file_flag_per_line_test.sh
@@ -51,10 +51,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
 
 add_to_bazelrc "build --package_path=%workspace%"
 
diff --git a/src/test/shell/integration/platform_based_flags_test.sh b/src/test/shell/integration/platform_based_flags_test.sh
index 0c4fc3f..65b5b29 100755
--- a/src/test/shell/integration/platform_based_flags_test.sh
+++ b/src/test/shell/integration/platform_based_flags_test.sh
@@ -50,11 +50,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 function set_up() {
   # Clean the bazelrc since some tests modify it
   write_default_bazelrc
diff --git a/src/test/shell/integration/progress_reporting_test.sh b/src/test/shell/integration/progress_reporting_test.sh
index 65ba345..be325e7 100755
--- a/src/test/shell/integration/progress_reporting_test.sh
+++ b/src/test/shell/integration/progress_reporting_test.sh
@@ -51,8 +51,6 @@
 esac
 
 if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
   declare -r WORKSPACE_STATUS="$(cygpath -m "$(mktemp -d "${TEST_TMPDIR}/wscXXXXXXXX")/wsc.bat")"
   touch "$WORKSPACE_STATUS"
 else
diff --git a/src/test/shell/integration/py_args_escaping_test.sh b/src/test/shell/integration/py_args_escaping_test.sh
index 9d6e588..69a74dd 100755
--- a/src/test/shell/integration/py_args_escaping_test.sh
+++ b/src/test/shell/integration/py_args_escaping_test.sh
@@ -56,10 +56,6 @@
 esac
 
 if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
   declare -r EXE_EXT=".exe"
 else
   declare -r EXE_EXT=""
diff --git a/src/test/shell/integration/python_stub_test.sh b/src/test/shell/integration/python_stub_test.sh
index f089307..8264794 100755
--- a/src/test/shell/integration/python_stub_test.sh
+++ b/src/test/shell/integration/python_stub_test.sh
@@ -50,8 +50,6 @@
 esac
 
 if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
   declare -r EXE_EXT=".exe"
 else
   declare -r EXE_EXT=""
diff --git a/src/test/shell/integration/python_test.sh b/src/test/shell/integration/python_test.sh
index c3afe22..47410a9 100755
--- a/src/test/shell/integration/python_test.sh
+++ b/src/test/shell/integration/python_test.sh
@@ -50,8 +50,6 @@
 esac
 
 if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
   declare -r EXE_EXT=".exe"
 else
   declare -r EXE_EXT=""
diff --git a/src/test/shell/integration/rc_options_test.sh b/src/test/shell/integration/rc_options_test.sh
index e6f7e71..ba5433c 100755
--- a/src/test/shell/integration/rc_options_test.sh
+++ b/src/test/shell/integration/rc_options_test.sh
@@ -51,11 +51,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 #### SETUP #############################################################
 
 add_to_bazelrc "build --terminal_columns=6"
diff --git a/src/test/shell/integration/run_test.sh b/src/test/shell/integration/run_test.sh
index 5f768be..95d8353 100755
--- a/src/test/shell/integration/run_test.sh
+++ b/src/test/shell/integration/run_test.sh
@@ -53,11 +53,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 add_to_bazelrc "test --notest_loasd"
 
 #### HELPER FUNCTIONS ##################################################
diff --git a/src/test/shell/integration/runfiles_test.sh b/src/test/shell/integration/runfiles_test.sh
index a4447a6..5fdb392 100755
--- a/src/test/shell/integration/runfiles_test.sh
+++ b/src/test/shell/integration/runfiles_test.sh
@@ -57,8 +57,6 @@
 # counts and manifest checks in test_foo_runfiles.
 # TODO(#8169): Update this test and remove the toolchain opt-out.
 if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
   export EXT=".exe"
   export EXTRA_STARTUP_FLAGS="--windows_enable_symlinks"
   export EXTRA_BUILD_FLAGS="--incompatible_use_python_toolchains=false \
diff --git a/src/test/shell/integration/server_logging_test.sh b/src/test/shell/integration/server_logging_test.sh
index d662dac..a110cef 100755
--- a/src/test/shell/integration/server_logging_test.sh
+++ b/src/test/shell/integration/server_logging_test.sh
@@ -57,13 +57,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 #### TESTS #############################################################
 
 function test_log_file_uses_single_line_formatter() {
diff --git a/src/test/shell/integration/starlark_configurations_external_workspaces_test.sh b/src/test/shell/integration/starlark_configurations_external_workspaces_test.sh
index 11e7ce4..6f125b3 100755
--- a/src/test/shell/integration/starlark_configurations_external_workspaces_test.sh
+++ b/src/test/shell/integration/starlark_configurations_external_workspaces_test.sh
@@ -54,10 +54,6 @@
   declare -r is_windows=false
   ;;
 esac
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
 
 add_to_bazelrc "build --package_path=%workspace%"
 
diff --git a/src/test/shell/integration/starlark_configurations_test.sh b/src/test/shell/integration/starlark_configurations_test.sh
index 6017335..c744451 100755
--- a/src/test/shell/integration/starlark_configurations_test.sh
+++ b/src/test/shell/integration/starlark_configurations_test.sh
@@ -51,11 +51,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 function set_up() {
   write_default_bazelrc
   add_to_bazelrc "build --package_path=%workspace%"
diff --git a/src/test/shell/integration/starlark_dependency_pruning_test.sh b/src/test/shell/integration/starlark_dependency_pruning_test.sh
index 71e1668..ceb8446 100755
--- a/src/test/shell/integration/starlark_dependency_pruning_test.sh
+++ b/src/test/shell/integration/starlark_dependency_pruning_test.sh
@@ -49,11 +49,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 add_to_bazelrc "build --package_path=%workspace%"
 add_to_bazelrc "build --spawn_strategy=local"
 
diff --git a/src/test/shell/integration/starlark_flag_test.sh b/src/test/shell/integration/starlark_flag_test.sh
index ab59a25..64ee82b 100755
--- a/src/test/shell/integration/starlark_flag_test.sh
+++ b/src/test/shell/integration/starlark_flag_test.sh
@@ -61,13 +61,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 # Text that will be appended to every print() output when the flag is enabled.
 MARKER="<== Starlark flag test ==>"
 
diff --git a/src/test/shell/integration/startup_options_test.sh b/src/test/shell/integration/startup_options_test.sh
index b2cdd6d..3d2aec6 100755
--- a/src/test/shell/integration/startup_options_test.sh
+++ b/src/test/shell/integration/startup_options_test.sh
@@ -50,11 +50,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 function test_different_startup_options() {
   pid=$(bazel --nobatch info server_pid 2> $TEST_log)
   [[ -n $pid ]] || fail "Couldn't run ${PRODUCT_NAME}"
diff --git a/src/test/shell/integration/subrules_test.sh b/src/test/shell/integration/subrules_test.sh
index c18ffac..0fe1e88 100755
--- a/src/test/shell/integration/subrules_test.sh
+++ b/src/test/shell/integration/subrules_test.sh
@@ -50,11 +50,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 function set_up() {
   mkdir -p subrule_testing
   cat > subrule_testing/rule.bzl <<EOF
diff --git a/src/test/shell/integration/target_compatible_with_test.sh b/src/test/shell/integration/target_compatible_with_test.sh
index c3dc96e..a96c01b 100755
--- a/src/test/shell/integration/target_compatible_with_test.sh
+++ b/src/test/shell/integration/target_compatible_with_test.sh
@@ -58,11 +58,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 function set_up() {
   add_platforms "MODULE.bazel"
   mkdir -p target_skipping || fail "couldn't create directory"
diff --git a/src/test/shell/integration/target_compatible_with_test_external_repo.sh b/src/test/shell/integration/target_compatible_with_test_external_repo.sh
index ab2b5f5..79a3710 100755
--- a/src/test/shell/integration/target_compatible_with_test_external_repo.sh
+++ b/src/test/shell/integration/target_compatible_with_test_external_repo.sh
@@ -45,11 +45,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 function set_up() {
   mkdir -p target_skipping || fail "couldn't create directory"
   touch target_skipping/MODULE.bazel
diff --git a/src/test/shell/integration/target_pattern_file_test.sh b/src/test/shell/integration/target_pattern_file_test.sh
index 29eff8d..2fca88b 100755
--- a/src/test/shell/integration/target_pattern_file_test.sh
+++ b/src/test/shell/integration/target_pattern_file_test.sh
@@ -55,13 +55,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 add_to_bazelrc "build --package_path=%workspace%"
 
 #### SETUP #############################################################
diff --git a/src/test/shell/integration/test_test.sh b/src/test/shell/integration/test_test.sh
index 465c559..046a0f3 100755
--- a/src/test/shell/integration/test_test.sh
+++ b/src/test/shell/integration/test_test.sh
@@ -55,13 +55,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  # Disable MSYS path conversion that converts path-looking command arguments to
-  # Windows paths (even if they arguments are not in fact paths).
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 #### TESTS #############################################################
 
 function test_passing_test_is_reported_correctly() {
diff --git a/src/test/shell/integration/validation_actions_test.sh b/src/test/shell/integration/validation_actions_test.sh
index b48df69..a7cd089 100755
--- a/src/test/shell/integration/validation_actions_test.sh
+++ b/src/test/shell/integration/validation_actions_test.sh
@@ -48,11 +48,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 function setup_test_project() {
   mkdir -p validation_actions
 
diff --git a/src/test/shell/integration/workspace_status_test.sh b/src/test/shell/integration/workspace_status_test.sh
index c10cc23..39692fe 100755
--- a/src/test/shell/integration/workspace_status_test.sh
+++ b/src/test/shell/integration/workspace_status_test.sh
@@ -54,11 +54,6 @@
   ;;
 esac
 
-if "$is_windows"; then
-  export MSYS_NO_PATHCONV=1
-  export MSYS2_ARG_CONV_EXCL="*"
-fi
-
 add_to_bazelrc "build --package_path=%workspace%"
 
 #### TESTS #############################################################
diff --git a/src/test/shell/testenv.sh b/src/test/shell/testenv.sh
index fb260df..a534df5 100755
--- a/src/test/shell/testenv.sh
+++ b/src/test/shell/testenv.sh
@@ -58,6 +58,11 @@
 
   export JAVA_HOME="${JAVA_HOME:-$(ls -d C:/Program\ Files/Java/jdk* | sort | tail -n 1)}"
   export BAZEL_SH="$(cygpath -m /usr/bin/bash)"
+
+  # Disable MSYS path conversion that converts path-looking command arguments to
+  # Windows paths (even if they arguments are not in fact paths).
+  export MSYS_NO_PATHCONV=1
+  export MSYS2_ARG_CONV_EXCL="*"
 fi
 
 # Make the command "bazel" available for tests.