diff options
author | Steven Knight <knight@baldmt.com> | 2001-11-02 03:12:07 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2001-11-02 03:12:07 (GMT) |
commit | 2f51f69cf055ec44e37eaac22b1992bd5218278f (patch) | |
tree | 60165bd248d020974a0be3f5477825876a682445 /test | |
parent | 00c3ada748b164ecf909727fa81f521dde72fda9 (diff) | |
download | SCons-2f51f69cf055ec44e37eaac22b1992bd5218278f.zip SCons-2f51f69cf055ec44e37eaac22b1992bd5218278f.tar.gz SCons-2f51f69cf055ec44e37eaac22b1992bd5218278f.tar.bz2 |
Rebuild in response to a changed build command.
Diffstat (limited to 'test')
-rw-r--r-- | test/CCFLAGS.py | 15 | ||||
-rw-r--r-- | test/actions.py | 109 |
2 files changed, 123 insertions, 1 deletions
diff --git a/test/CCFLAGS.py b/test/CCFLAGS.py index cc6ad73..8b0e5a8 100644 --- a/test/CCFLAGS.py +++ b/test/CCFLAGS.py @@ -53,9 +53,22 @@ main(int argc, char *argv[]) """) -test.run(arguments = 'foo bar') +test.run(arguments = '.') test.run(program = test.workpath('foo'), stdout = "prog.c: FOO\n") test.run(program = test.workpath('bar'), stdout = "prog.c: BAR\n") +test.write('SConstruct', """ +bar = Environment(CCFLAGS = '-DBAR') +bar.Object(target = 'foo.o', source = 'prog.c') +bar.Object(target = 'bar.o', source = 'prog.c') +bar.Program(target = 'foo', source = 'foo.o') +bar.Program(target = 'bar', source = 'bar.o') +""") + +test.run(arguments = '.') + +test.run(program = test.workpath('foo'), stdout = "prog.c: BAR\n") +test.run(program = test.workpath('bar'), stdout = "prog.c: BAR\n") + test.pass_test() diff --git a/test/actions.py b/test/actions.py new file mode 100644 index 0000000..cee067e --- /dev/null +++ b/test/actions.py @@ -0,0 +1,109 @@ +#!/usr/bin/env python +# +# Copyright (c) 2001 Steven Knight +# +# 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__" + +import sys +import TestSCons + +python = sys.executable + +test = TestSCons.TestSCons() + +test.write('build.py', r""" +import sys +file = open(sys.argv[1], 'wb') +file.write(sys.argv[2] + "\n") +file.write(open(sys.argv[3], 'rb').read()) +file.close +sys.exit(0) +""") + +test.write('SConstruct', """ +B = Builder(name = 'B', action = r'%s build.py $TARGET 1 $SOURCES') +env = Environment(BUILDERS = [B]) +env.B(target = 'foo.out', source = 'foo.in') +""" % python) + +test.write('foo.in', "foo.in\n") + +test.run(arguments = '.') + +test.fail_test(test.read('foo.out') != "1\nfoo.in\n") + +test.up_to_date(arguments = '.') + +test.write('SConstruct', """ +B = Builder(name = 'B', action = r'%s build.py $TARGET 2 $SOURCES') +env = Environment(BUILDERS = [B]) +env.B(target = 'foo.out', source = 'foo.in') +""" % python) + +test.run(arguments = '.') + +test.fail_test(test.read('foo.out') != "2\nfoo.in\n") + +test.up_to_date(arguments = '.') + +test.write('SConstruct', """ +import os +import SCons.Util +def func(**kw): + cmd = SCons.Util.scons_subst(r'%s build.py $TARGET 3 $SOURCES', kw, {}) + return os.system(cmd) +B = Builder(name = 'B', action = func) +env = Environment(BUILDERS = [B]) +env.B(target = 'foo.out', source = 'foo.in') +""" % python) + +test.run(arguments = '.') + +test.fail_test(test.read('foo.out') != "3\nfoo.in\n") + +test.up_to_date(arguments = '.') + +test.write('SConstruct', """ +import os +import SCons.Util +class bld: + def __init__(self): + self.cmd = r'%s build.py $TARGET 4 $SOURCES' + def __call__(self, **kw): + cmd = SCons.Util.scons_subst(self.cmd, kw, {}) + return os.system(cmd) + def get_contents(self, **kw): + cmd = SCons.Util.scons_subst(self.cmd, kw, {}) + return cmd +B = Builder(name = 'B', action = bld()) +env = Environment(BUILDERS = [B]) +env.B(target = 'foo.out', source = 'foo.in') +""" % python) + +test.run(arguments = '.') + +test.fail_test(test.read('foo.out') != "4\nfoo.in\n") + +test.up_to_date(arguments = '.') + +test.pass_test() |