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 Verify that targets with the same SideEffect are not built in parallel
29 when the -j option is used.
34 _python_
= TestSCons
._python
_
36 test
= TestSCons
.TestSCons()
38 test
.write('build.py', """
43 lockdir = 'build.lock'
49 msg = 'could not create lock directory: %s\\n' % e
53 src, target = sys.argv[1:]
55 with open(logfile, 'ab') as f:
56 f.write(('%s -> %s\\n' % (src, target)).encode())
57 with open(target, 'wb') as ofp, open(src, 'rb') as ifp:
60 # Give the other threads a chance to start.
66 test
.write('SConstruct', """\
67 Build = Builder(action=r'%(_python_)s build.py $SOURCE $TARGET')
68 env = Environment(BUILDERS={'Build':Build})
69 env.Build('h1.out', 'h1.in')
70 env.Build('g2.out', 'g2.in')
71 env.Build('f3.out', 'f3.in')
72 SideEffect('log.txt', ['h1.out', 'g2.out', 'f3.out'])
73 env.Build('log.out', 'log.txt')
76 test
.write('h1.in', 'h1.in\n')
77 test
.write('g2.in', 'g2.in\n')
78 test
.write('f3.in', 'f3.in\n')
79 test
.write('baz.in', 'baz.in\n')
82 test
.run(arguments
= "-j 4 .")
84 test
.must_match('h1.out', 'h1.in\n')
85 test
.must_match('g2.out', 'g2.in\n')
86 test
.must_match('f3.out', 'f3.in\n')
87 test
.must_exist('log.txt')
88 test
.must_exist('log.out')
90 stdout
= test
.stdout()
94 'build.py h1.in h1.out',
95 'build.py g2.in g2.out',
96 'build.py f3.in f3.out',
100 for line
in build_lines
:
101 if stdout
.find(line
) == -1:
105 print("===== standard output is missing the following lines:")
106 print('\n'.join(missing
))
107 print("===== STDOUT ========================================")
112 log
= test
.read('log.txt', mode
='r')
121 for line
in log_lines
:
122 if log
.find(line
) == -1:
126 print("===== log file 'log.txt' is missing the following lines:")
127 print('\n'.join(missing
))
128 print("===== STDOUT ===========================================")
136 # indent-tabs-mode:nil
138 # vim: set expandtab tabstop=4 shiftwidth=4: