Bug 1670168 - Fix configure lint error when a template uses an undefined variable. r=firefox-build-system-reviewers,rstewart DONTBUILD
Differential Revision: https://phabricator.services.mozilla.com/D93057
This commit is contained in:
@@ -312,6 +312,9 @@ class LintSandbox(ConfigureSandbox):
|
||||
# Raise the same kind of error as what would happen during
|
||||
# execution.
|
||||
e = NameError("global name '{}' is not defined".format(instr.argval))
|
||||
self._raise_from(e, func, instr.starts_line - func.__code__.co_firstlineno)
|
||||
if instr.starts_line is None:
|
||||
self._raise_from(e, func)
|
||||
else:
|
||||
self._raise_from(e, func, instr.starts_line - code.co_firstlineno)
|
||||
|
||||
return wrapped
|
||||
|
||||
@@ -397,6 +397,24 @@ class TestLint(unittest.TestCase):
|
||||
self.assertEquals(str(e.exception),
|
||||
"global name 'unknown' is not defined")
|
||||
|
||||
# Ideally, this would raise on line 4, where `unknown` is used, but
|
||||
# python disassembly doesn't give use the information.
|
||||
with self.assertRaisesFromLine(NameError, 2) as e:
|
||||
with self.moz_configure('''
|
||||
@template
|
||||
def tmpl():
|
||||
@depends(unknown)
|
||||
def foo(value):
|
||||
if value:
|
||||
return True
|
||||
return foo
|
||||
tmpl()
|
||||
'''):
|
||||
self.lint_test()
|
||||
|
||||
self.assertEquals(str(e.exception),
|
||||
"global name 'unknown' is not defined")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user