Repository: tox-dev/tox

Issue:
MSYSTEM is not passed by default on Windows
## Summary

I discovered this when people started reporting breakage when they run `check-manifest` from `tox`, from a Git for Windows `bash.exe` shell: https://github.com/mgedmin/check-manifest/issues/64

When you run `git.exe` on Windows, the way it prints filenames depends on the environment.  If `MSYSTEM` is set to `MINGW64`, the filenames are printed in the standard Windows fashion (e.g. `C:\Users\...`).  When `MSYSTEM` is not set, filenames are printed in the Unix fashion (`/c/Users/...`).

`check-manifest` runs `git` in a subprocess to enumerate submodules and versioned files.  This works fine, except when `tox` clears the environment, things break.

I think MSYSTEM should be included in tox's default `passenv` list, since it describes system configuration (sort of like TERM, or LC_CTYPE) and a wrong value breaks things.

## Steps to reproduce

- get a Windows VM
- install Git for Windows
- install Python
- install tox
- launch Git Bash
- `git clone https://github.com/mgedmin/check-manifest`
- `cd check-manifest`
- `git checkout 0.34`  # master has a workaround for this
- `tox --develop -e py27 -- tests:TestGit.test_get_versioned_files_with_git_submodules`

## Expected output

- tox indicates it ran 1 test successfully

## Actual output

- tox shows a test failure where `subprocess.Popen(..., cwd=...)` says the directory name is invalid.

Discussion:

Patch:
diff --git a/doc/config.txt b/doc/config.txt
index 1cc6d3d0..2a7a1465 100644
--- a/doc/config.txt
+++ b/doc/config.txt
@@ -220,7 +220,7 @@ Complete list of settings that you can put into ``testenv*`` sections:
    * passed through on all platforms: ``PATH``, ``LANG``, ``LANGUAGE``,
      ``LD_LIBRARY_PATH``, ``PIP_INDEX_URL``
    * Windows: ``SYSTEMDRIVE``, ``SYSTEMROOT``, ``PATHEXT``, ``TEMP``, ``TMP``
-      ``NUMBER_OF_PROCESSORS``, ``USERPROFILE``
+      ``NUMBER_OF_PROCESSORS``, ``USERPROFILE``, ``MSYSTEM``
    * Others (e.g. UNIX, macOS): ``TMPDIR``
 
    You can override these variables with the ``setenv`` option.
diff --git a/tox/config.py b/tox/config.py
index 2f5d52ac..33bf14f2 100755
--- a/tox/config.py
+++ b/tox/config.py
@@ -492,7 +492,8 @@ def tox_addoption(parser):
             # for `multiprocessing.cpu_count()` on Windows
             # (prior to Python 3.4).
             passenv.add("NUMBER_OF_PROCESSORS")
-            passenv.add("USERPROFILE")  # needed for `os.path.expanduser()`.
+            passenv.add("USERPROFILE")  # needed for `os.path.expanduser()`
+            passenv.add("MSYSTEM")      # fixes #429
         else:
             passenv.add("TMPDIR")
         for spec in value:


Test patch:
diff --git a/tests/test_config.py b/tests/test_config.py
index 54d11367..3416d0d4 100644
--- a/tests/test_config.py
+++ b/tests/test_config.py
@@ -876,6 +876,7 @@ class TestConfigTestEnv:
             assert "TMP" in envconfig.passenv
             assert "NUMBER_OF_PROCESSORS" in envconfig.passenv
             assert "USERPROFILE" in envconfig.passenv
+            assert "MSYSTEM" in envconfig.passenv
         else:
             assert "TMPDIR" in envconfig.passenv
         assert "PATH" in envconfig.passenv