Merge pull request #4655 from bdbaddog/fix_new_ninja_package
[scons.git] / test / D / di / Common / common.py
blob6ca40f91c990ae86362d85a5a8020b3f5fd19987
1 # MIT License
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.
24 """
25 Test D compilers use of .di files
26 """
28 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
30 import TestSCons
32 from os.path import abspath, dirname
34 import sys
35 sys.path.insert(1, abspath(dirname(__file__) + '/../../Support'))
37 from executablesSearch import isExecutableOfToolAvailable
39 def testForTool(tool):
41 test = TestSCons.TestSCons()
43 if not isExecutableOfToolAvailable(test, tool) :
44 test.skip_test("Required executable for tool '{0}' not found, skipping test.\n".format(tool))
46 test.dir_fixture('Image')
47 with open('SConstruct_template', 'r') as f:
48 config = f.read().format(tool)
49 test.write('SConstruct', config)
51 test.run(options="--debug=explain")
53 test.must_exist('source/helloWorld.o')
54 test.must_exist('helloWorldMain.o')
55 test.must_exist('include/helloWorld.di')
56 test.must_exist('hw')
58 test.run(program=test.workpath('hw'+TestSCons._exe))
59 test.fail_test(test.stdout() != 'Hello World.\n')
61 #add a comment and test that this doesn't result in a complete rebuild of all the files that include helloWorld.d because the comment doesn't change helloWorld.di
62 test.write("source/helloWorld.d",'''import std.stdio;
63 void go()
65 //comment
66 writeln("Hello World.");
67 }''')
69 test.not_up_to_date("source/helloWorld.o")
70 test.up_to_date("helloWorldMain.o hw")
72 test.run("-c")
74 test.must_not_exist('source/helloWorld.o')
75 test.must_not_exist('helloWorldMain.o')
76 test.must_not_exist('include/helloWorld.di')
77 test.must_not_exist('hw')
79 test.pass_test()
80 # Local Variables:
81 # tab-width:4
82 # indent-tabs-mode:nil
83 # End:
84 # vim: set expandtab tabstop=4 shiftwidth=4: