Merge pull request #4674 from bdbaddog/fix_2281_Aliases_ignore_pre_post_add_actions
[scons.git] / test / MSVS / vs-mult-auto-guid.py
blob412c379ab78b82540ad92557ff6aa38f31267fa7
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 test = None
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'
58 if major >= 10:
59 project_guid_1 = "{F7D7CE55-37BF-51DE-8942-9377B2BE8387}"
60 project_guid_2 = "{8D17BC73-09FD-5B69-BBBF-1E40E0C63456}"
61 else:
62 project_guid_1 = "{53EE9FA7-6300-55B8-8A0E-A3DC40983390}"
63 project_guid_2 = "{57358E9B-126D-53F6-AD5A-559AB4A8EE62}"
65 if major >= 10:
66 solution_guid_1 = "{73ABD7C4-0A64-5192-97C3-252B70C8D1B1}"
67 solution_guid_2 = "{142F0D4F-9896-5808-AAB4-A80F5661B1FE}"
68 else:
69 solution_guid_1 = "{73ABD7C4-0A64-5192-97C3-252B70C8D1B1}"
70 solution_guid_2 = "{142F0D4F-9896-5808-AAB4-A80F5661B1FE}"
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(
81 vc_version,
82 project_file_1,
83 project_file_2,
84 have_solution_project_nodes=True,
85 autofilter_solution_project_nodes=autofilter_projects,
88 expected_slnfile_1 = test.get_expected_sln_file_contents(
89 vc_version,
90 project_file_1,
93 expected_slnfile_2 = test.get_expected_sln_file_contents(
94 vc_version,
95 project_file_2,
98 SConstruct_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,
105 default_guids=True,
108 test.write('SConstruct', SConstruct_contents)
110 if autofilter_projects is None:
111 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)
112 continue
114 test.run(arguments=".")
116 test.must_exist(test.workpath(project_file_1))
117 vcproj = test.read(project_file_1, 'r')
118 expect = test.msvs_substitute(expected_vcprojfile_1, vc_version, None, 'SConstruct', project_guid=project_guid_1)
119 # don't compare the pickled data
120 assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj)
122 test.must_exist(test.workpath(project_file_2))
123 vcproj = test.read(project_file_2, 'r')
124 expect = test.msvs_substitute(expected_vcprojfile_2, vc_version, None, 'SConstruct', project_guid=project_guid_2)
125 # don't compare the pickled data
126 assert vcproj[:len(expect)] == expect, test.diff_substr(expect, vcproj)
128 test.must_exist(test.workpath(solution_file))
129 sln = test.read(solution_file, 'r')
130 expect = test.msvs_substitute_projects(
131 expected_slnfile, subdir='src',
132 project_guid_1=project_guid_1, project_guid_2=project_guid_2,
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(solution_file_1))
139 sln = test.read(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(solution_file_2))
145 sln = test.read(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(filters_file_1))
152 test.must_exist(test.workpath(filters_file_2))
153 else:
154 test.must_not_exist(test.workpath(filters_file_1))
155 test.must_not_exist(test.workpath(filters_file_2))
157 # TODO: clean tests
159 if test:
160 test.pass_test()
162 # Local Variables:
163 # tab-width:4
164 # indent-tabs-mode:nil
165 # End:
166 # vim: set expandtab tabstop=4 shiftwidth=4: