Issue 2505: fix use of pre-compiled headers when the source .cpp
[scons.git] / test / MSVS / vs-7.0-variant_dir.py
1 #!/usr/bin/env python
2 #
3 # __COPYRIGHT__
4 #
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:
12 #
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
15 #
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.
23 #
24
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26
27 """
28 Test that we can generate Visual Studio 7.0 project (.vcproj) and
29 solution (.sln) files that look correct when using a variant_dir.
30 """
31
32 import TestSConsMSVS
33
34 test = TestSConsMSVS.TestSConsMSVS()
35
36 # Make the test infrastructure think we have this version of MSVS installed.
37 test._msvs_versions = ['7.0']
38
39
40
41 expected_slnfile = TestSConsMSVS.expected_slnfile_7_0
42 expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_7_0
43 SConscript_contents = TestSConsMSVS.SConscript_contents_7_0
44
45
46
47 test.subdir('src')
48
49 test.write('SConstruct', """\
50 SConscript('src/SConscript', variant_dir='build')
51 """)
52
53 test.write(['src', 'SConscript'], SConscript_contents)
54
55 test.run(arguments=".")
56
57 vcproj = test.read(['src', 'Test.vcproj'], 'r')
58 expect = test.msvs_substitute(expected_vcprojfile, '7.0', None, 'SConstruct')
59 # don't compare the pickled data
60 assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj)
61
62 test.must_exist(test.workpath('src', 'Test.sln'))
63 sln = test.read(['src', 'Test.sln'], 'r')
64 expect = test.msvs_substitute(expected_slnfile, '7.0', 'src')
65 # don't compare the pickled data
66 assert sln[:len(expect)] == expect, test.diff_substr(expect, sln)
67
68 test.must_match(['build', 'Test.vcproj'], """\
69 This is just a placeholder file.
70 The real project file is here:
71 %s
72 """ % test.workpath('src', 'Test.vcproj'),
73                 mode='r')
74
75 test.must_match(['build', 'Test.sln'], """\
76 This is just a placeholder file.
77 The real workspace file is here:
78 %s
79 """ % test.workpath('src', 'Test.sln'),
80                 mode='r')
81
82
83
84 test.pass_test()
85
86 # Local Variables:
87 # tab-width:4
88 # indent-tabs-mode:nil
89 # End:
90 # vim: set expandtab tabstop=4 shiftwidth=4: