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.
27 Test two project files (.vcxproj) and three solution (.sln) file.
34 for vc_version
in TestSConsMSVS
.get_tested_proj_file_vc_versions():
36 for autofilter_projects
in (None, False, True):
38 test
= TestSConsMSVS
.TestSConsMSVS()
40 # Make the test infrastructure think we have this version of MSVS installed.
41 test
._msvs
_versions
= [vc_version
]
43 dirs
= ['inc1', 'inc2']
44 major
, minor
= test
.parse_vc_version(vc_version
)
45 project_ext
= '.vcproj' if major
<= 9 else '.vcxproj'
47 project_file_1
= 'Test_1' + project_ext
48 project_file_2
= 'Test_2' + project_ext
50 filters_file_1
= project_file_1
+ '.filters'
51 filters_file_2
= project_file_2
+ '.filters'
52 filters_file_expected
= major
>= 10
54 solution_file
= 'Test.sln'
55 solution_file_1
= 'Test_1.sln'
56 solution_file_2
= 'Test_2.sln'
59 project_guid_1
= "{5A243E49-07F0-54C3-B3FD-1DBDF1BA5C9E}"
60 project_guid_2
= "{E20E17C7-251E-5246-8FD1-5D51978A0A5D}"
62 project_guid_1
= "{AB46DD68-8CD8-5832-B784-65B216B94739}"
63 project_guid_2
= "{03EB0BC3-DA68-5825-9EBB-D8713304E739}"
66 solution_guid_1
= "{5E5E4F5D-3E6A-5958-81C6-D4B8B8C633FA}"
67 solution_guid_2
= "{ECBCA12A-191D-54EC-BA78-F14249171130}"
69 solution_guid_1
= "{5E5E4F5D-3E6A-5958-81C6-D4B8B8C633FA}"
70 solution_guid_2
= "{ECBCA12A-191D-54EC-BA78-F14249171130}"
72 expected_vcprojfile_1
= test
.get_expected_projects_proj_file_contents(
73 vc_version
, dirs
, project_file_1
, project_guid_1
,
76 expected_vcprojfile_2
= test
.get_expected_projects_proj_file_contents(
77 vc_version
, dirs
, project_file_2
, project_guid_2
,
80 expected_slnfile
= test
.get_expected_projects_sln_file_contents(
84 have_solution_project_nodes
=True,
85 autofilter_solution_project_nodes
=autofilter_projects
,
88 expected_slnfile_1
= test
.get_expected_sln_file_contents(
93 expected_slnfile_2
= test
.get_expected_sln_file_contents(
98 SConscript_contents
= test
.get_expected_projects_sconscript_file_contents(
99 vc_version
=vc_version
,
100 project_file_1
=project_file_1
,
101 project_file_2
=project_file_2
,
102 solution_file
=solution_file
,
103 autobuild_solution
=1,
104 autofilter_projects
=autofilter_projects
,
110 test
.write('SConstruct', """\
111 SConscript('src/SConscript', variant_dir='build')
114 test
.write(['src', 'SConscript'], SConscript_contents
)
116 if autofilter_projects
is None:
117 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
)
120 test
.run(arguments
=".")
122 test
.must_exist(test
.workpath('src', project_file_1
))
123 vcproj
= test
.read(['src', project_file_1
], 'r')
124 expect
= test
.msvs_substitute(expected_vcprojfile_1
, vc_version
, None, 'SConstruct', project_guid
=project_guid_1
)
125 # don't compare the pickled data
126 assert vcproj
[:len(expect
)] == expect
, test
.diff_substr(expect
, vcproj
)
128 test
.must_exist(test
.workpath('src', project_file_2
))
129 vcproj
= test
.read(['src', project_file_2
], 'r')
130 expect
= test
.msvs_substitute(expected_vcprojfile_2
, vc_version
, None, 'SConstruct', project_guid
=project_guid_2
)
131 # don't compare the pickled data
132 assert vcproj
[:len(expect
)] == expect
, test
.diff_substr(expect
, vcproj
)
134 test
.must_exist(test
.workpath('src', solution_file
))
135 sln
= test
.read(['src', solution_file
], 'r')
136 expect
= test
.msvs_substitute_projects(
137 expected_slnfile
, subdir
='src',
138 project_guid_1
=project_guid_1
, project_guid_2
=project_guid_2
,
139 solution_guid_1
=solution_guid_1
, solution_guid_2
=solution_guid_2
,
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_1
))
145 sln
= test
.read(['src', solution_file_1
], 'r')
146 expect
= test
.msvs_substitute(expected_slnfile_1
, vc_version
, subdir
='src', project_guid
=project_guid_1
)
147 # don't compare the pickled data
148 assert sln
[:len(expect
)] == expect
, test
.diff_substr(expect
, sln
)
150 test
.must_exist(test
.workpath('src', solution_file_2
))
151 sln
= test
.read(['src', solution_file_2
], 'r')
152 expect
= test
.msvs_substitute(expected_slnfile_2
, vc_version
, subdir
='src', project_guid
=project_guid_2
)
153 # don't compare the pickled data
154 assert sln
[:len(expect
)] == expect
, test
.diff_substr(expect
, sln
)
156 if filters_file_expected
:
157 test
.must_exist(test
.workpath('src', filters_file_1
))
158 test
.must_exist(test
.workpath('src', filters_file_2
))
160 test
.must_not_exist(test
.workpath('src', filters_file_1
))
161 test
.must_not_exist(test
.workpath('src', filters_file_2
))
163 test
.must_match(['build', project_file_1
], """\
164 This is just a placeholder file.
165 The real project file is here:
167 """ % test
.workpath('src', project_file_1
), mode
='r')
169 test
.must_match(['build', project_file_2
], """\
170 This is just a placeholder file.
171 The real project file is here:
173 """ % test
.workpath('src', project_file_2
), mode
='r')
175 test
.must_match(['build', solution_file
], """\
176 This is just a placeholder file.
177 The real workspace file is here:
179 """ % test
.workpath('src', solution_file
), mode
='r')
181 test
.must_match(['build', solution_file_1
], """\
182 This is just a placeholder file.
183 The real workspace file is here:
185 """ % test
.workpath('src', solution_file_1
), mode
='r')
187 test
.must_match(['build', solution_file_2
], """\
188 This is just a placeholder file.
189 The real workspace file is here:
191 """ % test
.workpath('src', solution_file_2
), mode
='r')
200 # indent-tabs-mode:nil
202 # vim: set expandtab tabstop=4 shiftwidth=4: