3 # Copyright The SCons Foundation
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.
30 from TestCmd
import IS_WINDOWS
32 test
= TestSCons
.TestSCons()
37 test
.skip_test("Could not find module in python")
39 _python_
= TestSCons
._python
_
42 ninja_bin
= os
.path
.abspath(os
.path
.join(
46 test
.dir_fixture('ninja-fixture')
48 test
.file_fixture('ninja_test_sconscripts/sconstruct_ninja_determinism', 'SConstruct')
50 # generate simple build
52 test
.must_contain_all_lines(test
.stdout(), ['Generating: build.ninja'])
53 test
.must_contain_all(test
.stdout(), 'Executing:')
54 test
.must_contain_all(test
.stdout(), 'ninja%(_exe)s -f' % locals())
55 test
.must_exist([test
.workpath('out1.txt'), test
.workpath('out2.txt')])
56 shutil
.copyfile(test
.workpath('build.ninja'), test
.workpath('build.ninja.orig'))
58 ninja_file_mtime
= os
.path
.getmtime(test
.workpath('build.ninja'))
60 # generate same build again
62 test
.must_contain_all_lines(test
.stdout(), ['Generating: build.ninja', 'ninja: no work to do.'])
63 test
.must_contain_all(test
.stdout(), 'Executing:')
64 test
.must_contain_all(test
.stdout(), 'ninja%(_exe)s -f' % locals())
65 test
.must_exist([test
.workpath('out1.txt'), test
.workpath('out2.txt')])
67 if os
.path
.getmtime(test
.workpath('build.ninja')) != ninja_file_mtime
:
68 test
.fail_test(message
="build.ninja file has been updated (mtime changed) and should not have been")
70 # make sure the ninja file was deterministic
71 if not filecmp
.cmp(test
.workpath('build.ninja'), test
.workpath('build.ninja.orig')):
74 # clean build and ninja files
75 os
.unlink(test
.workpath('build.ninja.orig'))
76 test
.run(arguments
='-c', stdout
=None)
78 # only generate the ninja file
79 test
.run(arguments
='--disable-execute-ninja', stdout
=None)
80 test
.must_contain_all_lines(test
.stdout(), ['Generating: build.ninja'])
81 test
.must_not_exist([test
.workpath('out1.txt'), test
.workpath('out2.txt')])
83 # run ninja independently
84 program
= test
.workpath('run_ninja_env.bat') if IS_WINDOWS
else ninja_bin
85 test
.run(program
=program
, stdout
=None)
86 test
.must_exist([test
.workpath('out1.txt'), test
.workpath('out2.txt')])
87 shutil
.copyfile(test
.workpath('build.ninja'), test
.workpath('build.ninja.orig'))
89 # only generate the ninja file again
90 test
.run(arguments
='--disable-execute-ninja', stdout
=None)
91 test
.must_contain_all_lines(test
.stdout(), ['Generating: build.ninja'])
92 test
.must_exist([test
.workpath('out1.txt'), test
.workpath('out2.txt')])
94 # run ninja independently again
95 program
= test
.workpath('run_ninja_env.bat') if IS_WINDOWS
else ninja_bin
96 test
.run(program
=program
, stdout
=None)
97 test
.must_contain_all_lines(test
.stdout(), ['ninja: no work to do.'])
98 test
.must_exist([test
.workpath('out1.txt'), test
.workpath('out2.txt')])
100 # make sure the ninja file was deterministic
101 if not filecmp
.cmp(test
.workpath('build.ninja'), test
.workpath('build.ninja.orig')):
108 # indent-tabs-mode:nil
110 # vim: set expandtab tabstop=4 shiftwidth=4: