aboutsummaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2023-05-02 20:40:13 -0400
committerEli Schwartz <eschwartz@archlinux.org>2023-05-02 22:09:25 -0400
commit4e17d60d47357b7e3a4fd772ce031cd7cd7bc57e (patch)
tree0fe95082a27a63c51eae980518f6c096d9780620 /unittests
parent877d5ea8e02c13bb606969d33d0491cfd4e08275 (diff)
downloadmeson-4e17d60d47357b7e3a4fd772ce031cd7cd7bc57e.zip
meson-4e17d60d47357b7e3a4fd772ce031cd7cd7bc57e.tar.gz
meson-4e17d60d47357b7e3a4fd772ce031cd7cd7bc57e.tar.bz2
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.
Diffstat (limited to 'unittests')
-rw-r--r--unittests/baseplatformtests.py3
-rw-r--r--unittests/helpers.py8
-rw-r--r--unittests/pythontests.py13
3 files changed, 22 insertions, 2 deletions
diff --git a/unittests/baseplatformtests.py b/unittests/baseplatformtests.py
index 9ab8083..b3572df 100644
--- a/unittests/baseplatformtests.py
+++ b/unittests/baseplatformtests.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}'
diff --git a/unittests/helpers.py b/unittests/helpers.py
index d3d1560..7483f51 100644
--- a/unittests/helpers.py
+++ b/unittests/helpers.py
@@ -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
diff --git a/unittests/pythontests.py b/unittests/pythontests.py
index 6f3f075..4b0581d 100644
--- a/unittests/pythontests.py
+++ b/unittests/pythontests.py
@@ -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')