diff --git a/test/lit.cfg b/test/lit.cfg
index a5bb350..456dafd 100644
--- a/test/lit.cfg
+++ b/test/lit.cfg
@@ -244,8 +244,20 @@ if platform.system() not in ['FreeBSD']:
 if execute_external:
     config.available_features.add('shell')
 
+# Check if this is msys bash.
+def is_bash_msys(bash):
+    if lit.getBashPath() == '':
+        return False
+
+    cmd = subprocess.Popen([bash, '-help', 'echo $MSYSTEM'], stdout=subprocess.PIPE)
+    for line in cmd.stdout:
+        # Example output: "GNU bash, version 3.1.0(1)-release-(i686-pc-msys)"
+        if re.match(r'GNU bash.*msys', line) is not None:
+            return True
+    return False
+
 # Exclude MSYS due to transforming '/' to 'X:/mingwroot/'.
-if not platform.system() in ['Windows'] or lit.getBashPath() == '':
+if not platform.system() in ['Windows'] or not is_bash_msys(lit.getBashPath()):
     config.available_features.add('shell-preserves-root')
 
 # ANSI escape sequences in non-dumb terminal
