aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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')