tests: add workarounds for python brokenness on Windows

msys2 is broken only on clang, due to -Werror issues in the python
headers as patched by msys2.

MSVC is simply weird... due to the use of an unversioned platlib/purelib
directory, the python2 and python3 components overlap.
pull/11530/head
Eli Schwartz 2 years ago
parent 877d5ea8e0
commit 4e17d60d47
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
  1. 3
      unittests/baseplatformtests.py
  2. 8
      unittests/helpers.py
  3. 13
      unittests/pythontests.py

@ -484,3 +484,6 @@ class BasePlatformTests(TestCase):
def assertPathDoesNotExist(self, path):
m = f'Path {path!r} should not exist'
self.assertFalse(os.path.exists(path), msg=m)
def assertLength(self, val, length):
assert len(val) == length, f'{val} is not length {length}'

@ -204,3 +204,11 @@ def get_path_without_cmd(cmd: str, path: str) -> str:
paths.discard(dirname)
path = pathsep.join([str(p) for p in paths])
return path
def xfail_if_jobname(name: str):
if os.environ.get('MESON_CI_JOBNAME') == name:
return unittest.expectedFailure
def wrapper(func):
return func
return wrapper

@ -20,8 +20,9 @@ from run_tests import (
from .allplatformstests import git_init
from .baseplatformtests import BasePlatformTests
from .helpers import *
from mesonbuild.mesonlib import TemporaryDirectoryWinProof
from mesonbuild.mesonlib import MachineChoice, TemporaryDirectoryWinProof
class PythonTests(BasePlatformTests):
'''
@ -61,6 +62,9 @@ python = pymod.find_installation('python3', required: true)
def _test_bytecompile(self, py2=False):
testdir = os.path.join(self.src_root, 'test cases', 'python', '2 extmodule')
env = get_fake_env(testdir, self.builddir, self.prefix)
cc = detect_c_compiler(env, MachineChoice.HOST)
self.init(testdir, extra_args=['-Dpython2=auto', '-Dpython.bytecompile=1'])
self.build()
self.install()
@ -71,7 +75,11 @@ python = pymod.find_installation('python3', required: true)
realfile = os.path.join(root, file)
if file.endswith('.py'):
cached = glob.glob(realfile+'?') + glob.glob(os.path.join(root, '__pycache__', os.path.splitext(file)[0] + '*.pyc'))
self.assertEqual(len(cached), 2)
if cc.get_id() == 'msvc':
# MSVC python installs python2/python3 into the same directory
self.assertLength(cached, 4)
else:
self.assertLength(cached, 2)
count += 1
# there are 5 files x 2 installations
if py2:
@ -79,6 +87,7 @@ python = pymod.find_installation('python3', required: true)
else:
self.assertEqual(count, 5)
@xfail_if_jobname('msys2-clangx64ninja')
def test_bytecompile_multi(self):
if not shutil.which('python2'):
raise self.skipTest('python2 not installed')

Loading…
Cancel
Save