Add a test case for python exception exit status
This commit is contained in:
parent
2a64ed855e
commit
b78a01bced
|
@ -1470,6 +1470,7 @@ class Interpreter(InterpreterBase):
|
||||||
'disabler': self.func_disabler,
|
'disabler': self.func_disabler,
|
||||||
'environment': self.func_environment,
|
'environment': self.func_environment,
|
||||||
'error': self.func_error,
|
'error': self.func_error,
|
||||||
|
'exception': self.func_exception,
|
||||||
'executable': self.func_executable,
|
'executable': self.func_executable,
|
||||||
'generator': self.func_generator,
|
'generator': self.func_generator,
|
||||||
'gettext': self.func_gettext,
|
'gettext': self.func_gettext,
|
||||||
|
@ -1983,6 +1984,11 @@ to directly access options of other subprojects.''')
|
||||||
self.validate_arguments(args, 1, [str])
|
self.validate_arguments(args, 1, [str])
|
||||||
raise InterpreterException('Error encountered: ' + args[0])
|
raise InterpreterException('Error 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):
|
def detect_compilers(self, lang, need_cross_compiler):
|
||||||
cross_comp = None
|
cross_comp = None
|
||||||
if lang == 'c':
|
if lang == 'c':
|
||||||
|
|
|
@ -1933,6 +1933,16 @@ class FailureTests(BasePlatformTests):
|
||||||
self.assertRegex(out, r'Also couldn\'t find a fallback subproject in '
|
self.assertRegex(out, r'Also couldn\'t find a fallback subproject in '
|
||||||
'.*subprojects.*failingsubproj.*for the dependency.*somedep')
|
'.*subprojects.*failingsubproj.*for the dependency.*somedep')
|
||||||
|
|
||||||
|
def test_exception_exit_status(self):
|
||||||
|
'''
|
||||||
|
Test exit status on python exception
|
||||||
|
'''
|
||||||
|
tdir = os.path.join(self.unit_test_dir, '21 exit status')
|
||||||
|
with self.assertRaises(subprocess.CalledProcessError) as cm:
|
||||||
|
self.init(tdir, inprocess=False)
|
||||||
|
self.assertEqual(cm.exception.returncode, 2)
|
||||||
|
self.wipe()
|
||||||
|
|
||||||
|
|
||||||
class WindowsTests(BasePlatformTests):
|
class WindowsTests(BasePlatformTests):
|
||||||
'''
|
'''
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
project('exit status')
|
||||||
|
exception()
|
Loading…
Reference in New Issue