summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2003-03-26 15:57:50 (GMT)
committerSteven Knight <knight@baldmt.com>2003-03-26 15:57:50 (GMT)
commit95a4d924e02d940a8960e28be71056dab84deb9f (patch)
treeca6f9d1b4c0a5581a10756fa7a3fda0be75d4c62 /test
parentc24f1504b711f871c0c4310a460727ac1a859936 (diff)
downloadSCons-95a4d924e02d940a8960e28be71056dab84deb9f.zip
SCons-95a4d924e02d940a8960e28be71056dab84deb9f.tar.gz
SCons-95a4d924e02d940a8960e28be71056dab84deb9f.tar.bz2
Add warnings when we switch to BuildDir() targets when using -u or -U.
Diffstat (limited to 'test')
-rw-r--r--test/option-u.py122
1 files changed, 91 insertions, 31 deletions
diff --git a/test/option-u.py b/test/option-u.py
index 1f7df7a..9cb0055 100644
--- a/test/option-u.py
+++ b/test/option-u.py
@@ -24,6 +24,11 @@
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+"""
+Test that the -u option only builds targets at or below
+the current directory.
+"""
+
import os.path
import sys
@@ -31,49 +36,104 @@ import TestSCons
test = TestSCons.TestSCons()
-python = TestSCons.python
-
-test.subdir('sub1', 'sub2', 'sub3')
-
-test.write('build.py', r"""
-import sys
-contents = open(sys.argv[2], 'rb').read()
-file = open(sys.argv[1], 'wb')
-file.write(contents)
-file.close()
-""")
+test.subdir('sub1',
+ 'sub2', ['sub2', 'dir'],
+ 'sub3',
+ 'sub4', ['sub4', 'dir'])
test.write('SConstruct', """
+def cat(env, source, target):
+ target = str(target[0])
+ source = map(str, source)
+ f = open(target, "wb")
+ for src in source:
+ f.write(open(src, "rb").read())
+ f.close()
env = Environment()
-env['BUILDERS']['B'] = Builder(action=r'%s build.py $TARGET $SOURCES')
-env.B(target = 'sub1/foo.out', source = 'sub1/foo.in')
+env.Append(BUILDERS = {'Cat' : Builder(action=cat)})
+env.Cat(target = 'sub1/f1a.out', source = 'sub1/f1a.in')
+env.Cat(target = 'sub1/f1b.out', source = 'sub1/f1b.in')
Export('env')
SConscript('sub2/SConscript')
-env.Alias('baz', env.B(target = 'sub3/baz.out', source = 'sub3/baz.in'))
-""" % python)
+f3 = env.Cat(target = 'sub3/f3.out', source = 'sub3/f3.in')
+env.Alias('my_alias', f3)
+BuildDir('build', 'sub4')
+SConscript('build/SConscript')
+""")
test.write(['sub2', 'SConscript'], """
Import('env')
-env.B(target = 'bar.out', source = 'bar.in')
+env.Cat(target = 'f2a.out', source = 'f2a.in')
+env.Cat(target = 'dir/f2b.out', source = 'dir/f2b.in')
""")
-test.write(['sub1', 'foo.in'], "sub1/foo.in")
-test.write(['sub2', 'bar.in'], "sub2/bar.in")
-test.write(['sub3', 'baz.in'], "sub3/baz.in")
-
-test.run(arguments = '-u foo.out', chdir = 'sub1')
-
-test.fail_test(test.read(['sub1', 'foo.out']) != "sub1/foo.in")
-test.fail_test(os.path.exists(test.workpath('sub2', 'bar.out')))
-test.fail_test(os.path.exists(test.workpath('sub3', 'baz.out')))
+test.write(['sub4', 'SConscript'], """
+Import('env')
+env.Cat(target = 'f4a.out', source = 'f4a.in')
+env.Cat(target = 'dir/f4b.out', source = 'dir/f4b.in')
+""")
+test.write(['sub1', 'f1a.in'], "sub1/f1a.in")
+test.write(['sub1', 'f1b.in'], "sub1/f1b.in")
+test.write(['sub2', 'f2a.in'], "sub2/f2a.in")
+test.write(['sub2', 'dir', 'f2b.in'], "sub2/dir/f2b.in")
+test.write(['sub3', 'f3.in'], "sub3/f3.in")
+test.write(['sub4', 'f4a.in'], "sub4/f4a.in")
+test.write(['sub4', 'dir', 'f4b.in'], "sub4/dir/f4b.in")
+
+# Verify that we only build the specified local argument.
+test.run(chdir = 'sub1', arguments = '-u f1a.out')
+
+test.fail_test(test.read(['sub1', 'f1a.out']) != "sub1/f1a.in")
+test.fail_test(os.path.exists(test.workpath('sub1', 'sub1/f1b.out')))
+test.fail_test(os.path.exists(test.workpath('sub2', 'f2a.out')))
+test.fail_test(os.path.exists(test.workpath('sub2', 'dir', 'f2b.out')))
+test.fail_test(os.path.exists(test.workpath('sub3', 'f3.out')))
+test.fail_test(os.path.exists(test.workpath('sub4', 'f4a.out')))
+test.fail_test(os.path.exists(test.workpath('sub4', 'dir', 'f4b.out')))
+test.fail_test(os.path.exists(test.workpath('build', 'f4a.out')))
+test.fail_test(os.path.exists(test.workpath('build', 'dir', 'f4b.out')))
+
+# Verify that we build everything at or below our current directory.
test.run(chdir = 'sub2', arguments = '-u')
-test.fail_test(test.read(['sub2', 'bar.out']) != "sub2/bar.in")
-test.fail_test(os.path.exists(test.workpath('sub3', 'baz.out')))
-
-test.run(chdir = 'sub2', arguments = '-u baz')
-test.fail_test(test.read(['sub3', 'baz.out']) != "sub3/baz.in")
+test.fail_test(os.path.exists(test.workpath('sub1', 'sub1/f1b.out')))
+test.fail_test(test.read(['sub2', 'f2a.out']) != "sub2/f2a.in")
+test.fail_test(test.read(['sub2', 'dir', 'f2b.out']) != "sub2/dir/f2b.in")
+test.fail_test(os.path.exists(test.workpath('sub3', 'f3.out')))
+test.fail_test(os.path.exists(test.workpath('sub4', 'f4a.out')))
+test.fail_test(os.path.exists(test.workpath('sub4', 'dir', 'f4b.out')))
+test.fail_test(os.path.exists(test.workpath('build', 'f4a.out')))
+test.fail_test(os.path.exists(test.workpath('build', 'dir', 'f4b.out')))
+
+# Verify that we build a specified alias, regardless of where.
+test.run(chdir = 'sub2', arguments = '-u my_alias')
+
+test.fail_test(os.path.exists(test.workpath('sub1', 'sub1/f1b.out')))
+test.fail_test(test.read(['sub3', 'f3.out']) != "sub3/f3.in")
+test.fail_test(os.path.exists(test.workpath('sub4', 'f4a.out')))
+test.fail_test(os.path.exists(test.workpath('sub4', 'dir', 'f4b.out')))
+test.fail_test(os.path.exists(test.workpath('build', 'f4a.out')))
+test.fail_test(os.path.exists(test.workpath('build', 'dir', 'f4b.out')))
+
+# Verify that we build things in a linked BuildDir.
+f4a_in = os.path.join('build', 'f4a.in')
+f4a_out = os.path.join('build', 'f4a.out')
+f4b_in = os.path.join('build', 'dir', 'f4b.in')
+f4b_out = os.path.join('build', 'dir', 'f4b.out')
+test.run(chdir = 'sub4',
+ arguments = '-u',
+ stdout = "scons: Entering directory %s\n" % test.workpath() + \
+ test.wrap_stdout("""\
+scons: building associated BuildDir targets: build
+cat("%s", "%s")
+cat("%s", "%s")
+""" % (f4b_out, f4b_in, f4a_out, f4a_in)))
+
+test.fail_test(os.path.exists(test.workpath('sub1', 'sub1/f1b.out')))
+test.fail_test(os.path.exists(test.workpath('sub4', 'f4a.out')))
+test.fail_test(os.path.exists(test.workpath('sub4', 'dir', 'f4b.out')))
+test.fail_test(test.read(['build', 'f4a.out']) != "sub4/f4a.in")
+test.fail_test(test.read(['build', 'dir', 'f4b.out']) != "sub4/dir/f4b.in")
test.pass_test()
-