- Fix TestCmd.py, runtest.py and specific tests to accomodate being
run from directories whose paths include white space.
+ - Provide a more useful error message if a construction variable
+ expansion contains a syntax error during evaluation.
+
From Vincent Risi:
- Add support for the bcc32, ilink32 and tlib Borland tools.
import types
import UserDict
import UserList
-import SCons.Node
+
+import SCons.Errors
try:
from UserString import UserString
s = eval(key, self.gvars, lvars)
except (IndexError, NameError, TypeError):
return ''
+ except (SyntaxError):
+ raise SCons.Errors.UserError, "Syntax error trying to evaluate `%s'" % s
else:
# Before re-expanding the result, handle
# recursive expansion by copying the local
s = eval(key, self.gvars, lvars)
except (IndexError, NameError, TypeError):
return
+ except (SyntaxError):
+ raise SCons.Errors.UserError, "Syntax error trying to evaluate `%s'" % s
else:
# Before re-expanding the result, handle
# recursive expansion by copying the local
from SCons.Util import *
import TestCmd
+import SCons.Errors
+
class OutBuffer:
def __init__(self):
self.buffer = ""
env, target=MyNode('t'), source=MyNode('s'))
assert newcom == "test foo baz s t", newcom
+ # Test that we handle syntax errors during expansion as expected.
+ try:
+ scons_subst('$foo.bar.3.0', env)
+ except SCons.Errors.UserError, e:
+ assert str(e) == "Syntax error trying to evaluate `$foo.bar.3.0'", e
+ else:
+ raise AssertionError, "did not catch expected UserError"
+
# Test returning a function.
#env = DummyEnv({'FUNCTION' : foo})
#func = scons_subst("$FUNCTION", env, mode=SUBST_RAW, call=None)
del subst_list_cases[:4]
assert failed == 0, "%d subst() mode cases failed" % failed
+ # Test that we handle syntax errors during expansion as expected.
+ try:
+ scons_subst_list('$foo.bar.3.0', env)
+ except SCons.Errors.UserError, e:
+ assert str(e) == "Syntax error trying to evaluate `$foo.bar.3.0'", e
+ else:
+ raise AssertionError, "did not catch expected SyntaxError"
+
def test_splitext(self):
assert splitext('foo') == ('foo','')
assert splitext('foo.bar') == ('foo','.bar')
+# Test syntax errors when trying to expand construction variables.
+test.write('SConstruct', """\
+env = Environment()
+env.subst('$foo.bar.3.0')
+""")
+
+test.run(status=2, stderr="""
+scons: \*\*\* Syntax error trying to evaluate `\$foo\.bar\.3\.0'
+File "SConstruct", line 2, in \?
+""")
+
+test.write('SConstruct', """\
+env = Environment()
+env.subst_list('$foo.3.0.x')
+""")
+
+test.run(status=2, stderr="""
+scons: \*\*\* Syntax error trying to evaluate `\$foo\.3\.0\.x'
+File "SConstruct", line 2, in \?
+""")
+
+
+
test.pass_test()