diff options
author | Steven Knight <knight@baldmt.com> | 2003-09-08 04:01:32 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2003-09-08 04:01:32 (GMT) |
commit | 68b5dfbc87552d4cd1a9c067f6ba4523d9560bb9 (patch) | |
tree | 910dcf1998d6b72aa8eb4bdb5497177d331ea900 /test | |
parent | 61d018dfceac6cb9717caeeea7125d7a55b4b0eb (diff) | |
download | SCons-68b5dfbc87552d4cd1a9c067f6ba4523d9560bb9.zip SCons-68b5dfbc87552d4cd1a9c067f6ba4523d9560bb9.tar.gz SCons-68b5dfbc87552d4cd1a9c067f6ba4523d9560bb9.tar.bz2 |
Give the global functions corresponding Environment methods.
Diffstat (limited to 'test')
-rw-r--r-- | test/Default.py | 58 | ||||
-rw-r--r-- | test/FindFile.py | 5 | ||||
-rw-r--r-- | test/Repository/Local.py | 4 | ||||
-rw-r--r-- | test/pre-post-actions.py | 60 |
4 files changed, 86 insertions, 41 deletions
diff --git a/test/Default.py b/test/Default.py index d2c438f..ae0346a 100644 --- a/test/Default.py +++ b/test/Default.py @@ -155,57 +155,77 @@ test.fail_test(test.read(test.workpath('eight', 'bar.out')) != "eight/bar.in\n") -test.subdir('sub1') +test.subdir('nine', ['nine', 'sub1']) -test.write('SConstruct', """ +test.write(['nine', 'SConstruct'], """\ B = Builder(action = r'%s build.py $TARGET $SOURCES') env = Environment(BUILDERS = { 'B' : B }) env.B(target = 'xxx.out', source = 'xxx.in') SConscript('sub1/SConscript') """ % python) -test.write('xxx.in', "xxx.in\n") +test.write(['nine', 'xxx.in'], "xxx.in\n") -test.write(['sub1', 'SConscript'], """ -B = Builder(action = r'%s build.py $TARGET $SOURCES') +test.write(['nine', 'sub1', 'SConscript'], """ +B = Builder(action = r'%s ../build.py $TARGET $SOURCES') env = Environment(BUILDERS = { 'B' : B }) env.B(target = 'xxx.out', source = 'xxx.in') Default('xxx.out') """ % python) -test.write(['sub1', 'xxx.in'], "sub1/xxx.in\n") +test.write(['nine', 'sub1', 'xxx.in'], "sub1/xxx.in\n") -test.run() # no arguments, use the Default +test.run(chdir = 'nine') # no arguments, use the Default -test.fail_test(os.path.exists(test.workpath('xxx.out'))) -test.fail_test(test.read(test.workpath('sub1', 'xxx.out')) != "sub1/xxx.in\n") +test.fail_test(os.path.exists(test.workpath('nine', 'xxx.out'))) +test.fail_test(test.read(test.workpath('nine', 'sub1', 'xxx.out')) != "sub1/xxx.in\n") -test.subdir('sub2') +test.subdir('ten', ['ten', 'sub2']) -test.write('SConstruct', """ +test.write(['ten', 'SConstruct'], """\ Default('sub2') -B = Builder(action = r'%s build.py $TARGET $SOURCES') +B = Builder(action = r'%s ../build.py $TARGET $SOURCES') env = Environment(BUILDERS = { 'B' : B }) env.B(target = 'xxx.out', source = 'xxx.in') SConscript('sub2/SConscript') """ % python) -test.write('xxx.in', "xxx.in\n") +test.write(['ten', 'xxx.in'], "xxx.in\n") -test.write(['sub2', 'SConscript'], """ -B = Builder(action = r'%s build.py $TARGET $SOURCES') +test.write(['ten', 'sub2', 'SConscript'], """ +B = Builder(action = r'%s ../build.py $TARGET $SOURCES') env = Environment(BUILDERS = { 'B' : B }) env.B(target = 'xxx.out', source = 'xxx.in') """ % python) -test.write(['sub2', 'xxx.in'], "sub2/xxx.in\n") +test.write(['ten', 'sub2', 'xxx.in'], "sub2/xxx.in\n") + +test.run(chdir = 'ten') # no arguments, use the Default + +test.fail_test(os.path.exists(test.workpath('ten', 'xxx.out'))) +test.fail_test(test.read(test.workpath('ten', 'sub2', 'xxx.out')) != "sub2/xxx.in\n") + + +test.subdir('eleven') + +test.write(['eleven', 'SConstruct'], """ +B = Builder(action = r'%s ../build.py $TARGET $SOURCES') +env = Environment(BUILDERS = { 'B' : B }, XXX = 'foo.out') +env.B(target = 'foo.out', source = 'foo.in') +env.B(target = 'bar.out', source = 'bar.in') +env.Default('$XXX') +""" % python) + +test.write(os.path.join('eleven', 'foo.in'), "eleven/foo.in\n"); + +test.write(os.path.join('eleven', 'bar.in'), "eleven/bar.in\n"); -test.run() # no arguments, use the Default +test.run(chdir = 'eleven') # no arguments, use the Default -test.fail_test(os.path.exists(test.workpath('xxx.out'))) -test.fail_test(test.read(test.workpath('sub2', 'xxx.out')) != "sub2/xxx.in\n") +test.fail_test(test.read(test.workpath('eleven', 'foo.out')) != "eleven/foo.in\n") +test.fail_test(os.path.exists(test.workpath('eleven', 'bar'))) diff --git a/test/FindFile.py b/test/FindFile.py index 9c837b5..8f6cb1a 100644 --- a/test/FindFile.py +++ b/test/FindFile.py @@ -38,13 +38,14 @@ test.write(['bar', 'testfile1'], 'test 3\n') test.write(['bar', 'baz', 'testfile2'], 'test 4\n') test.write('SConstruct', """ +env = Environment(FILE = 'file', BAR = 'bar') file1 = FindFile('testfile1', [ 'foo', '.', 'bar', 'bar/baz' ]) print open(str(file1), 'r').read() -file2 = FindFile('testfile1', [ 'bar', 'foo', '.', 'bar/baz' ]) +file2 = env.FindFile('test${FILE}1', [ 'bar', 'foo', '.', 'bar/baz' ]) print open(str(file2), 'r').read() file3 = FindFile('testfile2', [ 'foo', '.', 'bar', 'bar/baz' ]) print open(str(file3), 'r').read() -file4 = FindFile('testfile2', [ 'bar/baz', 'foo', '.', 'bar' ]) +file4 = env.FindFile('testfile2', [ '$BAR/baz', 'foo', '.', 'bar' ]) print open(str(file4), 'r').read() """) diff --git a/test/Repository/Local.py b/test/Repository/Local.py index 1163767..5962095 100644 --- a/test/Repository/Local.py +++ b/test/Repository/Local.py @@ -52,7 +52,7 @@ def copy(env, source, target): open(target, "wb").write(open(source, "rb").read()) Build = Builder(action=copy) -env = Environment(BUILDERS={'Build':Build}) +env = Environment(BUILDERS={'Build':Build}, BBB='bbb') env.Build('aaa.mid', 'aaa.in') env.Build('aaa.out', 'aaa.mid') Local('aaa.out') @@ -70,7 +70,7 @@ def bbb_copy(env, source, target): Import("env") env.Build('bbb.1', 'bbb.0') -Local('bbb.1') +env.Local('${BBB}.1') env.Command('bbb.2', 'bbb.x', bbb_copy) env.Depends('bbb.2', 'bbb.1') """) diff --git a/test/pre-post-actions.py b/test/pre-post-actions.py index 91fcb3b..d5340f2 100644 --- a/test/pre-post-actions.py +++ b/test/pre-post-actions.py @@ -36,32 +36,22 @@ _exe = TestSCons._exe test = TestSCons.TestSCons() -test.write('foo.c', r""" -#include <stdio.h> - -int main(void) -{ - printf("Foo\n"); - return 0; -} -""") - test.write('SConstruct', """ import os.path -env=Environment() +env = Environment(XXX='bar%s') def before(env, target, source): f=open(str(target[0]), "wb") f.write("Foo\\n") f.close() - f=open("before.txt", "wb") - f.write("Bar\\n") + f=open("before.txt", "ab") + f.write(str(target[0]) + "\\n") f.close() def after(env, target, source): fin = open(str(target[0]), "rb") - fout = open("after%s", "wb") + fout = open("after_" + str(target[0]), "wb") fout.write(fin.read()) fout.close() fin.close() @@ -69,12 +59,46 @@ def after(env, target, source): foo = env.Program(source='foo.c', target='foo') AddPreAction(foo, before) AddPostAction('foo%s', after) + +bar = env.Program(source='bar.c', target='bar') +env.AddPreAction('$XXX', before) +env.AddPostAction('$XXX', after) """ % (_exe, _exe)) -after_exe = test.workpath('after' + _exe) +test.write('foo.c', r""" +#include <stdio.h> + +int main(void) +{ + printf("foo.c\n"); + return 0; +} +""") + +test.write('bar.c', r""" +#include <stdio.h> + +int main(void) +{ + printf("bar.c\n"); + return 0; +} +""") + test.run(arguments='.') -test.fail_test(open('before.txt', 'rb').read() != "Bar\n") -os.chmod(after_exe, os.stat(after_exe)[stat.ST_MODE] | stat.S_IXUSR) -test.run(program=test.workpath(after_exe), stdout="Foo\n") + +test.run(program=test.workpath('foo'+ _exe), stdout="foo.c\n") +test.run(program=test.workpath('bar'+ _exe), stdout="bar.c\n") + +test.fail_test(test.read('before.txt', 'rb') != "bar%s\nfoo%s\n" % (_exe, _exe)) + +after_foo_exe = test.workpath('after_foo' + _exe) +os.chmod(after_foo_exe, os.stat(after_foo_exe)[stat.ST_MODE] | stat.S_IXUSR) +test.run(program=test.workpath(after_foo_exe), stdout="foo.c\n") + +after_bar_exe = test.workpath('after_bar' + _exe) +os.chmod(after_bar_exe, os.stat(after_bar_exe)[stat.ST_MODE] | stat.S_IXUSR) +test.run(program=test.workpath(after_bar_exe), stdout="bar.c\n") + test.pass_test() |