summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2001-12-29 08:04:42 (GMT)
committerSteven Knight <knight@baldmt.com>2001-12-29 08:04:42 (GMT)
commit9198503d21ac99352629e8d8dfb7c14b11f34401 (patch)
treef43d4904a396cb3a43f0832ff3a0c912e574e0d5 /test
parentc4285a0fcb42c8b8e84126ed5cb81ae745b98a8b (diff)
downloadSCons-9198503d21ac99352629e8d8dfb7c14b11f34401.zip
SCons-9198503d21ac99352629e8d8dfb7c14b11f34401.tar.gz
SCons-9198503d21ac99352629e8d8dfb7c14b11f34401.tar.bz2
Add duplicate (defaults to true) option to BuildDir()
Diffstat (limited to 'test')
-rw-r--r--test/BuildDir.py47
-rw-r--r--test/CPPPATH.py33
-rw-r--r--test/SConscript.py9
3 files changed, 68 insertions, 21 deletions
diff --git a/test/BuildDir.py b/test/BuildDir.py
index 8f7c149..ef11760 100644
--- a/test/BuildDir.py
+++ b/test/BuildDir.py
@@ -36,17 +36,29 @@ else:
test = TestSCons.TestSCons()
-foo1 = test.workpath('build/var1/foo1' + _exe)
-foo2 = test.workpath('build/var1/foo2' + _exe)
-foo3 = test.workpath('build/var2/foo1' + _exe)
-foo4 = test.workpath('build/var2/foo2' + _exe)
+foo11 = test.workpath('build', 'var1', 'foo1' + _exe)
+foo12 = test.workpath('build', 'var1', 'foo2' + _exe)
+foo21 = test.workpath('build', 'var2', 'foo1' + _exe)
+foo22 = test.workpath('build', 'var2', 'foo2' + _exe)
+foo31 = test.workpath('build', 'var3', 'foo1' + _exe)
+foo32 = test.workpath('build', 'var3', 'foo2' + _exe)
test.write('SConstruct', """
-BuildDir('build/var1', 'src')
-BuildDir('build/var2', 'src')
-SConscript('build/var1/SConscript')
-SConscript('build/var2/SConscript')
-""")
+src = Dir('src')
+var2 = Dir('build/var2')
+var3 = Dir('build/var3')
+
+BuildDir('build/var1', src)
+BuildDir(var2, src)
+BuildDir(var3, src, duplicate=0)
+
+env = Environment()
+SConscript('build/var1/SConscript', "env")
+SConscript('build/var2/SConscript', "env")
+
+env = Environment(CPPPATH=src)
+SConscript('build/var3/SConscript', "env")
+""")
test.subdir('src')
test.write('src/SConscript', """
@@ -62,8 +74,7 @@ def buildIt(target, source, env):
f2.close()
f1.close()
return 0
-
-env = Environment()
+Import("env")
env.Command(target='f2.c', source='f2.in', action=buildIt)
env.Program(target='foo2', source='f2.c')
env.Program(target='foo1', source='f1.c')
@@ -103,9 +114,15 @@ test.write('src/f2.h', r"""
test.run(arguments = '.')
-test.run(program = foo1, stdout = "f1.c\n")
-test.run(program = foo2, stdout = "f2.c\n")
-test.run(program = foo3, stdout = "f1.c\n")
-test.run(program = foo4, stdout = "f2.c\n")
+test.run(program = foo11, stdout = "f1.c\n")
+test.run(program = foo12, stdout = "f2.c\n")
+test.run(program = foo21, stdout = "f1.c\n")
+test.run(program = foo22, stdout = "f2.c\n")
+test.run(program = foo31, stdout = "f1.c\n")
+test.run(program = foo32, stdout = "f2.c\n")
+
+# Make sure we didn't duplicate the source files in build/var3.
+test.fail_test(os.path.exists(test.workpath('build', 'var3', 'f1.c')))
+test.fail_test(os.path.exists(test.workpath('build', 'var3', 'f2.in')))
test.pass_test()
diff --git a/test/CPPPATH.py b/test/CPPPATH.py
index fb21426..af7bdd8 100644
--- a/test/CPPPATH.py
+++ b/test/CPPPATH.py
@@ -35,8 +35,9 @@ else:
prog = 'prog' + _exe
subdir_prog = os.path.join('subdir', 'prog' + _exe)
+variant_prog = os.path.join('variant', 'prog' + _exe)
-args = prog + ' ' + subdir_prog
+args = prog + ' ' + subdir_prog + ' ' + variant_prog
test = TestSCons.TestSCons()
@@ -47,6 +48,11 @@ env = Environment(CPPPATH = ['include'])
obj = env.Object(target='prog', source='subdir/prog.c')
env.Program(target='prog', source=obj)
SConscript('subdir/SConscript', "env")
+
+BuildDir('variant', 'subdir', 0)
+include = Dir('include')
+env = Environment(CPPPATH=[include])
+SConscript('variant/SConscript', "env")
""")
test.write(['subdir', 'SConscript'], """
@@ -93,7 +99,7 @@ r"""
-test.run(arguments = args, stderr = None)
+test.run(arguments = args)
test.run(program = test.workpath(prog),
stdout = "subdir/prog.c\ninclude/foo.h 1\ninclude/bar.h 1\n")
@@ -101,9 +107,13 @@ test.run(program = test.workpath(prog),
test.run(program = test.workpath(subdir_prog),
stdout = "subdir/prog.c\nsubdir/include/foo.h 1\nsubdir/include/bar.h 1\n")
-test.up_to_date(arguments = args)
+test.run(program = test.workpath(variant_prog),
+ stdout = "subdir/prog.c\ninclude/foo.h 1\ninclude/bar.h 1\n")
+# Make sure we didn't duplicate the source file in the variant subdirectory.
+test.fail_test(os.path.exists(test.workpath('variant', 'prog.c')))
+test.up_to_date(arguments = args)
test.unlink('include/foo.h')
test.write('include/foo.h',
@@ -120,8 +130,13 @@ test.run(program = test.workpath(prog),
test.run(program = test.workpath(subdir_prog),
stdout = "subdir/prog.c\nsubdir/include/foo.h 1\nsubdir/include/bar.h 1\n")
-test.up_to_date(arguments = args)
+test.run(program = test.workpath(variant_prog),
+ stdout = "subdir/prog.c\ninclude/foo.h 2\ninclude/bar.h 1\n")
+# Make sure we didn't duplicate the source file in the variant subdirectory.
+test.fail_test(os.path.exists(test.workpath('variant', 'prog.c')))
+
+test.up_to_date(arguments = args)
test.unlink('include/bar.h')
@@ -130,7 +145,7 @@ r"""
#define BAR_STRING "include/bar.h 2\n"
""")
-test.run(arguments = prog)
+test.run(arguments = args)
test.run(program = test.workpath(prog),
stdout = "subdir/prog.c\ninclude/foo.h 2\ninclude/bar.h 2\n")
@@ -138,6 +153,12 @@ test.run(program = test.workpath(prog),
test.run(program = test.workpath(subdir_prog),
stdout = "subdir/prog.c\nsubdir/include/foo.h 1\nsubdir/include/bar.h 1\n")
-test.up_to_date(arguments = prog)
+test.run(program = test.workpath(variant_prog),
+ stdout = "subdir/prog.c\ninclude/foo.h 2\ninclude/bar.h 2\n")
+
+# Make sure we didn't duplicate the source file in the variant subdirectory.
+test.fail_test(os.path.exists(test.workpath('variant', 'prog.c')))
+
+test.up_to_date(arguments = args)
test.pass_test()
diff --git a/test/SConscript.py b/test/SConscript.py
index 5172040..496624d 100644
--- a/test/SConscript.py
+++ b/test/SConscript.py
@@ -59,6 +59,10 @@ Import("x1"," x2")
assert x1 == "SConscript4 x1"
assert x2 == "SConscript4 x2"
+subdir = Dir('subdir')
+script = File('SConscript', subdir)
+foo = SConscript(script)
+assert foo == "subdir/SConscript foo"
""")
test.write('SConscript', """
@@ -128,6 +132,11 @@ x2 = "SConscript4 x2"
Export("x1", "x2")
""")
+test.subdir('subdir')
+test.write(['subdir', 'SConscript'], """
+foo = 'subdir/SConscript foo'
+Return('foo')
+""")
wpath = test.workpath()