5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 __revision__
= "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
28 Test that we can generate Visual Studio 10.0 project (.vcxproj) and
29 solution (.sln) files that contain SCC information and look correct.
36 for vc_version
in TestSConsMSVS
.get_tested_proj_file_vc_versions():
37 test
= TestSConsMSVS
.TestSConsMSVS()
38 host_arch
= test
.get_vs_host_arch()
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_file
= 'Test.vcproj' if major
<= 9 else 'Test.vcxproj'
46 filters_file
= project_file
+ '.filters'
47 filters_file_expected
= major
>= 10
48 expected_slnfile
= test
.get_expected_sln_file_contents(vc_version
, project_file
)
49 expected_vcprojfile
= test
.get_expected_proj_file_contents(vc_version
, dirs
, project_file
)
50 SConscript_contents
= """\
51 env=Environment(tools=['msvs'],
52 MSVS_VERSION='{vc_version}',
53 CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')],
54 CPPPATH=['inc1', 'inc2'],
55 MSVS_SCC_CONNECTION_ROOT='.',
56 MSVS_SCC_PROVIDER='MSSCCI:Perforce SCM',
57 MSVS_SCC_PROJECT_NAME='Perforce Project',
58 HOST_ARCH='{host_arch}')
60 testsrc = ['test1.cpp', 'test2.cpp']
61 testincs = [r'sdk_dir\\sdk.h']
62 testlocalincs = ['test.h']
63 testresources = ['test.rc']
64 testmisc = ['readme.txt']
66 env.MSVSProject(target = '{project_file}',
67 MSVS_PROJECT_GUID='{project_guid}',
70 localincs = testlocalincs,
71 resources = testresources,
73 buildtarget = 'Test.exe',
76 vc_version
=vc_version
, project_file
=project_file
,
77 host_arch
=host_arch
, project_guid
=TestSConsMSVS
.PROJECT_GUID
,
80 expected_sln_sccinfo
= """\
81 \tGlobalSection(SourceCodeControl) = preSolution
82 \t\tSccNumberOfProjects = 2
83 \t\tSccProjectName0 = Perforce\\u0020Project
85 \t\tSccProvider0 = MSSCCI:Perforce\\u0020SCM
86 \t\tCanCheckoutShared = true
87 \t\tSccProjectUniqueName1 = {project_file}
89 \t\tCanCheckoutShared = true
90 \t\tSccProjectFilePathRelativizedFromConnection1 = .\\\\
92 """.format(project_file
=project_file
)
95 # VC8 and VC9 used key-value pair format.
96 expected_vcproj_sccinfo
= """\
97 \tSccProjectName="Perforce Project"
99 \tSccProvider="MSSCCI:Perforce SCM"
102 # VC10 and later use XML format.
103 expected_vcproj_sccinfo
= """\
104 \t\t<SccProjectName>Perforce Project</SccProjectName>
105 \t\t<SccLocalPath>.</SccLocalPath>
106 \t\t<SccProvider>MSSCCI:Perforce SCM</SccProvider>
109 test
.write('SConstruct', SConscript_contents
)
111 test
.run(arguments
=project_file
)
113 test
.must_exist(test
.workpath(project_file
))
114 vcproj
= test
.read(project_file
, 'r')
115 expect
= test
.msvs_substitute(expected_vcprojfile
, vc_version
, None, 'SConstruct',
116 vcproj_sccinfo
=expected_vcproj_sccinfo
)
117 # don't compare the pickled data
118 assert vcproj
[:len(expect
)] == expect
, test
.diff_substr(expect
, vcproj
)
120 test
.must_exist(test
.workpath('Test.sln'))
121 sln
= test
.read('Test.sln', 'r')
122 expect
= test
.msvs_substitute(expected_slnfile
, vc_version
, None, 'SConstruct',
123 sln_sccinfo
=expected_sln_sccinfo
)
124 # don't compare the pickled data
125 assert sln
[:len(expect
)] == expect
, test
.diff_substr(expect
, sln
)
132 # indent-tabs-mode:nil
134 # vim: set expandtab tabstop=4 shiftwidth=4: