def Depends(self, target, dependency):
"""Explicity specify that 'target's depend on 'dependency'."""
- tlist = self.arg2nodes(target, self.fs.File)
- dlist = self.arg2nodes(dependency, self.fs.File)
+ tlist = self.arg2nodes(target, self.fs.Entry)
+ dlist = self.arg2nodes(dependency, self.fs.Entry)
for t in tlist:
t.add_dependency(dlist)
def Ignore(self, target, dependency):
"""Ignore a dependency."""
- tlist = self.arg2nodes(target, self.fs.File)
- dlist = self.arg2nodes(dependency, self.fs.File)
+ tlist = self.arg2nodes(target, self.fs.Entry)
+ dlist = self.arg2nodes(dependency, self.fs.Entry)
for t in tlist:
t.add_ignore(dlist)
def Precious(self, *targets):
tlist = []
for t in targets:
- tlist.extend(self.arg2nodes(t, self.fs.File))
+ tlist.extend(self.arg2nodes(t, self.fs.Entry))
for t in tlist:
t.set_precious()
def SideEffect(self, side_effect, target):
"""Tell scons that side_effects are built as side
effects of building targets."""
- side_effects = self.arg2nodes(side_effect, self.fs.File)
- targets = self.arg2nodes(target, self.fs.File)
+ side_effects = self.arg2nodes(side_effect, self.fs.Entry)
+ targets = self.arg2nodes(target, self.fs.Entry)
for side_effect in side_effects:
# A builder of 1 means the node is supposed to appear
assert d == ['bbb', 'another_file'], d
def test_Depends(self):
- """Test the explicit Depends method."""
- env = Environment(FOO = 'xxx', BAR='yyy')
- t = env.Depends(target='EnvironmentTest.py', dependency='Environment.py')
- assert t.__class__.__name__ == 'File'
- assert t.path == 'EnvironmentTest.py'
- assert len(t.depends) == 1
- d = t.depends[0]
- assert d.__class__.__name__ == 'File'
- assert d.path == 'Environment.py'
-
- t = env.Depends(target='${FOO}.py', dependency='${BAR}.py')
- assert t.__class__.__name__ == 'File'
- assert t.path == 'xxx.py'
- assert len(t.depends) == 1
- d = t.depends[0]
- assert d.__class__.__name__ == 'File'
- assert d.path == 'yyy.py'
+ """Test the explicit Depends method."""
+ env = Environment(FOO = 'xxx', BAR='yyy')
+ env.Dir('dir1')
+ env.Dir('dir2')
+ env.File('xxx.py')
+ env.File('yyy.py')
+ t = env.Depends(target='EnvironmentTest.py', dependency='Environment.py')
+ assert t.__class__.__name__ == 'Entry', t.__class__.__name__
+ assert t.path == 'EnvironmentTest.py'
+ assert len(t.depends) == 1
+ d = t.depends[0]
+ assert d.__class__.__name__ == 'Entry', d.__class__.__name__
+ assert d.path == 'Environment.py'
+
+ t = env.Depends(target='${FOO}.py', dependency='${BAR}.py')
+ assert t.__class__.__name__ == 'File', t.__class__.__name__
+ assert t.path == 'xxx.py'
+ assert len(t.depends) == 1
+ d = t.depends[0]
+ assert d.__class__.__name__ == 'File', d.__class__.__name__
+ assert d.path == 'yyy.py'
+
+ t = env.Depends(target='dir1', dependency='dir2')
+ assert t.__class__.__name__ == 'Dir', t.__class__.__name__
+ assert t.path == 'dir1'
+ assert len(t.depends) == 1
+ d = t.depends[0]
+ assert d.__class__.__name__ == 'Dir', d.__class__.__name__
+ assert d.path == 'dir2'
def test_Dir(self):
"""Test the Dir() method"""
def test_Ignore(self):
"""Test the explicit Ignore method."""
env = Environment(FOO='yyy', BAR='zzz')
+ env.Dir('dir1')
+ env.Dir('dir2')
+ env.File('yyyzzz')
+ env.File('zzzyyy')
+
t = env.Ignore(target='targ.py', dependency='dep.py')
- assert t.__class__.__name__ == 'File'
+ assert t.__class__.__name__ == 'Entry', t.__class__.__name__
assert t.path == 'targ.py'
assert len(t.ignore) == 1
i = t.ignore[0]
- assert i.__class__.__name__ == 'File'
+ assert i.__class__.__name__ == 'Entry', i.__class__.__name__
assert i.path == 'dep.py'
+
t = env.Ignore(target='$FOO$BAR', dependency='$BAR$FOO')
- assert t.__class__.__name__ == 'File'
+ assert t.__class__.__name__ == 'File', t.__class__.__name__
assert t.path == 'yyyzzz'
assert len(t.ignore) == 1
i = t.ignore[0]
- assert i.__class__.__name__ == 'File'
+ assert i.__class__.__name__ == 'File', i.__class__.__name__
assert i.path == 'zzzyyy'
+ t = env.Ignore(target='dir1', dependency='dir2')
+ assert t.__class__.__name__ == 'Dir', t.__class__.__name__
+ assert t.path == 'dir1'
+ assert len(t.ignore) == 1
+ i = t.ignore[0]
+ assert i.__class__.__name__ == 'Dir', i.__class__.__name__
+ assert i.path == 'dir2'
+
def test_Install(self):
"""Test the Install method"""
env = Environment(FOO='iii', BAR='jjj')
def test_Precious(self):
"""Test the Precious() method"""
env = Environment(FOO='ggg', BAR='hhh')
- t = env.Precious('a', '${BAR}b', ['c', 'd'], '$FOO')
- assert t[0].__class__.__name__ == 'File'
- assert t[0].path == 'a'
+ env.Dir('p_hhhb')
+ env.File('p_d')
+ t = env.Precious('p_a', 'p_${BAR}b', ['p_c', 'p_d'], 'p_$FOO')
+
+ assert t[0].__class__.__name__ == 'Entry', t[0].__class__.__name__
+ assert t[0].path == 'p_a'
assert t[0].precious
- assert t[1].__class__.__name__ == 'File'
- assert t[1].path == 'hhhb'
+ assert t[1].__class__.__name__ == 'Dir', t[1].__class__.__name__
+ assert t[1].path == 'p_hhhb'
assert t[1].precious
- assert t[2].__class__.__name__ == 'File'
- assert t[2].path == 'c'
+ assert t[2].__class__.__name__ == 'Entry', t[2].__class__.__name__
+ assert t[2].path == 'p_c'
assert t[2].precious
- assert t[3].__class__.__name__ == 'File'
- assert t[3].path == 'd'
+ assert t[3].__class__.__name__ == 'File', t[3].__class__.__name__
+ assert t[3].path == 'p_d'
assert t[3].precious
- assert t[4].__class__.__name__ == 'File'
- assert t[4].path == 'ggg'
+ assert t[4].__class__.__name__ == 'Entry', t[4].__class__.__name__
+ assert t[4].path == 'p_ggg'
assert t[4].precious
def test_Repository(self):
def test_SideEffect(self):
"""Test the SideEffect() method"""
env = Environment(LIB='lll', FOO='fff', BAR='bbb')
+ env.File('mylll.pdb')
+ env.Dir('mymmm.pdb')
foo = env.Object('foo.obj', 'foo.cpp')
bar = env.Object('bar.obj', 'bar.cpp')
s = env.SideEffect('mylib.pdb', ['foo.obj', 'bar.obj'])
+ assert s.__class__.__name__ == 'Entry', s.__class__.__name__
assert s.path == 'mylib.pdb'
assert s.side_effect
assert foo.side_effects == [s]
fff = env.Object('fff.obj', 'fff.cpp')
bbb = env.Object('bbb.obj', 'bbb.cpp')
s = env.SideEffect('my${LIB}.pdb', ['${FOO}.obj', '${BAR}.obj'])
+ assert s.__class__.__name__ == 'File', s.__class__.__name__
assert s.path == 'mylll.pdb'
assert s.side_effect
assert fff.side_effects == [s], fff.side_effects
assert s.depends_on([bbb])
assert s.depends_on([fff])
+ ggg = env.Object('ggg.obj', 'ggg.cpp')
+ ccc = env.Object('ccc.obj', 'ccc.cpp')
+ s = env.SideEffect('mymmm.pdb', ['ggg.obj', 'ccc.obj'])
+ assert s.__class__.__name__ == 'Dir', s.__class__.__name__
+ assert s.path == 'mymmm.pdb'
+ assert s.side_effect
+ assert ggg.side_effects == [s], ggg.side_effects
+ assert ccc.side_effects == [s], ccc.side_effects
+ assert s.depends_on([ccc])
+ assert s.depends_on([ggg])
+
def test_SourceCode(self):
"""Test the SourceCode() method."""
env = Environment(FOO='mmm', BAR='nnn')
test = TestSCons.TestSCons()
-test.subdir('subdir')
+test.subdir('subdir', 'sub2')
test.write('build.py', r"""
import sys
env.Foo(target = 'f2.out', source = 'f2.in')
env.Bar(target = 'subdir/f3.out', source = 'f3.in')
SConscript('subdir/SConscript', "env")
+env.Foo(target = 'f5.out', source = 'f5.in')
+env.Bar(target = 'sub2/f6.out', source = 'f6.in')
+env.Depends(target = 'f5.out', dependency = 'sub2')
""" % (python,
python,
os.path.join('$SUBDIR', 'foo.dep'),
""")
test.write('f1.in', "f1.in\n")
-
test.write('f2.in', "f2.in\n")
-
test.write('f3.in', "f3.in\n")
-
test.write(['subdir', 'f4.in'], "subdir/f4.in\n")
+test.write('f5.in', "f5.in\n")
+test.write('f6.in', "f6.in\n")
test.write(['subdir', 'foo.dep'], "subdir/foo.dep 1\n")
-
test.write(['subdir', 'bar.dep'], "subdir/bar.dep 1\n")
-test.run(arguments = '--debug=dtree .')
+test.run(arguments = '.')
test.fail_test(test.read('f1.out') != "f1.in\nsubdir/foo.dep 1\n")
test.fail_test(test.read('f2.out') != "f2.in\nsubdir/foo.dep 1\n")
test.fail_test(test.read(['subdir', 'f3.out']) != "f3.in\nsubdir/bar.dep 1\n")
test.fail_test(test.read(['subdir', 'f4.out']) !=
"subdir/f4.in\nsubdir/bar.dep 1\n")
+test.fail_test(test.read('f5.out') != "f5.in\nsubdir/foo.dep 1\n")
+test.fail_test(test.read(['sub2', 'f6.out']) != "f6.in\nsubdir/bar.dep 1\n")
+#
test.write(['subdir', 'foo.dep'], "subdir/foo.dep 2\n")
-
test.write(['subdir', 'bar.dep'], "subdir/bar.dep 2\n")
+test.write('f6.in', "f6.in 2\n")
test.run(arguments = '.')
test.fail_test(test.read(['subdir', 'f3.out']) != "f3.in\nsubdir/bar.dep 2\n")
test.fail_test(test.read(['subdir', 'f4.out']) !=
"subdir/f4.in\nsubdir/bar.dep 2\n")
+test.fail_test(test.read('f5.out') != "f5.in\nsubdir/foo.dep 2\n")
+test.fail_test(test.read(['sub2', 'f6.out']) != "f6.in 2\nsubdir/bar.dep 2\n")
+
+#
+test.write(['subdir', 'foo.dep'], "subdir/foo.dep 3\n")
+
+test.run(arguments = '.')
+
+test.fail_test(test.read('f1.out') != "f1.in\nsubdir/foo.dep 3\n")
+test.fail_test(test.read('f2.out') != "f2.in\nsubdir/foo.dep 3\n")
+test.fail_test(test.read(['subdir', 'f3.out']) != "f3.in\nsubdir/bar.dep 2\n")
+test.fail_test(test.read(['subdir', 'f4.out']) !=
+ "subdir/f4.in\nsubdir/bar.dep 2\n")
+test.fail_test(test.read('f5.out') != "f5.in\nsubdir/foo.dep 2\n")
+test.fail_test(test.read(['sub2', 'f6.out']) != "f6.in 2\nsubdir/bar.dep 2\n")
+#
test.write(['subdir', 'bar.dep'], "subdir/bar.dep 3\n")
test.run(arguments = '.')
-test.fail_test(test.read('f1.out') != "f1.in\nsubdir/foo.dep 2\n")
-test.fail_test(test.read('f2.out') != "f2.in\nsubdir/foo.dep 2\n")
+test.fail_test(test.read('f1.out') != "f1.in\nsubdir/foo.dep 3\n")
+test.fail_test(test.read('f2.out') != "f2.in\nsubdir/foo.dep 3\n")
+test.fail_test(test.read(['subdir', 'f3.out']) != "f3.in\nsubdir/bar.dep 3\n")
+test.fail_test(test.read(['subdir', 'f4.out']) !=
+ "subdir/f4.in\nsubdir/bar.dep 3\n")
+test.fail_test(test.read('f5.out') != "f5.in\nsubdir/foo.dep 2\n")
+test.fail_test(test.read(['sub2', 'f6.out']) != "f6.in 2\nsubdir/bar.dep 2\n")
+
+#
+test.write('f6.in', "f6.in 3\n")
+
+test.run(arguments = '.')
+
+test.fail_test(test.read('f1.out') != "f1.in\nsubdir/foo.dep 3\n")
+test.fail_test(test.read('f2.out') != "f2.in\nsubdir/foo.dep 3\n")
test.fail_test(test.read(['subdir', 'f3.out']) != "f3.in\nsubdir/bar.dep 3\n")
test.fail_test(test.read(['subdir', 'f4.out']) !=
"subdir/f4.in\nsubdir/bar.dep 3\n")
+test.fail_test(test.read('f5.out') != "f5.in\nsubdir/foo.dep 3\n")
+test.fail_test(test.read(['sub2', 'f6.out']) != "f6.in 3\nsubdir/bar.dep 3\n")
test.pass_test()