summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-01-04 14:36:40 (GMT)
committerSteven Knight <knight@baldmt.com>2004-01-04 14:36:40 (GMT)
commitffa68a9db1f04d9efedab845c1c744bc9c7e785b (patch)
tree80a5a0a882566123f73db2719df959eceb063d60
parent21bcea81ee5091735a41d7bfac8d5398dc8bf97f (diff)
downloadSCons-ffa68a9db1f04d9efedab845c1c744bc9c7e785b.zip
SCons-ffa68a9db1f04d9efedab845c1c744bc9c7e785b.tar.gz
SCons-ffa68a9db1f04d9efedab845c1c744bc9c7e785b.tar.bz2
Miscellaneous changes: update a call to env.subst(); white space cleanup in EnvironmentTests.py and Node/NodeTests.py; more informative failure reporting in Node/FSTests.py; remove the now-unused SCons.Node.arg2nodes() function.
-rw-r--r--src/engine/SCons/Defaults.py2
-rw-r--r--src/engine/SCons/EnvironmentTests.py32
-rw-r--r--src/engine/SCons/Node/FSTests.py18
-rw-r--r--src/engine/SCons/Node/NodeTests.py130
-rw-r--r--src/engine/SCons/Node/__init__.py38
5 files changed, 32 insertions, 188 deletions
diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py
index 569269e..cbd468d 100644
--- a/src/engine/SCons/Defaults.py
+++ b/src/engine/SCons/Defaults.py
@@ -156,7 +156,7 @@ def _concat(prefix, list, suffix, env, f=lambda x: x):
def subst(x, env = env):
if SCons.Util.is_String(x):
- return SCons.Util.scons_subst(x, env)
+ return env.subst(x)
else:
return x
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index c9270f7..778b2f8 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -262,7 +262,7 @@ class EnvironmentTestCase(unittest.TestCase):
def test_subst(self):
"""Test substituting construction variables within strings
-
+
Check various combinations, including recursive expansion
of variables into other variables.
"""
@@ -505,7 +505,7 @@ class EnvironmentTestCase(unittest.TestCase):
clazz=SCons.Node.FS.Dir,
must_exist=0,
cwd=SCons.Node.FS.default_fs.Dir('xx'))
-
+
env = Environment(LIBS = [ 'foo', 'bar', 'baz' ],
LIBLINKPREFIX = 'foo',
LIBLINKSUFFIX = 'bar',
@@ -675,10 +675,10 @@ class EnvironmentTestCase(unittest.TestCase):
env = Environment(tools = [t1, t2, t3], XYZ = 'aaa')
assert env['TOOL1'] == 111, env['TOOL1']
assert env['TOOL2'] == 222, env
- assert env['AAA'] == 'aaa', env
+ assert env['AAA'] == 'aaa', env
t4(env)
assert env['TOOL4'] == 444, env
-
+
def test_Default_TOOLS(self):
"""Test overriding the default TOOLS variable"""
def t5(env):
@@ -699,7 +699,7 @@ class EnvironmentTestCase(unittest.TestCase):
env = Environment(XYZ = 'bbb')
assert env['TOOL5'] == 555, env['TOOL5']
assert env['TOOL6'] == 666, env
- assert env['BBB'] == 'bbb', env
+ assert env['BBB'] == 'bbb', env
t8(env)
assert env['TOOL8'] == 888, env
finally:
@@ -882,7 +882,7 @@ class EnvironmentTestCase(unittest.TestCase):
env1 = Environment(tools=[foo])
env2 = env1.Copy()
env3 = env1.Copy(tools=[bar, baz])
-
+
assert env1.get('FOO') is 1
assert env1.get('BAR') is None
assert env1.get('BAZ') is None
@@ -974,9 +974,9 @@ class EnvironmentTestCase(unittest.TestCase):
def test_FindIxes(self):
"Test FindIxes()"
- env = Environment(LIBPREFIX='lib',
+ env = Environment(LIBPREFIX='lib',
LIBSUFFIX='.a',
- SHLIBPREFIX='lib',
+ SHLIBPREFIX='lib',
SHLIBSUFFIX='.so',
PREFIX='pre',
SUFFIX='post')
@@ -1095,7 +1095,7 @@ class EnvironmentTestCase(unittest.TestCase):
env1 = Environment(ENV = {'PATH': r'C:\dir\num\one;C:\dir\num\two'},
MYENV = {'MYPATH': r'C:\mydir\num\one;C:\mydir\num\two'})
# have to include the pathsep here so that the test will work on UNIX too.
- env1.PrependENVPath('PATH',r'C:\dir\num\two',sep = ';')
+ env1.PrependENVPath('PATH',r'C:\dir\num\two',sep = ';')
env1.PrependENVPath('PATH',r'C:\dir\num\three',sep = ';')
env1.PrependENVPath('MYPATH',r'C:\mydir\num\three','MYENV',sep = ';')
env1.PrependENVPath('MYPATH',r'C:\mydir\num\one','MYENV',sep = ';')
@@ -1107,7 +1107,7 @@ class EnvironmentTestCase(unittest.TestCase):
env1 = Environment(ENV = {'PATH': r'C:\dir\num\one;C:\dir\num\two'},
MYENV = {'MYPATH': r'C:\mydir\num\one;C:\mydir\num\two'})
# have to include the pathsep here so that the test will work on UNIX too.
- env1.PrependENVPath('PATH',r'C:\dir\num\two',sep = ';')
+ env1.PrependENVPath('PATH',r'C:\dir\num\two',sep = ';')
env1.PrependENVPath('PATH',r'C:\dir\num\three',sep = ';')
env1.PrependENVPath('MYPATH',r'C:\mydir\num\three','MYENV',sep = ';')
env1.PrependENVPath('MYPATH',r'C:\mydir\num\one','MYENV',sep = ';')
@@ -1133,22 +1133,22 @@ class EnvironmentTestCase(unittest.TestCase):
def test_ReplaceIxes(self):
"Test ReplaceIxes()"
- env = Environment(LIBPREFIX='lib',
+ env = Environment(LIBPREFIX='lib',
LIBSUFFIX='.a',
- SHLIBPREFIX='lib',
+ SHLIBPREFIX='lib',
SHLIBSUFFIX='.so',
PREFIX='pre',
SUFFIX='post')
-
- assert 'libfoo.a' == env.ReplaceIxes('libfoo.so',
+
+ assert 'libfoo.a' == env.ReplaceIxes('libfoo.so',
'SHLIBPREFIX', 'SHLIBSUFFIX',
'LIBPREFIX', 'LIBSUFFIX')
-
+
assert os.path.join('dir', 'libfoo.a') == env.ReplaceIxes(os.path.join('dir', 'libfoo.so'),
'SHLIBPREFIX', 'SHLIBSUFFIX',
'LIBPREFIX', 'LIBSUFFIX')
- assert 'libfoo.a' == env.ReplaceIxes('prefoopost',
+ assert 'libfoo.a' == env.ReplaceIxes('prefoopost',
'PREFIX', 'SUFFIX',
'LIBPREFIX', 'LIBSUFFIX')
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py
index fcd605b..739d4e9 100644
--- a/src/engine/SCons/Node/FSTests.py
+++ b/src/engine/SCons/Node/FSTests.py
@@ -1708,36 +1708,36 @@ class SpecialAttrTestCase(unittest.TestCase):
f=fs.Entry('foo/bar/baz.blat').get_subst_proxy()
assert str(f.dir) == os.path.normpath('foo/bar'), str(f.dir)
- assert f.dir.is_literal()
+ assert f.dir.is_literal(), f.dir
assert f.dir.for_signature() == 'bar', f.dir.for_signature()
assert str(f.file) == 'baz.blat', str(f.file)
- assert f.file.is_literal()
+ assert f.file.is_literal(), f.file
assert f.file.for_signature() == 'baz.blat_file', \
f.file.for_signature()
assert str(f.base) == os.path.normpath('foo/bar/baz'), str(f.base)
- assert f.base.is_literal()
+ assert f.base.is_literal(), f.base
assert f.base.for_signature() == 'baz.blat_base', \
f.base.for_signature()
assert str(f.filebase) == 'baz', str(f.filebase)
- assert f.filebase.is_literal()
+ assert f.filebase.is_literal(), f.filebase
assert f.filebase.for_signature() == 'baz.blat_filebase', \
f.filebase.for_signature()
assert str(f.suffix) == '.blat', str(f.suffix)
- assert f.suffix.is_literal()
+ assert f.suffix.is_literal(), f.suffix
assert f.suffix.for_signature() == 'baz.blat_suffix', \
f.suffix.for_signature()
assert str(f.abspath) == test.workpath('foo', 'bar', 'baz.blat'), str(f.abspath)
- assert f.abspath.is_literal()
+ assert f.abspath.is_literal(), f.abspath
assert f.abspath.for_signature() == 'baz.blat_abspath', \
f.abspath.for_signature()
assert str(f.posix) == 'foo/bar/baz.blat', str(f.posix)
- assert f.posix.is_literal()
+ assert f.posix.is_literal(), f.posix
if f.posix != f:
assert f.posix.for_signature() == 'baz.blat_posix', \
f.posix.for_signature()
@@ -1771,11 +1771,11 @@ class SpecialAttrTestCase(unittest.TestCase):
fs.BuildDir('foo', 'baz')
assert str(f.srcpath) == os.path.normpath('baz/bar/baz.blat'), str(f.srcpath)
- assert f.srcpath.is_literal()
+ assert f.srcpath.is_literal(), f.srcpath
assert isinstance(f.srcpath.get(), SCons.Node.FS.Entry)
assert str(f.srcdir) == os.path.normpath('baz/bar'), str(f.srcdir)
- assert f.srcdir.is_literal()
+ assert f.srcdir.is_literal(), f.srcdir
assert isinstance(f.srcdir.get(), SCons.Node.FS.Dir)
# And now, combinations!!!
diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py
index f4d4845..fa0b6f7 100644
--- a/src/engine/SCons/Node/NodeTests.py
+++ b/src/engine/SCons/Node/NodeTests.py
@@ -42,7 +42,7 @@ built_order = 0
class MyAction:
def __init__(self):
self.order = 0
-
+
def __call__(self, target, source, env):
global built_it, built_target, built_source, built_args, built_order
built_it = 1
@@ -260,7 +260,7 @@ class NodeTestCase(unittest.TestCase):
"""
n = SCons.Node.Node()
n.visited()
-
+
def test_depends_on(self):
"""Test the depends_on() method
"""
@@ -268,7 +268,7 @@ class NodeTestCase(unittest.TestCase):
child = SCons.Node.Node()
parent.add_dependency([child])
assert parent.depends_on([child])
-
+
def test_builder_set(self):
"""Test setting a Node's Builder
"""
@@ -455,7 +455,7 @@ class NodeTestCase(unittest.TestCase):
n4 = MyNode()
node.implicit = []
node.implicit_dict = {}
- node._add_child(node.implicit, node.implicit_dict, [n4])
+ node._add_child(node.implicit, node.implicit_dict, [n4])
exc_caught = 0
try:
node.prepare()
@@ -836,134 +836,16 @@ class NodeTestCase(unittest.TestCase):
def for_signature(self):
return self.sig
-
+
n = TestNode("foo", "bar")
assert n.get_string(0) == "foo", n.get_string(0)
assert n.get_string(1) == "bar", n.get_string(1)
- def test_arg2nodes(self):
- """Test the arg2nodes function."""
- dict = {}
- class X(SCons.Node.Node):
- pass
- def Factory(name, directory = None, create = 1, dict=dict, X=X):
- if not dict.has_key(name):
- dict[name] = X()
- dict[name].name = name
- return dict[name]
-
- nodes = SCons.Node.arg2nodes("Util.py UtilTests.py", Factory)
- assert len(nodes) == 1, nodes
- assert isinstance(nodes[0], X)
- assert nodes[0].name == "Util.py UtilTests.py"
-
- if hasattr(types, 'UnicodeType'):
- code = """if 1:
- nodes = SCons.Node.arg2nodes(u"Util.py UtilTests.py", Factory)
- assert len(nodes) == 1, nodes
- assert isinstance(nodes[0], X)
- assert nodes[0].name == u"Util.py UtilTests.py"
- \n"""
- exec code in globals(), locals()
-
- nodes = SCons.Node.arg2nodes(["Util.py", "UtilTests.py"], Factory)
- assert len(nodes) == 2, nodes
- assert isinstance(nodes[0], X)
- assert isinstance(nodes[1], X)
- assert nodes[0].name == "Util.py"
- assert nodes[1].name == "UtilTests.py"
-
- n1 = Factory("Util.py")
- nodes = SCons.Node.arg2nodes([n1, "UtilTests.py"], Factory)
- assert len(nodes) == 2, nodes
- assert isinstance(nodes[0], X)
- assert isinstance(nodes[1], X)
- assert nodes[0].name == "Util.py"
- assert nodes[1].name == "UtilTests.py"
-
- class SConsNode(SCons.Node.Node):
- pass
- nodes = SCons.Node.arg2nodes(SConsNode())
- assert len(nodes) == 1, nodes
- assert isinstance(nodes[0], SConsNode), node
-
- class OtherNode:
- pass
- nodes = SCons.Node.arg2nodes(OtherNode())
- assert len(nodes) == 1, nodes
- assert isinstance(nodes[0], OtherNode), node
-
- def lookup_a(str, F=Factory):
- if str[0] == 'a':
- n = F(str)
- n.a = 1
- return n
- else:
- return None
-
- def lookup_b(str, F=Factory):
- if str[0] == 'b':
- n = F(str)
- n.b = 1
- return n
- else:
- return None
-
- SCons.Node.arg2nodes_lookups.append(lookup_a)
- SCons.Node.arg2nodes_lookups.append(lookup_b)
-
- nodes = SCons.Node.arg2nodes(['aaa', 'bbb', 'ccc'], Factory)
- assert len(nodes) == 3, nodes
-
- assert nodes[0].name == 'aaa', nodes[0]
- assert nodes[0].a == 1, nodes[0]
- assert not hasattr(nodes[0], 'b'), nodes[0]
-
- assert nodes[1].name == 'bbb'
- assert not hasattr(nodes[1], 'a'), nodes[1]
- assert nodes[1].b == 1, nodes[1]
-
- assert nodes[2].name == 'ccc'
- assert not hasattr(nodes[2], 'a'), nodes[1]
- assert not hasattr(nodes[2], 'b'), nodes[1]
-
- def lookup_bbbb(str, F=Factory):
- if str == 'bbbb':
- n = F(str)
- n.bbbb = 1
- return n
- else:
- return None
-
- def lookup_c(str, F=Factory):
- if str[0] == 'c':
- n = F(str)
- n.c = 1
- return n
- else:
- return None
-
- nodes = SCons.Node.arg2nodes(['bbbb', 'ccc'], Factory,
- [lookup_c, lookup_bbbb, lookup_b])
- assert len(nodes) == 2, nodes
-
- assert nodes[0].name == 'bbbb'
- assert not hasattr(nodes[0], 'a'), nodes[1]
- assert not hasattr(nodes[0], 'b'), nodes[1]
- assert nodes[0].bbbb == 1, nodes[1]
- assert not hasattr(nodes[0], 'c'), nodes[0]
-
- assert nodes[1].name == 'ccc'
- assert not hasattr(nodes[1], 'a'), nodes[1]
- assert not hasattr(nodes[1], 'b'), nodes[1]
- assert not hasattr(nodes[1], 'bbbb'), nodes[0]
- assert nodes[1].c == 1, nodes[1]
-
def test_literal(self):
"""Test the is_literal() function."""
n=SCons.Node.Node()
assert n.is_literal()
-
+
def test_Annotate(self):
"""Test using an interface-specific Annotate function."""
def my_annotate(node, self=self):
diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py
index 1eb7f29..51bfe30 100644
--- a/src/engine/SCons/Node/__init__.py
+++ b/src/engine/SCons/Node/__init__.py
@@ -825,41 +825,3 @@ class Walker:
arg2nodes_lookups = []
-
-def arg2nodes(args, node_factory=None, lookup_list=arg2nodes_lookups):
- """This function converts a string or list into a list of Node
- instances. It accepts the following inputs:
- - A single string,
- - A single Node instance,
- - A list containing either strings or Node instances.
- In all cases, strings are converted to Node instances, and the
- function returns a list of Node instances."""
-
- if not args:
- return []
- if not SCons.Util.is_List(args):
- args = [args]
-
- nodes = []
- for v in args:
- if SCons.Util.is_String(v):
- n = None
- for l in lookup_list:
- n = l(v)
- if not n is None:
- break
- if not n is None:
- if SCons.Util.is_String(n) and node_factory:
- n = node_factory(n)
- nodes.append(n)
- elif node_factory:
- nodes.append(node_factory(v))
- # Do we enforce the following restriction? Maybe, but it
- # would also restrict what we can do to allow people to
- # use the engine with alternate Node implementations...
- #elif not issubclass(v.__class__, Node):
- # raise TypeError
- else:
- nodes.append(v)
-
- return nodes