Only expose exception() test function during unit tests

This commit is contained in:
Jon Turney 2018-02-09 13:35:07 +00:00
parent b78a01bced
commit 9e6d3f903c
2 changed files with 3 additions and 1 deletions

View File

@ -1470,7 +1470,6 @@ class Interpreter(InterpreterBase):
'disabler': self.func_disabler,
'environment': self.func_environment,
'error': self.func_error,
'exception': self.func_exception,
'executable': self.func_executable,
'generator': self.func_generator,
'gettext': self.func_gettext,
@ -1504,6 +1503,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):

View File

@ -1938,6 +1938,7 @@ class FailureTests(BasePlatformTests):
Test exit status on python exception
'''
tdir = os.path.join(self.unit_test_dir, '21 exit status')
os.environ['MESON_UNIT_TEST'] = '1'
with self.assertRaises(subprocess.CalledProcessError) as cm:
self.init(tdir, inprocess=False)
self.assertEqual(cm.exception.returncode, 2)