diff options
| author | Steven Knight <knight@baldmt.com> | 2003-09-05 19:26:05 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2003-09-05 19:26:05 (GMT) |
| commit | bf221d4e593f803116af76ec3bc16514b666c9f1 (patch) | |
| tree | d80f1ab39365370ce1f50dba335af34f8cad83e2 /test | |
| parent | f1d7f1dc87300ea5c905c648c39aeee031100c8c (diff) | |
| download | SCons-bf221d4e593f803116af76ec3bc16514b666c9f1.zip SCons-bf221d4e593f803116af76ec3bc16514b666c9f1.tar.gz SCons-bf221d4e593f803116af76ec3bc16514b666c9f1.tar.bz2 | |
Support construction variable expansion anywhere in a file or path name.
Diffstat (limited to 'test')
| -rw-r--r-- | test/AlwaysBuild.py | 17 | ||||
| -rw-r--r-- | test/Depends.py | 24 | ||||
| -rw-r--r-- | test/Ignore.py | 25 | ||||
| -rw-r--r-- | test/Install.py | 11 | ||||
| -rw-r--r-- | test/InstallAs.py | 68 | ||||
| -rw-r--r-- | test/Precious.py | 47 | ||||
| -rw-r--r-- | test/SideEffect.py | 29 | ||||
| -rw-r--r-- | test/SourceCode.py | 95 | ||||
| -rw-r--r-- | test/expansion.py | 108 | ||||
| -rw-r--r-- | test/special-filenames.py | 8 |
10 files changed, 383 insertions, 49 deletions
diff --git a/test/AlwaysBuild.py b/test/AlwaysBuild.py index f4126c1..832120a 100644 --- a/test/AlwaysBuild.py +++ b/test/AlwaysBuild.py @@ -31,25 +31,36 @@ import TestSCons test = TestSCons.TestSCons() -test.write('SConstruct', """ +test.subdir('sub') + +test.write('SConstruct', """\ def bfunc(target, source, env): import shutil shutil.copyfile('f2.in', str(target[0])) B = Builder(action=bfunc) -env = Environment(BUILDERS = { 'B' : B }) +env = Environment(BUILDERS = { 'B' : B }, SUBDIR='sub') env.B('f1.out', source='f1.in') env.AlwaysBuild('f1.out') -""") + +env.B(r'%s', source='f3.in') +env.AlwaysBuild(r'%s') +""" % (os.path.join('sub', 'f3.out'), + os.path.join('$SUBDIR', 'f3.out') + )) test.write('f1.in', "f1.in\n") test.write('f2.in', "1") +test.write('f3.in', "f3.in\n") test.run(arguments = ".") test.fail_test(test.read('f1.out') != '1') +test.fail_test(test.read(['sub', 'f3.out']) != '1') test.write('f2.in', "2") + test.run(arguments = ".") test.fail_test(test.read('f1.out') != '2') +test.fail_test(test.read(['sub', 'f3.out']) != '2') test.pass_test() diff --git a/test/Depends.py b/test/Depends.py index dd3c2b5..d65f2b6 100644 --- a/test/Depends.py +++ b/test/Depends.py @@ -24,7 +24,8 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import sys +import os.path + import TestSCons python = TestSCons.python @@ -44,14 +45,17 @@ file.close() test.write('SConstruct', """ Foo = Builder(action = r"%s build.py $TARGET $SOURCES subdir/foo.dep") Bar = Builder(action = r"%s build.py $TARGET $SOURCES subdir/bar.dep") -env = Environment(BUILDERS = { 'Foo' : Foo, 'Bar' : Bar }) -env.Depends(target = ['f1.out', 'f2.out'], dependency = 'subdir/foo.dep') -env.Depends(target = 'f3.out', dependency = 'subdir/bar.dep') +env = Environment(BUILDERS = { 'Foo' : Foo, 'Bar' : Bar }, SUBDIR='subdir') +env.Depends(target = ['f1.out', 'f2.out'], dependency = r'%s') +env.Depends(target = r'%s', dependency = 'subdir/bar.dep') env.Foo(target = 'f1.out', source = 'f1.in') env.Foo(target = 'f2.out', source = 'f2.in') -env.Bar(target = 'f3.out', source = 'f3.in') +env.Bar(target = 'subdir/f3.out', source = 'f3.in') SConscript('subdir/SConscript', "env") -""" % (python, python)) +""" % (python, + python, + os.path.join('$SUBDIR', 'foo.dep'), + os.path.join('$SUBDIR', 'f3.out'))) test.write(['subdir', 'SConscript'], """ Import("env") @@ -71,11 +75,11 @@ test.write(['subdir', 'foo.dep'], "subdir/foo.dep 1\n") test.write(['subdir', 'bar.dep'], "subdir/bar.dep 1\n") -test.run(arguments = '.') +test.run(arguments = '--debug=dtree .') 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('f3.out') != "f3.in\nsubdir/bar.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") @@ -87,7 +91,7 @@ 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('f3.out') != "f3.in\nsubdir/bar.dep 2\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") @@ -97,7 +101,7 @@ 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('f3.out') != "f3.in\nsubdir/bar.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") diff --git a/test/Ignore.py b/test/Ignore.py index 5d87bba..6809434 100644 --- a/test/Ignore.py +++ b/test/Ignore.py @@ -24,7 +24,8 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import sys +import os.path + import TestSCons python = TestSCons.python @@ -42,14 +43,19 @@ for arg in sys.argv[2:]: file.close() """) -test.write('SConstruct', """ +test.write('SConstruct', """\ Foo = Builder(action = r"%s build.py $TARGET $SOURCES") Bar = Builder(action = r"%s build.py $TARGET $SOURCES") -env = Environment(BUILDERS = { 'Foo' : Foo, 'Bar' : Bar }) +env = Environment(BUILDERS = { 'Foo' : Foo, 'Bar' : Bar }, SUBDIR='subdir') env.Foo(target = 'f1.out', source = ['f1a.in', 'f1b.in']) env.Ignore(target = 'f1.out', dependency = 'f1b.in') SConscript('subdir/SConscript', "env") -""" % (python, python)) +env.Foo(target = 'subdir/f3.out', source = ['subdir/f3a.in', 'subdir/f3b.in']) +env.Ignore(target = r'%s', dependency = r'%s') +""" % (python, + python, + os.path.join('$SUBDIR', 'f3.out'), + os.path.join('$SUBDIR', 'f3b.in'))) test.write(['subdir', 'SConscript'], """ Import("env") @@ -63,31 +69,42 @@ test.write('f1b.in', "f1b.in\n") test.write(['subdir', 'f2a.in'], "subdir/f2a.in\n") test.write(['subdir', 'f2b.in'], "subdir/f2b.in\n") +test.write(['subdir', 'f3a.in'], "subdir/f3a.in\n") +test.write(['subdir', 'f3b.in'], "subdir/f3b.in\n") + test.run(arguments = '.') test.fail_test(test.read('f1.out') != "f1a.in\nf1b.in\n") test.fail_test(test.read(['subdir', 'f2.out']) != "subdir/f2a.in\nsubdir/f2b.in\n") +test.fail_test(test.read(['subdir', 'f3.out']) != + "subdir/f3a.in\nsubdir/f3b.in\n") test.up_to_date(arguments = '.') test.write('f1b.in', "f1b.in 2\n") test.write(['subdir', 'f2a.in'], "subdir/f2a.in 2\n") +test.write(['subdir', 'f3b.in'], "subdir/f3b.in 2\n") test.up_to_date(arguments = '.') test.fail_test(test.read('f1.out') != "f1a.in\nf1b.in\n") test.fail_test(test.read(['subdir', 'f2.out']) != "subdir/f2a.in\nsubdir/f2b.in\n") +test.fail_test(test.read(['subdir', 'f3.out']) != + "subdir/f3a.in\nsubdir/f3b.in\n") test.write('f1a.in', "f1a.in 2\n") test.write(['subdir', 'f2b.in'], "subdir/f2b.in 2\n") +test.write(['subdir', 'f3a.in'], "subdir/f3a.in 2\n") test.run(arguments = '.') test.fail_test(test.read('f1.out') != "f1a.in 2\nf1b.in 2\n") test.fail_test(test.read(['subdir', 'f2.out']) != "subdir/f2a.in 2\nsubdir/f2b.in 2\n") +test.fail_test(test.read(['subdir', 'f3.out']) != + "subdir/f3a.in 2\nsubdir/f3b.in 2\n") test.up_to_date(arguments = '.') diff --git a/test/Install.py b/test/Install.py index f69c954..7637662 100644 --- a/test/Install.py +++ b/test/Install.py @@ -35,9 +35,12 @@ import TestSCons test = TestSCons.TestSCons() +test.subdir('sub') + f1_out = test.workpath('export', 'f1.out') f2_out = test.workpath('export', 'f2.out') f3_out = test.workpath('export', 'f3.out') +f4_out = test.workpath('export', 'f4.out') test.write('SConstruct', """\ def cat(env, source, target): @@ -64,17 +67,23 @@ env1.Install(dir='export', source=t) t = env3.Cat(target='f3.out', source='f3.in') env3.Install(dir='export', source=t) -""") + +env4 = env1.Copy(EXPORT='export', SUBDIR='sub') +t = env4.Cat(target='sub/f4.out', source='sub/f4.in') +env4.Install(dir='$EXPORT', source=r'%s') +""" % (os.path.join('$SUBDIR', 'f4.out'))) test.write('f1.in', "f1.in\n") test.write('f2.in', "f2.in\n") test.write('f3.in', "f3.in\n") +test.write(['sub', 'f4.in'], "sub/f4.in\n") test.run(arguments = '.') test.fail_test(test.read(f1_out) != "f1.in\n") test.fail_test(test.read(f2_out) != "f2.in\n") test.fail_test(test.read(f3_out) != "f3.in\n") +test.fail_test(test.read(f4_out) != "sub/f4.in\n") test.fail_test(test.read('my_install.out') != os.path.join('export', 'f3.out')) diff --git a/test/InstallAs.py b/test/InstallAs.py new file mode 100644 index 0000000..643ac85 --- /dev/null +++ b/test/InstallAs.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test the InstallAs() Environment method. +""" + +import os.path +import sys +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('install', 'subdir') + +install = test.workpath('install') +install_file1_out = test.workpath('install', 'file1.out') +install_file2_out = test.workpath('install', 'file2.out') +install_file3_out = test.workpath('install', 'file3.out') + +# +test.write('SConstruct', r""" +env = Environment(INSTALLDIR=r'%s', SUBDIR='subdir') +env.InstallAs(r'%s', 'file1.in') +env.InstallAs([r'%s', r'%s'], ['file2.in', r'%s']) +""" % (install, + install_file1_out, + os.path.join('$INSTALLDIR', 'file2.out'), + install_file3_out, + os.path.join('$SUBDIR', 'file3.in'))) + +test.write('file1.in', "file1.in\n") +test.write('file2.in', "file2.in\n") +test.write(['subdir', 'file3.in'], "subdir/file3.in\n") + +test.run(arguments = '.') + +test.fail_test(test.read(install_file1_out) != "file1.in\n") +test.fail_test(test.read(install_file2_out) != "file2.in\n") +test.fail_test(test.read(install_file3_out) != "subdir/file3.in\n") + +test.up_to_date(arguments = '.') + +# +test.pass_test() diff --git a/test/Precious.py b/test/Precious.py index 8b2c7ff..6aee9b0 100644 --- a/test/Precious.py +++ b/test/Precious.py @@ -24,8 +24,8 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import os -import sys +import os.path + import TestSCons python = TestSCons.python @@ -39,74 +39,81 @@ import sys sys.exit(0) """) -test.write('SConstruct', """ +test.write('SConstruct', """\ B = Builder(action = r"%s build.py $TARGET $SOURCES") -env = Environment(BUILDERS = { 'B' : B }) +env = Environment(BUILDERS = { 'B' : B }, SUBDIR = 'subdir') f1 = env.B(target = 'f1.out', source = 'f1.in') env.B(target = 'f2.out', source = 'f2.in') env.B(target = 'f3.out', source = 'f3.in') -env.Precious(f1, 'f2.out') +env.B(target = 'subdir/f4.out', source = 'f4.in') +env.Precious(f1, 'f2.out', r'%s') SConscript('subdir/SConscript', "env") -""" % python) +""" % (python, + os.path.join('$SUBDIR', 'f4.out'))) test.write(['subdir', 'SConscript'], """ Import("env") -env.B(target = 'f4.out', source = 'f4.in') -f5 = env.B(target = 'f5.out', source = 'f5.in') -env.B(target = 'f6.out', source = 'f6.in') -env.Precious(['f4.out', f5]) +env.B(target = 'f5.out', source = 'f5.in') +f6 = env.B(target = 'f6.out', source = 'f6.in') +env.B(target = 'f7.out', source = 'f7.in') +env.Precious(['f5.out', f6]) """) test.write('f1.in', "f1.in\n") test.write('f2.in', "f2.in\n") test.write('f3.in', "f3.in\n") +test.write('f4.in', "f4.in\n") -test.write(['subdir', 'f4.in'], "subdir/f4.in\n") test.write(['subdir', 'f5.in'], "subdir/f5.in\n") test.write(['subdir', 'f6.in'], "subdir/f6.in\n") +test.write(['subdir', 'f7.in'], "subdir/f7.in\n") test.write('f1.out', "SHOULD NOT BE REMOVED\n") test.write('f2.out', "SHOULD NOT BE REMOVED\n") test.write('f3.out', "SHOULD BE REMOVED\n") - test.write(['subdir', 'f4.out'], "SHOULD NOT BE REMOVED\n") + test.write(['subdir', 'f5.out'], "SHOULD NOT BE REMOVED\n") -test.write(['subdir', 'f6.out'], "SHOULD BE REMOVED\n") +test.write(['subdir', 'f6.out'], "SHOULD NOT BE REMOVED\n") +test.write(['subdir', 'f7.out'], "SHOULD BE REMOVED\n") test.run(arguments = '.') test.fail_test(not os.path.exists(test.workpath('f1.out'))) test.fail_test(not os.path.exists(test.workpath('f2.out'))) test.fail_test(os.path.exists(test.workpath('f3.out'))) - test.fail_test(not os.path.exists(test.workpath('subdir', 'f4.out'))) + test.fail_test(not os.path.exists(test.workpath('subdir', 'f5.out'))) -test.fail_test(os.path.exists(test.workpath('subdir', 'f6.out'))) +test.fail_test(not os.path.exists(test.workpath('subdir', 'f6.out'))) +test.fail_test(os.path.exists(test.workpath('subdir', 'f7.out'))) test.write('f3.out', "SHOULD BE REMOVED\n") -test.write(['subdir', 'f6.out'], "SHOULD BE REMOVED\n") +test.write(['subdir', 'f7.out'], "SHOULD BE REMOVED\n") test.run(arguments = '.') test.fail_test(not os.path.exists(test.workpath('f1.out'))) test.fail_test(not os.path.exists(test.workpath('f2.out'))) test.fail_test(not os.path.exists(test.workpath('f3.out'))) - test.fail_test(not os.path.exists(test.workpath('subdir', 'f4.out'))) + test.fail_test(not os.path.exists(test.workpath('subdir', 'f5.out'))) test.fail_test(not os.path.exists(test.workpath('subdir', 'f6.out'))) +test.fail_test(not os.path.exists(test.workpath('subdir', 'f7.out'))) test.write('f3.in', "f3.in 2\n") -test.write(['subdir', 'f6.in'], "subdir/f6.in 2\n") +test.write(['subdir', 'f7.in'], "subdir/f7.in 2\n") test.run(arguments = '.') test.fail_test(not os.path.exists(test.workpath('f1.out'))) test.fail_test(not os.path.exists(test.workpath('f2.out'))) test.fail_test(os.path.exists(test.workpath('f3.out'))) - test.fail_test(not os.path.exists(test.workpath('subdir', 'f4.out'))) + test.fail_test(not os.path.exists(test.workpath('subdir', 'f5.out'))) -test.fail_test(os.path.exists(test.workpath('subdir', 'f6.out'))) +test.fail_test(not os.path.exists(test.workpath('subdir', 'f6.out'))) +test.fail_test(os.path.exists(test.workpath('subdir', 'f7.out'))) test.pass_test() diff --git a/test/SideEffect.py b/test/SideEffect.py index ca2dc4f..61b0d58 100644 --- a/test/SideEffect.py +++ b/test/SideEffect.py @@ -24,13 +24,13 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import TestSCons import os.path +import TestSCons + test = TestSCons.TestSCons() -test.write('SConstruct', -""" +test.write('SConstruct', """\ def copy(source, target): open(target, "wb").write(open(source, "rb").read()) @@ -38,20 +38,25 @@ def build(env, source, target): copy(str(source[0]), str(target[0])) if target[0].side_effects: side_effect = open(str(target[0].side_effects[0]), "ab") - side_effect.write('%s -> %s\\n'%(str(source[0]), str(target[0]))) + side_effect.write('%%s -> %%s\\n'%%(str(source[0]), str(target[0]))) Build = Builder(action=build) -env = Environment(BUILDERS={'Build':Build}) +env = Environment(BUILDERS={'Build':Build}, SUBDIR='subdir') env.Build('foo.out', 'foo.in') env.Build('bar.out', 'bar.in') env.Build('blat.out', 'blat.in') env.SideEffect('log.txt', ['foo.out', 'bar.out', 'blat.out']) env.Build('log.out', 'log.txt') -""") +env.Build('subdir/baz.out', 'baz.in') +env.SideEffect(r'%s', ['blat.out', r'%s']) +env.Build('subdir/out.out', 'subdir/out.txt') +""" % (os.path.join('$SUBDIR', 'out.txt'), + os.path.join('$SUBDIR', 'baz.out'))) test.write('foo.in', 'foo.in\n') test.write('bar.in', 'bar.in\n') test.write('blat.in', 'blat.in\n') +test.write('baz.in', 'baz.in\n') test.run(arguments = 'foo.out bar.out', stdout=test.wrap_stdout("""\ build("foo.out", "foo.in") @@ -84,7 +89,11 @@ test.write('foo.in', 'foo.in 2 \n') test.run(arguments = ".", stdout=test.wrap_stdout("""\ build("foo.out", "foo.in") build("log.out", "log.txt") -""")) +build("%s", "baz.in") +build("%s", "%s") +""" % (os.path.join('subdir', 'baz.out'), + os.path.join('subdir', 'out.out'), + os.path.join('subdir', 'out.txt')))) expect = """\ foo.in -> foo.out @@ -107,7 +116,11 @@ build("bar.out", "bar.in") build("blat.out", "blat.in") build("foo.out", "foo.in") build("log.out", "log.txt") -""")) +build("%s", "baz.in") +build("%s", "%s") +""" % (os.path.join('subdir', 'baz.out'), + os.path.join('subdir', 'out.out'), + os.path.join('subdir', 'out.txt')))) expect = """\ bar.in -> bar.out diff --git a/test/SourceCode.py b/test/SourceCode.py new file mode 100644 index 0000000..cd8baf4 --- /dev/null +++ b/test/SourceCode.py @@ -0,0 +1,95 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test fetching source files using the SourceCode() method. +""" + +import os +import stat + +import TestSCons + +test = TestSCons.TestSCons() + +test.subdir('sub') + +test.write('SConstruct', """\ +import os.path + +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() + +def sc_cat(env, source, target): + source = [] + for t in target: + head, tail = os.path.split(str(t)) + source.append(os.path.join(head, 'sc-' + tail)) + cat(env, source, target) + +env = Environment(BUILDERS={'Cat':Builder(action=cat)}, SUBDIR='sub') +env.Cat('aaa.out', 'sub/aaa.in') +env.Cat('bbb.out', 'sub/bbb.in') +env.Cat('ccc.out', 'sub/ccc.in') +env.Cat('all', ['aaa.out', 'bbb.out', 'ccc.out']) +env.SourceCode('$SUBDIR', Builder(action=sc_cat, env=env)) +SConscript('sub/SConscript', "env") +""") + +test.write(['sub', 'sc-aaa.in'], "sub/sc-aaa.in\n") +test.write(['sub', 'sc-bbb.in'], "sub/sc-bbb.in\n") +test.write(['sub', 'sc-ccc.in'], "sub/sc-ccc.in\n") + +test.write(['sub', 'sc-SConscript'], "'sub/sc-SConscript'\n") + +test.run(arguments = '.', + stdout = test.wrap_stdout(read_str = """\ +sc_cat("%s", []) +""" % (os.path.join('sub', 'SConscript')), + build_str = """\ +sc_cat("%s", []) +cat("aaa.out", "%s") +sc_cat("%s", []) +cat("bbb.out", "%s") +sc_cat("%s", []) +cat("ccc.out", "%s") +cat("all", ["aaa.out", "bbb.out", "ccc.out"]) +""" % (os.path.join('sub', 'aaa.in'), + os.path.join('sub', 'aaa.in'), + os.path.join('sub', 'bbb.in'), + os.path.join('sub', 'bbb.in'), + os.path.join('sub', 'ccc.in'), + os.path.join('sub', 'ccc.in')))) + +test.fail_test(test.read(['sub', 'SConscript']) != "'sub/sc-SConscript'\n") +test.fail_test(test.read('all') != "sub/sc-aaa.in\nsub/sc-bbb.in\nsub/sc-ccc.in\n") + +test.pass_test() diff --git a/test/expansion.py b/test/expansion.py new file mode 100644 index 0000000..7b8676b --- /dev/null +++ b/test/expansion.py @@ -0,0 +1,108 @@ +#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Test construction variable expansion in Builder paths. +""" + +import os.path +import sys +import time +import TestSCons + +_exe = TestSCons._exe +_obj = TestSCons._obj + +test = TestSCons.TestSCons() + +test.subdir('sub') + +test.write('SConstruct', """\ +env = Environment(SUBDIR = 'sub') +env.Program(target = 'foo1', source = env.Object(source = r'%s')) +env.Program(source = env.Object(target = r'%s', source = 'f2.c')) +env.Program('foo3', r'%s') +env.Program(r'%s') +""" % (os.path.join('$SUBDIR', 'f1.c'), + os.path.join('$SUBDIR', 'foo2'), + os.path.join('$SUBDIR', 'f3.c'), + os.path.join('$SUBDIR', 'foo4.c'))) + +test.write(['sub', 'f1.c'], r""" +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("sub/f1.c\n"); + exit (0); +} +""") + +test.write('f2.c', r""" +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("f2.c\n"); + exit (0); +} +""") + +test.write(['sub', 'f3.c'], r""" +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("sub/f3.c\n"); + exit (0); +} +""") + +test.write(['sub', 'foo4.c'], r""" +int +main(int argc, char *argv[]) +{ + argv[argc++] = "--"; + printf("sub/foo4.c\n"); + exit (0); +} +""") + +test.run(arguments = '.') + +test.run(program = test.workpath('foo1' + _exe), stdout = "sub/f1.c\n") +test.run(program = test.workpath('sub', 'foo2' + _exe), stdout = "f2.c\n") +test.run(program = test.workpath('foo3' + _exe), stdout = "sub/f3.c\n") +test.run(program = test.workpath('sub','foo4' + _exe), stdout = "sub/foo4.c\n") + +test.fail_test(not os.path.exists(test.workpath('sub', 'f1' + _obj))) +test.fail_test(not os.path.exists(test.workpath('sub', 'foo2' + _obj))) +test.fail_test(not os.path.exists(test.workpath('sub', 'f3' + _obj))) +test.fail_test(not os.path.exists(test.workpath('sub', 'foo4' + _obj))) + +test.up_to_date(arguments = '.') + +test.pass_test() diff --git a/test/special-filenames.py b/test/special-filenames.py index 2002b37..98096b7 100644 --- a/test/special-filenames.py +++ b/test/special-filenames.py @@ -45,7 +45,7 @@ attempt_file_names = [ "File&with&ersand", "File?with?question", "File\twith\ttab", - "File$with$dollar", + "File$$with$$dollar", "Combination '\"\n\\;<>?|*\t&" ] @@ -57,7 +57,8 @@ open(sys.argv[1], 'wb').write(open(sys.argv[2], 'rb').read()) file_names = [] for fn in attempt_file_names: try: - test.write(fn + '.in', fn + '\n') + in_name = string.replace(fn, '$$', '$') + '.in' + test.write(in_name, fn + '\n') file_names.append(fn) except IOError: # if the Python interpreter can't handle it, don't bother @@ -76,6 +77,7 @@ env=Environment(BUILDERS = {'Build' : Builder(action = '%s cat.py $TARGET $SOURC test.run(arguments='.') for fn in file_names: - test.fail_test(test.read(fn + '.out') != fn + '\n') + out_name = string.replace(fn, '$$', '$') + '.out' + test.fail_test(test.read(out_name) != fn + '\n') test.pass_test() |
