[ci skip] update generated files
[scons.git] / test / MSVS / vs-mult-auto-vardir.py
blobb4d21093125f2d4a5a697fa66b9e19d3c5a027f0
1 #!/usr/bin/env python
3 # MIT License
5 # Copyright The SCons Foundation
7 # Permission is hereby granted, free of charge, to any person obtaining
8 # a copy of this software and associated documentation files (the
9 # "Software"), to deal in the Software without restriction, including
10 # without limitation the rights to use, copy, modify, merge, publish,
11 # distribute, sublicense, and/or sell copies of the Software, and to
12 # permit persons to whom the Software is furnished to do so, subject to
13 # the following conditions:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
19 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 """
27 Test two project files (.vcxproj) and three solution (.sln) file.
28 """
30 import TestSConsMSVS
32 project_guid_1 = TestSConsMSVS.PROJECT_GUID_1
33 project_guid_2 = TestSConsMSVS.PROJECT_GUID_2
35 test = None
37 for vc_version in TestSConsMSVS.get_tested_proj_file_vc_versions():
39 for autofilter_projects in (None, False, True):
41 test = TestSConsMSVS.TestSConsMSVS()
43 # Make the test infrastructure think we have this version of MSVS installed.
44 test._msvs_versions = [vc_version]
46 dirs = ['inc1', 'inc2']
47 major, minor = test.parse_vc_version(vc_version)
48 project_ext = '.vcproj' if major <= 9 else '.vcxproj'
50 project_file_1 = 'Test_1' + project_ext
51 project_file_2 = 'Test_2' + project_ext
53 filters_file_1 = project_file_1 + '.filters'
54 filters_file_2 = project_file_2 + '.filters'
55 filters_file_expected = major >= 10
57 solution_file = 'Test.sln'
58 solution_file_1 = 'Test_1.sln'
59 solution_file_2 = 'Test_2.sln'
61 if major >= 10:
62 solution_guid_1 = "{5E5E4F5D-3E6A-5958-81C6-D4B8B8C633FA}"
63 solution_guid_2 = "{ECBCA12A-191D-54EC-BA78-F14249171130}"
64 else:
65 solution_guid_1 = "{5E5E4F5D-3E6A-5958-81C6-D4B8B8C633FA}"
66 solution_guid_2 = "{ECBCA12A-191D-54EC-BA78-F14249171130}"
68 expected_vcprojfile_1 = test.get_expected_projects_proj_file_contents(
69 vc_version, dirs, project_file_1, project_guid_1,
72 expected_vcprojfile_2 = test.get_expected_projects_proj_file_contents(
73 vc_version, dirs, project_file_2, project_guid_2,
76 expected_slnfile = test.get_expected_projects_sln_file_contents(
77 vc_version,
78 project_file_1,
79 project_file_2,
80 have_solution_project_nodes=True,
81 autofilter_solution_project_nodes=autofilter_projects,
84 expected_slnfile_1 = test.get_expected_sln_file_contents(
85 vc_version,
86 project_file_1,
89 expected_slnfile_2 = test.get_expected_sln_file_contents(
90 vc_version,
91 project_file_2,
94 SConscript_contents = test.get_expected_projects_sconscript_file_contents(
95 vc_version=vc_version,
96 project_file_1=project_file_1,
97 project_file_2=project_file_2,
98 solution_file=solution_file,
99 autobuild_solution=1,
100 autofilter_projects=autofilter_projects,
103 test.subdir('src')
105 test.write('SConstruct', """\
106 SConscript('src/SConscript', variant_dir='build')
107 """)
109 test.write(['src', 'SConscript'], SConscript_contents)
111 if autofilter_projects is None:
112 test.run(arguments=".", status=2, stderr=r"^.*scons: [*]{3} An msvs solution file was detected in the MSVSSolution 'projects' argument:.+", match=test.match_re_dotall)
113 continue
115 test.run(arguments=".")
117 test.must_exist(test.workpath('src', project_file_1))
118 vcproj = test.read(['src', project_file_1], 'r')
119 expect = test.msvs_substitute(expected_vcprojfile_1, vc_version, None, 'SConstruct', project_guid=project_guid_1)
120 # don't compare the pickled data
121 assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj)
123 test.must_exist(test.workpath('src', project_file_2))
124 vcproj = test.read(['src', project_file_2], 'r')
125 expect = test.msvs_substitute(expected_vcprojfile_2, vc_version, None, 'SConstruct', project_guid=project_guid_2)
126 # don't compare the pickled data
127 assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj)
129 test.must_exist(test.workpath('src', solution_file))
130 sln = test.read(['src', solution_file], 'r')
131 expect = test.msvs_substitute_projects(
132 expected_slnfile, subdir='src',
133 solution_guid_1=solution_guid_1, solution_guid_2=solution_guid_2,
135 # don't compare the pickled data
136 assert sln[:len(expect)] == expect, test.diff_substr(expect, sln)
138 test.must_exist(test.workpath('src', solution_file_1))
139 sln = test.read(['src', solution_file_1], 'r')
140 expect = test.msvs_substitute(expected_slnfile_1, vc_version, subdir='src', project_guid=project_guid_1)
141 # don't compare the pickled data
142 assert sln[:len(expect)] == expect, test.diff_substr(expect, sln)
144 test.must_exist(test.workpath('src', solution_file_2))
145 sln = test.read(['src', solution_file_2], 'r')
146 expect = test.msvs_substitute(expected_slnfile_2, vc_version, subdir='src', project_guid=project_guid_2)
147 # don't compare the pickled data
148 assert sln[:len(expect)] == expect, test.diff_substr(expect, sln)
150 if filters_file_expected:
151 test.must_exist(test.workpath('src', filters_file_1))
152 test.must_exist(test.workpath('src', filters_file_2))
153 else:
154 test.must_not_exist(test.workpath('src', filters_file_1))
155 test.must_not_exist(test.workpath('src', filters_file_2))
157 test.must_match(['build', project_file_1], """\
158 This is just a placeholder file.
159 The real project file is here:
161 """ % test.workpath('src', project_file_1), mode='r')
163 test.must_match(['build', project_file_2], """\
164 This is just a placeholder file.
165 The real project file is here:
167 """ % test.workpath('src', project_file_2), mode='r')
169 test.must_match(['build', solution_file], """\
170 This is just a placeholder file.
171 The real workspace file is here:
173 """ % test.workpath('src', solution_file), mode='r')
175 test.must_match(['build', solution_file_1], """\
176 This is just a placeholder file.
177 The real workspace file is here:
179 """ % test.workpath('src', solution_file_1), mode='r')
181 test.must_match(['build', solution_file_2], """\
182 This is just a placeholder file.
183 The real workspace file is here:
185 """ % test.workpath('src', solution_file_2), mode='r')
187 # TODO: clean tests
189 if test:
190 test.pass_test()
192 # Local Variables:
193 # tab-width:4
194 # indent-tabs-mode:nil
195 # End:
196 # vim: set expandtab tabstop=4 shiftwidth=4: