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 Execute() function for executing actions directly.
33 _python_ = TestSCons._python_
35 test = TestSCons.TestSCons()
37 test.write('my_copy.py', """\
39 open(sys.argv[2], 'wb').write(open(sys.argv[1], 'rb').read())
41 exitval = int(sys.argv[3])
47 test.write('SConstruct', """\
48 Execute('%(_python_)s my_copy.py a.in a.out')
49 Execute(Action('%(_python_)s my_copy.py b.in b.out'))
50 env = Environment(COPY = 'my_copy.py')
51 env.Execute('%(_python_)s my_copy.py c.in c.out')
52 env.Execute(Action('%(_python_)s my_copy.py d.in d.out'))
53 v = env.Execute('%(_python_)s $COPY e.in e.out')
55 v = env.Execute(Action('%(_python_)s $COPY f.in f.out'))
57 v = env.Execute('%(_python_)s $COPY g.in g.out 1')
59 v = env.Execute(Action('%(_python_)s $COPY h.in h.out 2'))
62 Execute(lambda target, source, env: shutil.copy('i.in', 'i.out'))
63 Execute(Action(lambda target, source, env: shutil.copy('j.in', 'j.out')))
64 env.Execute(lambda target, source, env: shutil.copy('k.in', 'k.out'))
65 env.Execute(Action(lambda target, source, env: shutil.copy('l.in', 'l.out')))
67 Execute(Copy('m.out', 'm.in'))
68 Execute(Copy('nonexistent.out', 'nonexistent.in'))
71 test.write('a.in', "a.in\n")
72 test.write('b.in', "b.in\n")
73 test.write('c.in', "c.in\n")
74 test.write('d.in', "d.in\n")
75 test.write('e.in', "e.in\n")
76 test.write('f.in', "f.in\n")
77 test.write('g.in', "g.in\n")
78 test.write('h.in', "h.in\n")
79 test.write('i.in', "i.in\n")
80 test.write('j.in', "j.in\n")
81 test.write('k.in', "k.in\n")
82 test.write('l.in', "l.in\n")
83 test.write('m.in', "m.in\n")
86 if sys.platform == 'win32':
90 scons: *** nonexistent.in/*.*: The system cannot find the path specified
93 # TODO(1.5): the underlying shutil.copytree() call doesn't
94 # add the nonexistent file name to the exception it throws.
95 # This goes away soon, so just accomodate the difference.
96 if sys.version[:3] == '1.5':
100 scons: *** No such file or directory
106 scons: *** nonexistent.in: No such file or directory
109 test.run(arguments = '.', stderr=expect)
111 test.must_match('a.out', "a.in\n")
112 test.must_match('b.out', "b.in\n")
113 test.must_match('c.out', "c.in\n")
114 test.must_match('d.out', "d.in\n")
115 test.must_match('e.out', "e.in\n")
116 test.must_match('f.out', "f.in\n")
117 test.must_match('g.out', "g.in\n")
118 test.must_match('h.out', "h.in\n")
119 test.must_match('i.out', "i.in\n")
120 test.must_match('j.out', "j.in\n")
121 test.must_match('k.out', "k.in\n")
122 test.must_match('l.out', "l.in\n")
123 test.must_match('m.out', "m.in\n")
129 # indent-tabs-mode:nil
131 # vim: set expandtab tabstop=4 shiftwidth=4: