5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 # This test exercises the addition operator of Action objects.
25 # Using Environment.Prepend() and Environment.Append(), you should be
26 # able to add new actions to existing ones, effectively adding steps
29 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
36 if sys.platform == 'win32':
41 test = TestSCons.TestSCons()
43 test.write('foo.c', r"""
53 test.write('SConstruct', """
57 def before(env, target, source):
58 f=open(str(target[0]), "wb")
61 f=open("before.txt", "wb")
65 def after(env, target, source):
66 fin = open(str(target[0]), "rb")
67 fout = open("after%s", "wb")
68 fout.write(fin.read())
72 env.Prepend(LINKCOM=Action(before))
73 env.Append(LINKCOM=Action(after))
74 env.Program(source='foo.c', target='foo')
77 after_exe = test.workpath('after' + _exe)
79 test.run(arguments='.')
80 test.fail_test(open('before.txt', 'rb').read() != "Bar\n")
81 os.chmod(after_exe, os.stat(after_exe)[stat.ST_MODE] | stat.S_IXUSR)
82 test.run(program=after_exe, stdout="Foo\n")
87 # indent-tabs-mode:nil
89 # vim: set expandtab tabstop=4 shiftwidth=4: