22
33import os
44import sys
5+ import sysconfig
56import threading
67import unittest .mock as mock
78from distutils import _msvccompiler
89from distutils .errors import DistutilsPlatformError
910from distutils .tests import support
11+ from distutils .util import get_platform
1012
1113import pytest
1214
@@ -28,6 +30,30 @@ def _find_vcvarsall(plat_spec):
2830 'wont find this version' ,
2931 )
3032
33+ @pytest .mark .skipif (
34+ not sysconfig .get_platform ().startswith ("win" ),
35+ reason = "Only run test for non-mingw Windows platforms" ,
36+ )
37+ @pytest .mark .parametrize (
38+ "plat_name, expected" ,
39+ [
40+ ("win-arm64" , "win-arm64" ),
41+ ("win-amd64" , "win-amd64" ),
42+ (None , get_platform ()),
43+ ],
44+ )
45+ def test_cross_platform_compilation_paths (self , monkeypatch , plat_name , expected ):
46+ """
47+ Ensure a specified target platform is passed to _get_vcvars_spec.
48+ """
49+ compiler = _msvccompiler .MSVCCompiler ()
50+
51+ def _get_vcvars_spec (host_platform , platform ):
52+ assert platform == expected
53+
54+ monkeypatch .setattr (_msvccompiler , '_get_vcvars_spec' , _get_vcvars_spec )
55+ compiler .initialize (plat_name )
56+
3157 @needs_winreg
3258 def test_get_vc_env_unicode (self ):
3359 test_var = 'ṰḖṤṪ┅ṼẨṜ'
0 commit comments