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.
32 project_guid_1
= TestSConsMSVS
.PROJECT_GUID_1
33 project_guid_2
= TestSConsMSVS
.PROJECT_GUID_2
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'
62 solution_guid_1
= "{73ABD7C4-0A64-5192-97C3-252B70C8D1B1}"
63 solution_guid_2
= "{142F0D4F-9896-5808-AAB4-A80F5661B1FE}"
65 solution_guid_1
= "{73ABD7C4-0A64-5192-97C3-252B70C8D1B1}"
66 solution_guid_2
= "{142F0D4F-9896-5808-AAB4-A80F5661B1FE}"
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(
80 have_solution_project_nodes
=True,
81 autofilter_solution_project_nodes
=autofilter_projects
,
84 expected_slnfile_1
= test
.get_expected_sln_file_contents(
89 expected_slnfile_2
= test
.get_expected_sln_file_contents(
94 SConstruct_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
,
100 autofilter_projects
=autofilter_projects
,
103 test
.write('SConstruct', SConstruct_contents
)
105 if autofilter_projects
is None:
106 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
)
109 test
.run(arguments
=".")
111 test
.must_exist(test
.workpath(project_file_1
))
112 vcproj
= test
.read(project_file_1
, 'r')
113 expect
= test
.msvs_substitute(expected_vcprojfile_1
, vc_version
, None, 'SConstruct', project_guid
=project_guid_1
)
114 # don't compare the pickled data
115 assert vcproj
[:len(expect
)] == expect
, test
.diff_substr(expect
, vcproj
)
117 test
.must_exist(test
.workpath(project_file_2
))
118 vcproj
= test
.read(project_file_2
, 'r')
119 expect
= test
.msvs_substitute(expected_vcprojfile_2
, vc_version
, None, 'SConstruct', project_guid
=project_guid_2
)
120 # don't compare the pickled data
121 assert vcproj
[:len(expect
)] == expect
, test
.diff_substr(expect
, vcproj
)
123 test
.must_exist(test
.workpath(solution_file
))
124 sln
= test
.read(solution_file
, 'r')
125 expect
= test
.msvs_substitute_projects(
126 expected_slnfile
, subdir
='src',
127 solution_guid_1
=solution_guid_1
, solution_guid_2
=solution_guid_2
,
129 # don't compare the pickled data
130 assert sln
[:len(expect
)] == expect
, test
.diff_substr(expect
, sln
)
132 test
.must_exist(test
.workpath(solution_file_1
))
133 sln
= test
.read(solution_file_1
, 'r')
134 expect
= test
.msvs_substitute(expected_slnfile_1
, vc_version
, subdir
='src', project_guid
=project_guid_1
)
135 # don't compare the pickled data
136 assert sln
[:len(expect
)] == expect
, test
.diff_substr(expect
, sln
)
138 test
.must_exist(test
.workpath(solution_file_2
))
139 sln
= test
.read(solution_file_2
, 'r')
140 expect
= test
.msvs_substitute(expected_slnfile_2
, vc_version
, subdir
='src', project_guid
=project_guid_2
)
141 # don't compare the pickled data
142 assert sln
[:len(expect
)] == expect
, test
.diff_substr(expect
, sln
)
144 if filters_file_expected
:
145 test
.must_exist(test
.workpath(filters_file_1
))
146 test
.must_exist(test
.workpath(filters_file_2
))
148 test
.must_not_exist(test
.workpath(filters_file_1
))
149 test
.must_not_exist(test
.workpath(filters_file_2
))
158 # indent-tabs-mode:nil
160 # vim: set expandtab tabstop=4 shiftwidth=4: