diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2018-02-18 13:54:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-18 13:54:50 +0200 |
commit | 55a7c265c11e0f3e8a94cf9f4fd0b5f036a717d2 (patch) | |
tree | 29e6686ece50f119e8a4e850653c221b6872b975 /mesonbuild | |
parent | 1841d53a84be13a3ba989b917930b824aafdac26 (diff) | |
parent | 7297e9f7a3581d132b0bccc47da4435c7315c74b (diff) | |
download | meson-55a7c265c11e0f3e8a94cf9f4fd0b5f036a717d2.zip meson-55a7c265c11e0f3e8a94cf9f4fd0b5f036a717d2.tar.gz meson-55a7c265c11e0f3e8a94cf9f4fd0b5f036a717d2.tar.bz2 |
Merge pull request #2863 from jon-turney/exit-status-on-exception
Verify that failing tests are failing with an error, not a python exception
Diffstat (limited to 'mesonbuild')
-rw-r--r-- | mesonbuild/environment.py | 5 | ||||
-rw-r--r-- | mesonbuild/interpreter.py | 7 | ||||
-rw-r--r-- | mesonbuild/interpreterbase.py | 19 | ||||
-rw-r--r-- | mesonbuild/mesonmain.py | 3 |
4 files changed, 27 insertions, 7 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index 52c670a..e553423 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -695,10 +695,11 @@ class Environment: for compiler in compilers: if isinstance(compiler, str): compiler = [compiler] + arg = ['--version'] try: - p, out = Popen_safe(compiler + ['--version'])[0:2] + p, out = Popen_safe(compiler + arg)[0:2] except OSError as e: - popen_exceptions[compiler] = e + popen_exceptions[' '.join(compiler + arg)] = e continue version = search_version(out) diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py index 4bd7d7f..8041526 100644 --- a/mesonbuild/interpreter.py +++ b/mesonbuild/interpreter.py @@ -1504,6 +1504,8 @@ class Interpreter(InterpreterBase): 'test': self.func_test, 'vcs_tag': self.func_vcs_tag, }) + if 'MESON_UNIT_TEST' in os.environ: + self.funcs.update({'exception': self.func_exception}) def holderify(self, item): if isinstance(item, list): @@ -1984,6 +1986,11 @@ to directly access options of other subprojects.''') self.validate_arguments(args, 1, [str]) raise InterpreterException('Problem encountered: ' + args[0]) + @noKwargs + def func_exception(self, node, args, kwargs): + self.validate_arguments(args, 0, []) + raise Exception() + def detect_compilers(self, lang, need_cross_compiler): cross_comp = None if lang == 'c': diff --git a/mesonbuild/interpreterbase.py b/mesonbuild/interpreterbase.py index 6618dc8..0539b14 100644 --- a/mesonbuild/interpreterbase.py +++ b/mesonbuild/interpreterbase.py @@ -267,9 +267,8 @@ class InterpreterBase: def validate_comparison_types(self, val1, val2): if type(val1) != type(val2): - mlog.warning('''Trying to compare values of different types ({}, {}). -The result of this is undefined and will become a hard error -in a future Meson release.'''.format(type(val1).__name__, type(val2).__name__)) + return False + return True def evaluate_comparison(self, node): val1 = self.evaluate_statement(node.left) @@ -278,11 +277,23 @@ in a future Meson release.'''.format(type(val1).__name__, type(val2).__name__)) val2 = self.evaluate_statement(node.right) if is_disabler(val2): return val2 - self.validate_comparison_types(val1, val2) + valid = self.validate_comparison_types(val1, val2) + # Ordering comparisons of different types isn't allowed since PR #1810 + # (0.41.0). Since PR #2884 we also warn about equality comparisons of + # different types, which will one day become an error. + if not valid and (node.ctype == '==' or node.ctype == '!='): + mlog.warning('''Trying to compare values of different types ({}, {}) using {}. +The result of this is undefined and will become a hard error in a future Meson release.''' + .format(type(val1).__name__, type(val2).__name__, node.ctype), location=node) if node.ctype == '==': return val1 == val2 elif node.ctype == '!=': return val1 != val2 + elif not valid: + raise InterpreterException( + 'Values of different types ({}, {}) cannot be compared using {}.'.format(type(val1).__name__, + type(val2).__name__, + node.ctype)) elif not self.is_elementary_type(val1): raise InterpreterException('{} can only be compared for equality.'.format(node.left.value)) elif not self.is_elementary_type(val2): diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index 073e505..7966d70 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -376,11 +376,12 @@ def run(original_args, mainfile=None): mlog.log("\nA full log can be found at", mlog.bold(logfile)) if os.environ.get('MESON_FORCE_BACKTRACE'): raise + return 1 else: if os.environ.get('MESON_FORCE_BACKTRACE'): raise traceback.print_exc() - return 1 + return 2 finally: mlog.shutdown() |