5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 Test the Execute() function for executing actions directly.
31 from TestCmd
import IS_WINDOWS
33 _python_
= TestSCons
._python
_
35 test
= TestSCons
.TestSCons()
37 test
.write('my_copy.py', """\
39 with open(sys.argv[2], 'wb') as ofp, open(sys.argv[1], 'rb') as ifp:
42 exitval = int(sys.argv[3])
48 test
.write('SConstruct', """\
49 Execute(r'%(_python_)s my_copy.py a.in a.out')
50 Execute(Action(r'%(_python_)s my_copy.py b.in b.out'))
51 env = Environment(COPY = 'my_copy.py')
52 env.Execute(r'%(_python_)s my_copy.py c.in c.out')
53 env.Execute(Action(r'%(_python_)s my_copy.py d.in d.out'))
54 v = env.Execute(r'%(_python_)s $COPY e.in e.out')
56 v = env.Execute(Action(r'%(_python_)s $COPY f.in f.out'))
58 v = env.Execute(r'%(_python_)s $COPY g.in g.out 1')
60 v = env.Execute(Action(r'%(_python_)s $COPY h.in h.out 2'))
63 Execute(lambda target, source, env: shutil.copy('i.in', 'i.out'))
64 Execute(Action(lambda target, source, env: shutil.copy('j.in', 'j.out')))
65 env.Execute(lambda target, source, env: shutil.copy('k.in', 'k.out'))
66 env.Execute(Action(lambda target, source, env: shutil.copy('l.in', 'l.out')))
68 Execute(Copy('m.out', 'm.in'))
69 Execute(Copy('nonexistent.out', 'nonexistent.in'))
72 test
.write('a.in', "a.in\n")
73 test
.write('b.in', "b.in\n")
74 test
.write('c.in', "c.in\n")
75 test
.write('d.in', "d.in\n")
76 test
.write('e.in', "e.in\n")
77 test
.write('f.in', "f.in\n")
78 test
.write('g.in', "g.in\n")
79 test
.write('h.in', "h.in\n")
80 test
.write('i.in', "i.in\n")
81 test
.write('j.in', "j.in\n")
82 test
.write('k.in', "k.in\n")
83 test
.write('l.in', "l.in\n")
84 test
.write('m.in', "m.in\n")
87 expect
= r
"""scons: \*\*\* Error 1
89 scons: \*\*\* nonexistent.in: (The system cannot find the path specified|Das System kann den angegebenen Pfad nicht finden)"""
92 expect
= r
"""scons: \*\*\* Error 1
94 scons: \*\*\* nonexistent\.in: No such file or directory"""
96 test
.run(arguments
= '.', stdout
= None, stderr
= None)
98 test
.must_contain_all_lines(test
.stderr(), expect
.splitlines(), find
=TestSCons
.search_re
)
100 test
.must_match('a.out', "a.in\n")
101 test
.must_match('b.out', "b.in\n")
102 test
.must_match('c.out', "c.in\n")
103 test
.must_match('d.out', "d.in\n")
104 test
.must_match('e.out', "e.in\n")
105 test
.must_match('f.out', "f.in\n")
106 test
.must_match('g.out', "g.in\n")
107 test
.must_match('h.out', "h.in\n")
108 test
.must_match('i.out', "i.in\n")
109 test
.must_match('j.out', "j.in\n")
110 test
.must_match('k.out', "k.in\n")
111 test
.must_match('l.out', "l.in\n")
112 test
.must_match('m.out', "m.in\n")
118 # indent-tabs-mode:nil
120 # vim: set expandtab tabstop=4 shiftwidth=4: