summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/UtilTests.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-01-29 03:35:57 (GMT)
committerSteven Knight <knight@baldmt.com>2004-01-29 03:35:57 (GMT)
commit1ed5ce4f1c15b7608fe2fa62be76f7a781f98faa (patch)
tree2e6c2769a032d26227b22c39df84706d35ed7408 /src/engine/SCons/UtilTests.py
parentd0b4699180b7177561f452b646b85ec39f09d0e2 (diff)
downloadSCons-1ed5ce4f1c15b7608fe2fa62be76f7a781f98faa.zip
SCons-1ed5ce4f1c15b7608fe2fa62be76f7a781f98faa.tar.gz
SCons-1ed5ce4f1c15b7608fe2fa62be76f7a781f98faa.tar.bz2
Provide a better error message when a construction variable expansion is a Python syntax error.
Diffstat (limited to 'src/engine/SCons/UtilTests.py')
-rw-r--r--src/engine/SCons/UtilTests.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/engine/SCons/UtilTests.py b/src/engine/SCons/UtilTests.py
index ca5f649..fb4ec09 100644
--- a/src/engine/SCons/UtilTests.py
+++ b/src/engine/SCons/UtilTests.py
@@ -32,6 +32,8 @@ import unittest
from SCons.Util import *
import TestCmd
+import SCons.Errors
+
class OutBuffer:
def __init__(self):
self.buffer = ""
@@ -410,6 +412,14 @@ class UtilTestCase(unittest.TestCase):
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)
@@ -732,6 +742,14 @@ class UtilTestCase(unittest.TestCase):
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')