b2a310df254e0b36168f326e1a9883fa1f68f078
[scons.git] / test / MSVS / vs-8.0-x64-files.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 8.0 project (.vcproj) and
29 solution (.sln) files that look correct.
30 """
31
32 import os
33 import string
34
35 import TestSConsMSVS
36
37 test = TestSConsMSVS.TestSConsMSVS()
38
39 # Make the test infrastructure think we have this version of MSVS installed.
40 test._msvs_versions = ['8.0']
41
42
43
44 expected_slnfile = TestSConsMSVS.expected_slnfile_8_0
45 expected_vcprojfile = TestSConsMSVS.expected_vcprojfile_8_0
46 SConscript_contents = TestSConsMSVS.SConscript_contents_8_0
47
48 # We didn't create an API for putting parameters like this into
49 # the common generated and expected files.  Until we do, just patch
50 # in the values.
51 expected_slnfile = string.replace(expected_slnfile, 'Win32', 'x64')
52 expected_vcprojfile = string.replace(expected_vcprojfile, 'Win32', 'x64')
53 SConscript_contents = string.replace(SConscript_contents, '\'Release\'', '\'Release|x64\'')
54
55
56
57 test.write('SConstruct', SConscript_contents)
58
59 test.run(arguments="Test.vcproj")
60
61 test.must_exist(test.workpath('Test.vcproj'))
62 vcproj = test.read('Test.vcproj', 'r')
63 expect = test.msvs_substitute(expected_vcprojfile, '8.0', None, 'SConstruct')
64 # don't compare the pickled data
65 assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj)
66
67 test.must_exist(test.workpath('Test.sln'))
68 sln = test.read('Test.sln', 'r')
69 expect = test.msvs_substitute(expected_slnfile, '8.0', None, 'SConstruct')
70 # don't compare the pickled data
71 assert sln[:len(expect)] == expect, test.diff_substr(expect, sln)
72
73 test.run(arguments='-c .')
74
75 test.must_not_exist(test.workpath('Test.vcproj'))
76 test.must_not_exist(test.workpath('Test.sln'))
77
78 test.run(arguments='Test.vcproj')
79
80 test.must_exist(test.workpath('Test.vcproj'))
81 test.must_exist(test.workpath('Test.sln'))
82
83 test.run(arguments='-c Test.sln')
84
85 test.must_not_exist(test.workpath('Test.vcproj'))
86 test.must_not_exist(test.workpath('Test.sln'))
87
88
89
90 # Test that running SCons with $PYTHON_ROOT in the environment
91 # changes the .vcproj output as expected.
92 os.environ['PYTHON_ROOT'] = 'xyzzy'
93 python = os.path.join('$(PYTHON_ROOT)', os.path.split(TestSConsMSVS.python)[1])
94
95 test.run(arguments='Test.vcproj')
96
97 test.must_exist(test.workpath('Test.vcproj'))
98 vcproj = test.read('Test.vcproj', 'r')
99 expect = test.msvs_substitute(expected_vcprojfile, '8.0', None, 'SConstruct',
100                               python=python)
101 # don't compare the pickled data
102 assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj)
103
104
105
106 test.pass_test()
107
108 # Local Variables:
109 # tab-width:4
110 # indent-tabs-mode:nil
111 # End:
112 # vim: set expandtab tabstop=4 shiftwidth=4: