aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorNirbheek Chauhan <nirbheek@centricular.com>2020-09-08 19:05:50 +0530
committerNirbheek Chauhan <nirbheek.chauhan@gmail.com>2020-09-10 08:18:16 +0000
commitfb7099c6cf5a7ad43da1ad83c28567ecfb70809f (patch)
treeb92fe74badcb56854370f83fbc3235b64f1b4412 /mesonbuild
parent36600d7465e854c6f3d7fc824a7fa5d4415a6292 (diff)
downloadmeson-fb7099c6cf5a7ad43da1ad83c28567ecfb70809f.zip
meson-fb7099c6cf5a7ad43da1ad83c28567ecfb70809f.tar.gz
meson-fb7099c6cf5a7ad43da1ad83c28567ecfb70809f.tar.bz2
mtest: Check version in the test data after loading
Same as coredata.dat and build.dat loading. Also, do not assert if things change. Raise the appropriate exception. Fixes https://github.com/mesonbuild/meson/issues/7613
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/backend/backends.py7
-rw-r--r--mesonbuild/coredata.py6
-rw-r--r--mesonbuild/mtest.py37
3 files changed, 34 insertions, 16 deletions
diff --git a/mesonbuild/backend/backends.py b/mesonbuild/backend/backends.py
index b12932a..568aeee 100644
--- a/mesonbuild/backend/backends.py
+++ b/mesonbuild/backend/backends.py
@@ -121,8 +121,7 @@ class TestSerialisation:
env: build.EnvironmentVariables, should_fail: bool,
timeout: T.Optional[int], workdir: T.Optional[str],
extra_paths: T.List[str], protocol: TestProtocol, priority: int,
- cmd_is_built: bool,
- depends: T.List[str]):
+ cmd_is_built: bool, depends: T.List[str], version: str):
self.name = name
self.project_name = project
self.suite = suite
@@ -143,6 +142,7 @@ class TestSerialisation:
self.needs_exe_wrapper = needs_exe_wrapper
self.cmd_is_built = cmd_is_built
self.depends = depends
+ self.version = version
def get_backend_from_name(backend: str, build: T.Optional[build.Build] = None, interpreter: T.Optional['Interpreter'] = None) -> T.Optional['Backend']:
@@ -864,7 +864,8 @@ class Backend:
t.should_fail, t.timeout, t.workdir,
extra_paths, t.protocol, t.priority,
isinstance(exe, build.Executable),
- [x.get_id() for x in depends])
+ [x.get_id() for x in depends],
+ self.environment.coredata.version)
arr.append(ts)
return arr
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index 7e966a5..bba3942 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -46,10 +46,10 @@ default_yielding = False
_T = T.TypeVar('_T')
class MesonVersionMismatchException(MesonException):
- '''Build directory generated with Meson version incompatible with current version'''
+ '''Build directory generated with Meson version is incompatible with current version'''
def __init__(self, old_version: str, current_version: str) -> None:
super().__init__('Build directory has been generated with Meson version {}, '
- 'which is incompatible with current version {}.'
+ 'which is incompatible with the current version {}.'
.format(old_version, current_version))
self.old_version = old_version
self.current_version = current_version
@@ -977,7 +977,7 @@ def get_cmd_line_options(build_dir: str, options: argparse.Namespace) -> str:
cmdline += ['--native-file {}'.format(f) for f in options.native_file]
return ' '.join([shlex.quote(x) for x in cmdline])
-def major_versions_differ(v1, v2):
+def major_versions_differ(v1: str, v2: str) -> bool:
return v1.split('.')[0:2] != v2.split('.')[0:2]
def load(build_dir: str) -> CoreData:
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py
index 86d7384..c452254 100644
--- a/mesonbuild/mtest.py
+++ b/mesonbuild/mtest.py
@@ -41,6 +41,8 @@ import xml.etree.ElementTree as et
from . import build
from . import environment
from . import mlog
+from .coredata import major_versions_differ, MesonVersionMismatchException
+from .coredata import version as coredata_version
from .dependencies import ExternalProgram
from .mesonlib import MesonException, get_wine_shortpath, split_args, join_args
from .backend.backends import TestProtocol, TestSerialisation
@@ -574,27 +576,42 @@ def write_json_log(jsonlogfile: T.TextIO, test_name: str, result: TestRun) -> No
def run_with_mono(fname: str) -> bool:
return fname.endswith('.exe') and not (is_windows() or is_cygwin())
+def check_obj_major_version(objs: T.List[TestSerialisation]) -> None:
+ if not objs:
+ return
+ obj = objs[0]
+ if not hasattr(obj, 'version'):
+ raise MesonVersionMismatchException('<unknown>', coredata_version)
+ if major_versions_differ(obj.version, coredata_version):
+ raise MesonVersionMismatchException(obj.version, coredata_version)
+
def load_benchmarks(build_dir: str) -> T.List[TestSerialisation]:
datafile = Path(build_dir) / 'meson-private' / 'meson_benchmark_setup.dat'
if not datafile.is_file():
raise TestException('Directory {!r} does not seem to be a Meson build directory.'.format(build_dir))
with datafile.open('rb') as f:
- obj = pickle.load(f)
- assert isinstance(obj, list)
- for i in obj:
- assert isinstance(i, TestSerialisation)
- return obj
+ objs = pickle.load(f)
+ if not isinstance(objs, list):
+ raise MesonVersionMismatchException('<unknown>', coredata_version)
+ for i in objs:
+ if not isinstance(i, TestSerialisation):
+ raise MesonVersionMismatchException('<unknown>', coredata_version)
+ check_obj_major_version(objs)
+ return objs
def load_tests(build_dir: str) -> T.List[TestSerialisation]:
datafile = Path(build_dir) / 'meson-private' / 'meson_test_setup.dat'
if not datafile.is_file():
raise TestException('Directory {!r} does not seem to be a Meson build directory.'.format(build_dir))
with datafile.open('rb') as f:
- obj = pickle.load(f)
- assert isinstance(obj, list)
- for i in obj:
- assert isinstance(i, TestSerialisation)
- return obj
+ objs = pickle.load(f)
+ if not isinstance(objs, list):
+ raise MesonVersionMismatchException('<unknown>', coredata_version)
+ for i in objs:
+ if not isinstance(i, TestSerialisation):
+ raise MesonVersionMismatchException('<unknown>', coredata_version)
+ check_obj_major_version(objs)
+ return objs
class SingleTestRunner: