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 a 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():
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'
56 expected_vcprojfile_1
= test
.get_expected_projects_proj_file_contents(
57 vc_version
, dirs
, project_file_1
, project_guid_1
,
60 expected_vcprojfile_2
= test
.get_expected_projects_proj_file_contents(
61 vc_version
, dirs
, project_file_2
, project_guid_2
,
64 expected_slnfile
= test
.get_expected_projects_sln_file_contents(
70 SConscript_contents
= test
.get_expected_projects_sconscript_file_contents(
71 vc_version
=vc_version
,
72 project_file_1
=project_file_1
,
73 project_file_2
=project_file_2
,
74 solution_file
=solution_file
,
80 test
.write('SConstruct', """\
81 SConscript('src/SConscript', variant_dir='build')
84 test
.write(['src', 'SConscript'], SConscript_contents
)
86 test
.run(arguments
=".")
88 test
.must_exist(test
.workpath('src', project_file_1
))
89 vcproj
= test
.read(['src', project_file_1
], 'r')
90 expect
= test
.msvs_substitute(expected_vcprojfile_1
, vc_version
, None, 'SConstruct', project_guid
=project_guid_1
)
91 # don't compare the pickled data
92 assert vcproj
[:len(expect
)] == expect
, test
.diff_substr(expect
, vcproj
)
94 test
.must_exist(test
.workpath('src', project_file_2
))
95 vcproj
= test
.read(['src', project_file_2
], 'r')
96 expect
= test
.msvs_substitute(expected_vcprojfile_2
, vc_version
, None, 'SConstruct', project_guid
=project_guid_2
)
97 # don't compare the pickled data
98 assert vcproj
[:len(expect
)] == expect
, test
.diff_substr(expect
, vcproj
)
100 test
.must_exist(test
.workpath('src', solution_file
))
101 sln
= test
.read(['src', solution_file
], 'r')
102 expect
= test
.msvs_substitute_projects(expected_slnfile
, subdir
='src')
103 # don't compare the pickled data
104 assert sln
[:len(expect
)] == expect
, test
.diff_substr(expect
, sln
)
106 if filters_file_expected
:
107 test
.must_exist(test
.workpath('src', filters_file_1
))
108 test
.must_exist(test
.workpath('src', filters_file_2
))
110 test
.must_not_exist(test
.workpath('src', filters_file_1
))
111 test
.must_not_exist(test
.workpath('src', filters_file_2
))
113 test
.must_match(['build', project_file_1
], """\
114 This is just a placeholder file.
115 The real project file is here:
117 """ % test
.workpath('src', project_file_1
), mode
='r')
119 test
.must_match(['build', project_file_2
], """\
120 This is just a placeholder file.
121 The real project file is here:
123 """ % test
.workpath('src', project_file_2
), mode
='r')
125 test
.must_match(['build', solution_file
], """\
126 This is just a placeholder file.
127 The real workspace file is here:
129 """ % test
.workpath('src', solution_file
), mode
='r')
138 # indent-tabs-mode:nil
140 # vim: set expandtab tabstop=4 shiftwidth=4: