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.
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
28 Test the SPAWN construction variable.
33 _python_ = TestSCons._python_
35 test = TestSCons.TestSCons()
37 test.write('cat.py', """\
39 ofp = open(sys.argv[1], 'wb')
40 for s in sys.argv[2:]:
41 ofp.write(open(s, 'rb').read())
45 test.write('SConstruct', """
48 def my_spawn1(sh, escape, cmd, args, env):
49 s = " ".join(args + ['extra1.txt'])
50 if sys.platform in ['win32']:
53 def my_spawn2(sh, escape, cmd, args, env):
54 s = " ".join(args + ['extra2.txt'])
55 if sys.platform in ['win32']:
58 env = Environment(MY_SPAWN1 = my_spawn1,
59 MY_SPAWN2 = my_spawn2,
60 COMMAND = r'%(_python_)s cat.py $TARGET $SOURCES')
61 env1 = env.Clone(SPAWN = my_spawn1)
62 env1.Command('file1.out', 'file1.in', '$COMMAND')
64 env2 = env.Clone(SPAWN = '$MY_SPAWN2')
65 env2.Command('file2.out', 'file2.in', '$COMMAND')
67 env3 = env.Clone(SPAWN = '${USE_TWO and MY_SPAWN2 or MY_SPAWN1}')
68 env3.Command('file3.out', 'file3.in', '$COMMAND', USE_TWO=0)
69 env3.Command('file4.out', 'file4.in', '$COMMAND', USE_TWO=1)
72 test.write('file1.in', "file1.in\n")
73 test.write('file2.in', "file2.in\n")
74 test.write('file3.in', "file3.in\n")
75 test.write('file4.in', "file4.in\n")
76 test.write('extra1.txt', "extra1.txt\n")
77 test.write('extra2.txt', "extra2.txt\n")
79 test.run(arguments = '.')
81 test.must_match('file1.out', "file1.in\nextra1.txt\n")
82 test.must_match('file2.out', "file2.in\nextra2.txt\n")
83 test.must_match('file3.out', "file3.in\nextra1.txt\n")
84 test.must_match('file4.out', "file4.in\nextra2.txt\n")
90 # indent-tabs-mode:nil
92 # vim: set expandtab tabstop=4 shiftwidth=4: