Followon to PR #4348: more bool fixes
[scons.git] / SCons / Tool / msvsTests.py
blobdd708d0a7eca9e26628c4ef085b6c8af59e2e506
1 # MIT License
3 # Copyright The SCons Foundation
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.
24 import os
25 import sys
26 import unittest
27 import copy
29 import TestCmd
30 import TestUnit
32 from SCons.Tool.msvs import *
33 from SCons.Tool.MSCommon.vs import SupportedVSList
34 import SCons.Node.FS
35 import SCons.Util
36 import SCons.Warnings
38 from SCons.Tool.MSCommon.common import debug
40 from SCons.Tool.MSCommon import get_default_version, \
41 query_versions
42 from SCons.Tool.msvs import _GenerateV6DSP, _GenerateV7DSP, _GenerateV10DSP
44 regdata_6a = r'''[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio]
45 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0]
46 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\ServicePacks]
47 "sp3"=""
48 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup]
49 "VsCommonDir"="C:\Program Files\Microsoft Visual Studio\Common"
50 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft Developer Network Library - Visual Studio 6.0a]
51 "ProductDir"="C:\Program Files\Microsoft Visual Studio\MSDN98\98VSa\1033"
52 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft Visual C++]
53 "ProductDir"="C:\Program Files\Microsoft Visual Studio\VC98"
54 '''.split('\n')
56 regdata_6b = r'''[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio]
57 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0]
58 "InstallDir"="C:\VS6\Common\IDE\IDE98"
59 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\ServicePacks]
60 "sp5"=""
61 "latest"=dword:00000005
62 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup]
63 "VsCommonDir"="C:\VS6\Common"
64 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft Visual Basic]
65 "ProductDir"="C:\VS6\VB98"
66 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft Visual C++]
67 "ProductDir"="C:\VS6\VC98"
68 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft Visual Studio]
69 "ProductDir"="C:\VS6"
70 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Microsoft VSEE Client]
71 "ProductDir"="C:\VS6\Common\Tools"
72 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0\Setup\Visual Studio 98]
73 '''.split('\n')
75 regdata_7 = r'''
76 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0]
77 "InstallDir"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\"
78 "Source Directories"="C:\Program Files\Microsoft Visual Studio .NET\Vc7\crt\;C:\Program Files\Microsoft Visual Studio .NET\Vc7\atlmfc\src\mfc\;C:\Program Files\Microsoft Visual Studio .NET\Vc7\atlmfc\src\atl\"
79 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\InstalledProducts]
80 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\InstalledProducts\CrystalReports]
81 @="#15007"
82 "Package"="{F05E92C6-8346-11D3-B4AD-00A0C9B04E7B}"
83 "ProductDetails"="#15009"
84 "LogoID"="0"
85 "PID"="#15008"
86 "UseInterface"=dword:00000001
87 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\InstalledProducts\Visual Basic.NET]
88 @=""
89 "DefaultProductAttribute"="VB"
90 "Package"="{164B10B9-B200-11D0-8C61-00A0C91E29D5}"
91 "UseInterface"=dword:00000001
92 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\InstalledProducts\Visual C#]
93 @=""
94 "Package"="{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}"
95 "UseInterface"=dword:00000001
96 "DefaultProductAttribute"="C#"
97 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\InstalledProducts\VisualC++]
98 "UseInterface"=dword:00000001
99 "Package"="{F1C25864-3097-11D2-A5C5-00C04F7968B4}"
100 "DefaultProductAttribute"="VC"
101 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup]
102 "Dbghelp_path"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\"
103 "dw_dir"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\"
104 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\MSDN]
105 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\Msdn\1033\"
106 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\Servicing\SKU]
107 "Visual Studio .NET Professional - English"="{D0610409-7D65-11D5-A54F-0090278A1BB8}"
108 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VB]
109 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\Vb7\"
110 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VC]
111 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\Vc7\"
112 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VC#]
113 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\VC#\"
114 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\Visual Studio .NET Professional - English]
115 "InstallSuccess"=dword:00000001
116 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VS]
117 "EnvironmentDirectory"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\"
118 "EnvironmentPath"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\devenv.exe"
119 "VS7EnvironmentLocation"="C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\devenv.exe"
120 "MSMDir"="C:\Program Files\Common Files\Merge Modules\"
121 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\"
122 "VS7CommonBinDir"="C:\Program Files\Microsoft Visual Studio .NET\Common7\Tools\"
123 "VS7CommonDir"="C:\Program Files\Microsoft Visual Studio .NET\Common7\"
124 "VSUpdateDir"="C:\Program Files\Microsoft Visual Studio .NET\Setup\VSUpdate\"
125 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VS\BuildNumber]
126 "1033"="7.0.9466"
127 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\Setup\VS\Pro]
128 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET\"
129 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\VC]
130 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\VC\VC_OBJECTS_PLATFORM_INFO]
131 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32]
132 @="{A54AAE91-30C2-11D3-87BF-A04A4CC10000}"
133 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories]
134 "Path Dirs"="$(VCInstallDir)bin;$(VSInstallDir)Common7\Tools\bin\prerelease;$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;C:\Program Files\HTML Help Workshop\;$(FrameworkSDKDir)bin;$(FrameworkDir)$(FrameworkVersion);C:\perl\bin;C:\cygwin\bin;c:\cygwin\usr\bin;C:\bin;C:\program files\perforce;C:\cygwin\usr\local\bin\i686-pc-cygwin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem"
135 "Library Dirs"="$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(VCInstallDir)PlatformSDK\lib\prerelease;$(VCInstallDir)PlatformSDK\lib;$(FrameworkSDKDir)lib"
136 "Include Dirs"="$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(VCInstallDir)PlatformSDK\include\prerelease;$(VCInstallDir)PlatformSDK\include;$(FrameworkSDKDir)include"
137 "Source Dirs"="$(VCInstallDir)atlmfc\src\mfc;$(VCInstallDir)atlmfc\src\atl;$(VCInstallDir)crt\src"
138 "Reference Dirs"=""
139 '''.split('\n')
141 regdata_7_1 = r'''
142 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1]
143 @=""
144 "Source Directories"="C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\crt\src\;C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\src\mfc\;C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\src\atl\"
145 "ThisVersionSolutionCLSID"="{246C57AE-40DD-4d6b-9E8D-B0F5757BB2A8}"
146 "ThisVersionDTECLSID"="{8CD2DD97-4EC1-4bc4-9359-89A3EEDD57A6}"
147 "InstallDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\"
148 "CLR Version"="v1.1.4322"
149 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts]
150 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts\Smart Device Extensions]
151 "UseInterface"=dword:00000001
152 "VS7InstallDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\"
153 "VBDeviceInstallDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\VB7\"
154 "CSharpDeviceInstallDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\"
155 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts\Visual Basic.NET]
156 "UseInterface"=dword:00000001
157 "Package"="{164B10B9-B200-11D0-8C61-00A0C91E29D5}"
158 "DefaultProductAttribute"="VB"
159 @=""
160 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts\Visual C#]
161 "DefaultProductAttribute"="C#"
162 "UseInterface"=dword:00000001
163 "Package"="{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}"
164 @=""
165 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts\Visual JSharp]
166 @=""
167 "Package"="{E6FDF8B0-F3D1-11D4-8576-0002A516ECE8}"
168 "UseInterface"=dword:00000001
169 "DefaultProductAttribute"="Visual JSharp"
170 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\InstalledProducts\VisualC++]
171 "UseInterface"=dword:00000001
172 "Package"="{F1C25864-3097-11D2-A5C5-00C04F7968B4}"
173 "DefaultProductAttribute"="VC"
174 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup]
175 "Dbghelp_path"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\"
176 "dw_dir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\"
177 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\CSDPROJ]
178 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\"
179 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\JSHPROJ]
180 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\VJ#\"
181 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\Servicing]
182 "CurrentSULevel"=dword:00000000
183 "CurrentSPLevel"=dword:00000000
184 "Server Path"=""
185 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\Servicing\Package]
186 "FxSDK"=""
187 "VB"=""
188 "VC"=""
189 "VCS"=""
190 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\Servicing\SKU]
191 "Visual Studio .NET Professional 2003 - English"="{20610409-CA18-41A6-9E21-A93AE82EE7C5}"
192 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VB]
193 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Vb7\"
194 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VBDPROJ]
195 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Vb7\"
196 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VC]
197 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\"
198 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VC#]
199 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\"
200 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\Visual Studio .NET Professional 2003 - English]
201 "InstallSuccess"=dword:00000001
202 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VS]
203 "EnvironmentDirectory"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\"
204 "EnvironmentPath"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv.exe"
205 "VS7EnvironmentLocation"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE\devenv.exe"
206 "MSMDir"="C:\Program Files\Common Files\Merge Modules\"
207 "VS7CommonBinDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Tools\"
208 "VS7CommonDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\"
209 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\"
210 "VSUpdateDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\Setup\VSUpdate\"
211 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VS\BuildNumber]
212 "1033"="7.1.3088"
213 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\Setup\VS\Pro]
214 "ProductDir"="C:\Program Files\Microsoft Visual Studio .NET 2003\"
215 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\VC]
216 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\VC\VC_OBJECTS_PLATFORM_INFO]
217 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\VC\VC_OBJECTS_PLATFORM_INFO\Win32]
218 @="{759354D0-6B42-4705-AFFB-56E34D2BC3D4}"
219 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\VC\VC_OBJECTS_PLATFORM_INFO\Win32\Directories]
220 "Path Dirs"="$(VCInstallDir)bin;$(VSInstallDir)Common7\Tools\bin\prerelease;$(VSInstallDir)Common7\Tools\bin;$(VSInstallDir)Common7\tools;$(VSInstallDir)Common7\ide;C:\Program Files\HTML Help Workshop\;$(FrameworkSDKDir)bin;$(FrameworkDir)$(FrameworkVersion);C:\Perl\bin\;c:\bin;c:\cygwin\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Avid;C:\Program Files\backburner 2\;C:\Program Files\cvsnt;C:\Program Files\Subversion\bin;C:\Program Files\Common Files\Adobe\AGL;C:\Program Files\HTMLDoc"
221 "Library Dirs"="$(VCInstallDir)lib;$(VCInstallDir)atlmfc\lib;$(VCInstallDir)PlatformSDK\lib\prerelease;$(VCInstallDir)PlatformSDK\lib;$(FrameworkSDKDir)lib"
222 "Include Dirs"="$(VCInstallDir)include;$(VCInstallDir)atlmfc\include;$(VCInstallDir)PlatformSDK\include\prerelease;$(VCInstallDir)PlatformSDK\include;$(FrameworkSDKDir)include"
223 "Source Dirs"="$(VCInstallDir)atlmfc\src\mfc;$(VCInstallDir)atlmfc\src\atl;$(VCInstallDir)crt\src"
224 "Reference Dirs"="$(FrameWorkDir)$(FrameWorkVersion)"
225 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\7.1\VC\VC_OBJECTS_PLATFORM_INFO\Win32\ToolDefaultExtensionLists]
226 "VCCLCompilerTool"="*.cpp;*.cxx;*.cc;*.c"
227 "VCLinkerTool"="*.obj;*.res;*.lib;*.rsc"
228 "VCLibrarianTool"="*.obj;*.res;*.lib;*.rsc"
229 "VCMIDLTool"="*.idl;*.odl"
230 "VCCustomBuildTool"="*.bat"
231 "VCResourceCompilerTool"="*.rc"
232 "VCPreBuildEventTool"="*.bat"
233 "VCPreLinkEventTool"="*.bat"
234 "VCPostBuildEventTool"="*.bat"
235 "VCBscMakeTool"="*.sbr"
236 "VCNMakeTool"=""
237 "VCWebServiceProxyGeneratorTool"="*.discomap"
238 "VCWebDeploymentTool"=""
239 "VCALinkTool"="*.resources"
240 "VCManagedResourceCompilerTool"="*.resx"
241 "VCXMLDataGeneratorTool"="*.xsd"
242 "VCManagedWrapperGeneratorTool"=""
243 "VCAuxiliaryManagedWrapperGeneratorTool"=""
244 "VCPrimaryInteropTool"=""
245 '''.split('\n')
247 regdata_8exp = r'''
248 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0]
249 "CLR Version"="v2.0.50727"
250 "ApplicationID"="VCExpress"
251 "SecurityAppID"="{741726F6-1EAE-4680-86A6-6085E8872CF8}"
252 "InstallDir"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\"
253 "EnablePreloadCLR"=dword:00000001
254 "RestoreAppPath"=dword:00000001
255 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\InstalledProducts]
256 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\InstalledProducts\Microsoft Visual C++]
257 "UseInterface"=dword:00000001
258 "Package"="{F1C25864-3097-11D2-A5C5-00C04F7968B4}"
259 "DefaultProductAttribute"="VC"
260 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\Setup]
261 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\Setup\VC]
262 "ProductDir"="C:\Program Files\Microsoft Visual Studio 8\VC\"
263 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\Setup\VS]
264 "ProductDir"="C:\Program Files\Microsoft Visual Studio 8\"
265 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\VC]
266 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\VC\VC_OBJECTS_PLATFORM_INFO]
267 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32]
268 @="{72f11281-2429-11d7-8bf6-00b0d03daa06}"
269 [HKEY_LOCAL_MACHINE\Software\Microsoft\VCExpress\8.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32\ToolDefaultExtensionLists]
270 "VCCLCompilerTool"="*.cpp;*.cxx;*.cc;*.c"
271 "VCLinkerTool"="*.obj;*.res;*.lib;*.rsc;*.licenses"
272 "VCLibrarianTool"="*.obj;*.res;*.lib;*.rsc"
273 "VCMIDLTool"="*.idl;*.odl"
274 "VCCustomBuildTool"="*.bat"
275 "VCResourceCompilerTool"="*.rc"
276 "VCPreBuildEventTool"="*.bat"
277 "VCPreLinkEventTool"="*.bat"
278 "VCPostBuildEventTool"="*.bat"
279 "VCBscMakeTool"="*.sbr"
280 "VCFxCopTool"="*.dll;*.exe"
281 "VCNMakeTool"=""
282 "VCWebServiceProxyGeneratorTool"="*.discomap"
283 "VCWebDeploymentTool"=""
284 "VCALinkTool"="*.resources"
285 "VCManagedResourceCompilerTool"="*.resx"
286 "VCXMLDataGeneratorTool"="*.xsd"
287 "VCManifestTool"="*.manifest"
288 "VCXDCMakeTool"="*.xdc"
289 '''.split('\n')
291 regdata_80 = r'''
292 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0]
293 "CLR Version"="v2.0.50727"
294 "ApplicationID"="VisualStudio"
295 "ThisVersionDTECLSID"="{BA018599-1DB3-44f9-83B4-461454C84BF8}"
296 "ThisVersionSolutionCLSID"="{1B2EEDD6-C203-4d04-BD59-78906E3E8AAB}"
297 "SecurityAppID"="{DF99D4F5-9F04-4CEF-9D39-095821B49C77}"
298 "InstallDir"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\"
299 "EnablePreloadCLR"=dword:00000001
300 "RestoreAppPath"=dword:00000001
301 "Source Directories"="C:\Program Files\Microsoft Visual Studio 8\VC\crt\src\;C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\src\mfc\;C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\src\atl\;C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\include\"
302 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\InstalledProducts]
303 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\InstalledProducts\Microsoft Visual C++]
304 "UseInterface"=dword:00000001
305 "Package"="{F1C25864-3097-11D2-A5C5-00C04F7968B4}"
306 "DefaultProductAttribute"="VC"
307 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup]
308 "Dbghelp_path"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\"
309 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\EF]
310 "ProductDir"="C:\Program Files\Microsoft Visual Studio 8\EnterpriseFrameworks\"
311 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\Microsoft Visual Studio 2005 Professional Edition - ENU]
312 "SrcPath"="d:\vs\"
313 "InstallSuccess"=dword:00000001
314 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\VC]
315 "ProductDir"="C:\Program Files\Microsoft Visual Studio 8\VC\"
316 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\VS]
317 "ProductDir"="C:\Program Files\Microsoft Visual Studio 8\"
318 "VS7EnvironmentLocation"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe"
319 "EnvironmentPath"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\devenv.exe"
320 "EnvironmentDirectory"="C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\"
321 "VS7CommonDir"="C:\Program Files\Microsoft Visual Studio 8\Common7\"
322 "VS7CommonBinDir"="C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\"
323 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\VS\BuildNumber]
324 "1033"="8.0.50727.42"
325 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\Setup\VS\Pro]
326 "ProductDir"="C:\Program Files\Microsoft Visual Studio 8\"
327 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\VC]
328 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\VC\VC_OBJECTS_PLATFORM_INFO]
329 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32]
330 @="{72f11281-2429-11d7-8bf6-00b0d03daa06}"
331 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\VC\VC_OBJECTS_PLATFORM_INFO\Win32\ToolDefaultExtensionLists]
332 "VCCLCompilerTool"="*.cpp;*.cxx;*.cc;*.c"
333 "VCLinkerTool"="*.obj;*.res;*.lib;*.rsc;*.licenses"
334 "VCLibrarianTool"="*.obj;*.res;*.lib;*.rsc"
335 "VCMIDLTool"="*.idl;*.odl"
336 "VCCustomBuildTool"="*.bat"
337 "VCResourceCompilerTool"="*.rc"
338 "VCPreBuildEventTool"="*.bat"
339 "VCPreLinkEventTool"="*.bat"
340 "VCPostBuildEventTool"="*.bat"
341 "VCBscMakeTool"="*.sbr"
342 "VCFxCopTool"="*.dll;*.exe"
343 "VCNMakeTool"=""
344 "VCWebServiceProxyGeneratorTool"="*.discomap"
345 "VCWebDeploymentTool"=""
346 "VCALinkTool"="*.resources"
347 "VCManagedResourceCompilerTool"="*.resx"
348 "VCXMLDataGeneratorTool"="*.xsd"
349 "VCManifestTool"="*.manifest"
350 "VCXDCMakeTool"="*.xdc"
351 '''.split('\n')
353 regdata_140 = r'''
354 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS]
355 "MSMDir"="C:\\Program Files (x86)\\Common Files\\Merge Modules\\"
356 "ProductDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\"
357 "VS7EnvironmentLocation"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\devenv.exe"
358 "EnvironmentPath"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\devenv.exe"
359 "EnvironmentDirectory"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\"
360 "VS7CommonDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\"
361 "VS7CommonBinDir"=""
362 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\BuildNumber]
363 "1033"="14.0"
364 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\Community]
365 "ProductDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\"
366 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\JSLS_MSI]
367 "Version"="14.0.25527"
368 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\JSPS_MSI]
369 "Version"="14.0.25527"
370 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\Pro]
371 "ProductDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\"
372 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\professional]
373 "IsInstallInProgress"="0"
374 "CurrentOperation"="install"
375 "SetupFeedUri"="http://go.microsoft.com/fwlink/?LinkID=659004&clcid=0x409"
376 "SetupFeedLocalCache"="C:\\ProgramData\\Microsoft\\VisualStudioSecondaryInstaller\\14.0\\LastUsedFeed\\{68432bbb-c9a5-4a7b-bab3-ae5a49b28303}\\Feed.xml"
377 "InstallResult"="0"
378 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\SecondaryInstaller]
379 [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\SecondaryInstaller\AppInsightsTools]
380 "Version"="7.0.20620.1"
381 '''.split('\n')
383 regdata_cv = r'''[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion]
384 "ProgramFilesDir"="C:\Program Files"
385 "CommonFilesDir"="C:\Program Files\Common Files"
386 "MediaPath"="C:\WINDOWS\Media"
387 '''.split('\n')
390 regdata_none = []
392 class DummyEnv:
393 def __init__(self, dict=None) -> None:
394 self.fs = SCons.Node.FS.FS()
395 if dict:
396 self.dict = dict
397 else:
398 self.dict = {}
400 def Dictionary(self, key = None):
401 if not key:
402 return self.dict
403 return self.dict[key]
405 def __setitem__(self, key, value) -> None:
406 self.dict[key] = value
408 def __getitem__(self, key):
409 return self.dict[key]
411 def __contains__(self, key) -> bool:
412 return key in self.dict
414 def get(self, name, value=None):
415 if name in self.dict:
416 return self.dict[name]
417 else:
418 return value
420 def Dir(self, name):
421 return self.fs.Dir(name)
424 class RegKey:
425 """key class for storing an 'open' registry key"""
426 def __init__(self,key) -> None:
427 self.key = key
429 # Warning: this is NOT case-insensitive, unlike the Windows registry.
430 # So e.g. HKLM\Software is NOT the same key as HKLM\SOFTWARE.
431 class RegNode:
432 """node in the dummy registry"""
433 def __init__(self,name) -> None:
434 self.valdict = {}
435 self.keydict = {}
436 self.keyarray = []
437 self.valarray = []
438 self.name = name
440 def value(self,val):
441 if val in self.valdict:
442 return (self.valdict[val],1)
443 else:
444 raise SCons.Util.RegError
446 def addValue(self,name,val) -> None:
447 self.valdict[name] = val
448 self.valarray.append(name)
450 def valindex(self,index):
451 rv = None
452 try:
453 rv = (self.valarray[index],self.valdict[self.valarray[index]],1)
454 except KeyError:
455 raise SCons.Util.RegError
456 return rv
458 def key(self,key,sep: str = '\\'):
459 if key.find(sep) != -1:
460 keyname, subkeys = key.split(sep,1)
461 else:
462 keyname = key
463 subkeys = ""
464 try:
465 # recurse, and return the lowest level key node
466 if subkeys:
467 return self.keydict[keyname].key(subkeys)
468 else:
469 return self.keydict[keyname]
470 except KeyError:
471 raise SCons.Util.RegError
473 def addKey(self,name,sep: str = '\\'):
474 if name.find(sep) != -1:
475 keyname, subkeys = name.split(sep, 1)
476 else:
477 keyname = name
478 subkeys = ""
480 if keyname not in self.keydict:
481 self.keydict[keyname] = RegNode(keyname)
482 self.keyarray.append(keyname)
484 # recurse, and return the lowest level key node
485 if subkeys:
486 return self.keydict[keyname].addKey(subkeys)
487 else:
488 return self.keydict[keyname]
490 def keyindex(self,index):
491 return self.keydict[self.keyarray[index]]
493 def __str__(self) -> str:
494 return self._doStr()
496 def _doStr(self, indent: str = ''):
497 rv = ""
498 for value in self.valarray:
499 rv = rv + '%s"%s" = "%s"\n' % (indent, value, self.valdict[value])
500 for key in self.keyarray:
501 rv = rv + "%s%s: {\n"%(indent, key)
502 rv = rv + self.keydict[key]._doStr(indent + ' ')
503 rv = rv + indent + '}\n'
504 return rv
506 class DummyRegistry:
507 """registry class for storing fake registry attributes"""
508 def __init__(self,data) -> None:
509 """parse input data into the fake registry"""
510 self.root = RegNode('REGISTRY')
511 self.root.addKey('HKEY_LOCAL_MACHINE')
512 self.root.addKey('HKEY_CURRENT_USER')
513 self.root.addKey('HKEY_USERS')
514 self.root.addKey('HKEY_CLASSES_ROOT')
516 self.parse(data)
518 def parse(self, data) -> None:
519 parents = [None, None]
520 parents[0] = self.root
521 keymatch = re.compile(r'^\[(.*)\]$')
522 valmatch = re.compile(r'^(?:"(.*)"|[@])="(.*)"$')
523 for line in data:
524 m1 = keymatch.match(line)
525 if m1:
526 # add a key, set it to current parent.
527 # Also create subkey for Wow6432Node of HKLM\Software;
528 # that's where it looks on a 64-bit machine (tests will fail w/o this)
529 parents[0] = self.root.addKey(m1.group(1))
530 if 'HKEY_LOCAL_MACHINE\\Software' in m1.group(1):
531 p1 = m1.group(1).replace('HKEY_LOCAL_MACHINE\\Software', 'HKEY_LOCAL_MACHINE\\Software\\Wow6432Node')
532 parents[1] = self.root.addKey(p1)
533 else:
534 parents[1] = None
535 else:
536 m2 = valmatch.match(line)
537 if m2:
538 for p in parents:
539 if p:
540 p.addValue(m2.group(1),m2.group(2))
542 def OpenKeyEx(self,root,key):
543 if root == SCons.Util.HKEY_CLASSES_ROOT:
544 mykey = 'HKEY_CLASSES_ROOT\\' + key
545 if root == SCons.Util.HKEY_USERS:
546 mykey = 'HKEY_USERS\\' + key
547 if root == SCons.Util.HKEY_CURRENT_USER:
548 mykey = 'HKEY_CURRENT_USER\\' + key
549 if root == SCons.Util.HKEY_LOCAL_MACHINE:
550 mykey = 'HKEY_LOCAL_MACHINE\\' + key
551 debug("Open Key:%s"%mykey)
552 return self.root.key(mykey)
554 def DummyOpenKeyEx(root, key):
555 return registry.OpenKeyEx(root,key)
557 def DummyEnumKey(key, index):
558 rv = None
559 try:
560 rv = key.keyarray[index]
561 except IndexError:
562 raise SCons.Util.RegError
563 # DEBUG
564 # print "Enum Key",key.name,"[",index,"] =>",rv
565 return rv
567 def DummyEnumValue(key, index):
568 rv = key.valindex(index)
569 # DEBUG
570 # print "Enum Value",key.name,"[",index,"] =>",rv
571 return rv
573 def DummyQueryValue(key, value):
574 rv = key.value(value)
575 # DEBUG
576 # print "Query Value",key.name+"\\"+value,"=>",rv
577 return rv
579 def DummyExists(path) -> bool:
580 return True
582 def DummyVsWhere(msvc_version, env):
583 # not testing versions with vswhere, so return none
584 return None
586 class msvsTestCase(unittest.TestCase):
587 """This test case is run several times with different defaults.
588 See its subclasses below."""
589 def setUp(self) -> None:
590 debug("THIS TYPE :%s"%self)
591 global registry
592 registry = self.registry
593 from SCons.Tool.MSCommon.vs import reset_installed_visual_studios
594 reset_installed_visual_studios()
596 self.test = TestCmd.TestCmd(workdir='')
597 # FS doesn't like the cwd to be something other than its root.
598 os.chdir(self.test.workpath(""))
599 self.fs = SCons.Node.FS.FS()
601 def test_get_default_version(self) -> None:
602 """Test retrieval of the default visual studio version"""
604 debug("Testing for default version %s"%self.default_version)
605 env = DummyEnv()
606 v1 = get_default_version(env)
607 if v1:
608 assert env['MSVS_VERSION'] == self.default_version, \
609 ("env['MSVS_VERSION'] != self.default_version",
610 env['MSVS_VERSION'],self.default_version)
611 assert env['MSVS']['VERSION'] == self.default_version, \
612 ("env['MSVS']['VERSION'] != self.default_version",
613 env['MSVS']['VERSION'], self.default_version)
614 assert v1 == self.default_version, (self.default_version, v1)
616 env = DummyEnv({'MSVS_VERSION':'7.0'})
617 v2 = get_default_version(env)
618 assert env['MSVS_VERSION'] == '7.0', env['MSVS_VERSION']
619 assert env['MSVS']['VERSION'] == '7.0', env['MSVS']['VERSION']
620 assert v2 == '7.0', v2
622 env = DummyEnv()
623 v3 = get_default_version(env)
624 if v3 == '7.1':
625 override = '7.0'
626 else:
627 override = '7.1'
628 env['MSVS_VERSION'] = override
629 v3 = get_default_version(env)
630 assert env['MSVS_VERSION'] == override, env['MSVS_VERSION']
631 assert env['MSVS']['VERSION'] == override, env['MSVS']['VERSION']
632 assert v3 == override, v3
634 def _TODO_test_merge_default_version(self) -> None:
635 """Test the merge_default_version() function"""
636 pass
638 def test_query_versions(self) -> None:
639 """Test retrieval of the list of visual studio versions"""
640 v1 = query_versions()
641 assert not v1 or str(v1[0]) == self.highest_version, \
642 (v1, self.highest_version)
643 assert len(v1) == self.number_of_versions, v1
645 def test_config_generation(self) -> None:
646 """Test _DSPGenerator.__init__(...)"""
647 if not self.highest_version :
648 return
650 # Initialize 'static' variables
651 version_num, suite = msvs_parse_version(self.highest_version)
652 if version_num >= 10.0:
653 function_test = _GenerateV10DSP
654 suffix = '.vcxproj'
655 elif version_num >= 7.0:
656 function_test = _GenerateV7DSP
657 suffix = '.dsp'
658 else:
659 function_test = _GenerateV6DSP
660 suffix = '.dsp'
662 # Avoid any race conditions between the test cases when we test
663 # actually writing the files.
664 dspfile = 'test%s%s' % (hash(self), suffix)
666 str_function_test = str(function_test.__init__)
667 source = 'test.cpp'
669 # Create the cmdargs test list
670 list_variant = ['Debug|Win32','Release|Win32',
671 'Debug|x64', 'Release|x64']
672 list_cmdargs = ['debug=True target_arch=32',
673 'debug=False target_arch=32',
674 'debug=True target_arch=x64',
675 'debug=False target_arch=x64']
676 list_cppdefines = [['_A', '_B', 'C'], ['_B', '_C_'], ['D'], []]
677 list_cpppaths = [[r'C:\test1'], [r'C:\test1;C:\test2'],
678 [self.fs.Dir('subdir')], []]
679 list_cppflags = [['/std:c++17', '/Zc:__cplusplus'],
680 ['/std:c++14', '/Zc:__cplusplus'],
681 ['/std:c++11', '/Zc:__cplusplus'], []]
683 def TestParamsFromList(test_variant, test_list):
685 Generates test data based on the parameters passed in.
687 Returns tuple list:
688 1. Parameter.
689 2. Dictionary of expected result per variant.
691 def normalizeParam(param):
693 Converts the raw data based into the AddConfig function of
694 msvs.py to the expected result.
696 Expects the following behavior:
697 1. A value of None will be converted to an empty list.
698 2. A File or Directory object will be converted to an
699 absolute path (because those objects can't be pickled).
700 3. Otherwise, the parameter will be used.
702 if param is None:
703 return []
704 elif isinstance(param, list):
705 return [normalizeParam(p) for p in param]
706 elif hasattr(param, 'abspath'):
707 return param.abspath
708 else:
709 return param
711 return [
712 (None, dict.fromkeys(test_variant, '')),
713 ('', dict.fromkeys(test_variant, '')),
714 (test_list[0], dict.fromkeys(test_variant, normalizeParam(test_list[0]))),
715 (test_list, dict(list(zip(test_variant, [normalizeParam(x) for x in test_list]))))
718 tests_cmdargs = TestParamsFromList(list_variant, list_cmdargs)
719 tests_cppdefines = TestParamsFromList(list_variant, list_cppdefines)
720 tests_cpppaths = TestParamsFromList(list_variant, list_cpppaths)
721 tests_cppflags = TestParamsFromList(list_variant, list_cppflags)
723 # Run the test for each test case
724 for param_cmdargs, expected_cmdargs in tests_cmdargs:
725 for param_cppdefines, expected_cppdefines in tests_cppdefines:
726 for param_cpppaths, expected_cpppaths in tests_cpppaths:
727 for param_cppflags, expected_cppflags in tests_cppflags:
728 # DEBUG:
729 # print(
730 # 'Testing %s. with :\n variant = %s \n cmdargs = "%s" \n cppdefines = "%s" \n cpppaths = "%s" \n cppflags = "%s"'
731 # % (
732 # str_function_test,
733 # list_variant,
734 # param_cmdargs,
735 # param_cppdefines,
736 # param_cpppaths,
737 # param_cppflags,
740 param_configs = []
741 expected_configs = {}
742 for platform in ['Win32', 'x64']:
743 for variant in ['Debug', 'Release']:
744 variant_platform = '%s|%s' % (variant, platform)
745 runfile = '%s\\%s\\test.exe' % (platform, variant)
746 buildtarget = '%s\\%s\\test.exe' % (platform, variant)
747 outdir = '%s\\%s' % (platform, variant)
749 # Create parameter list for this variant_platform
750 param_configs.append([variant_platform, runfile, buildtarget, outdir])
752 # Create expected dictionary result for this variant_platform
753 expected_configs[variant_platform] = {
754 'variant': variant,
755 'platform': platform,
756 'runfile': runfile,
757 'buildtarget': buildtarget,
758 'outdir': outdir,
759 'cmdargs': expected_cmdargs[variant_platform],
760 'cppdefines': expected_cppdefines[variant_platform],
761 'cpppaths': expected_cpppaths[variant_platform],
762 'cppflags': expected_cppflags[variant_platform],
765 # Create parameter environment with final parameter dictionary
766 param_dict = dict(list(zip(('variant', 'runfile', 'buildtarget', 'outdir'),
767 [list(l) for l in zip(*param_configs)])))
768 param_dict['cmdargs'] = param_cmdargs
769 param_dict['cppdefines'] = param_cppdefines
770 param_dict['cpppaths'] = param_cpppaths
771 param_dict['cppflags'] = param_cppflags
773 # Hack to be able to run the test with a 'DummyEnv'
774 class _DummyEnv(DummyEnv):
775 def subst(self, string, *args, **kwargs):
776 return string
778 env = _DummyEnv(param_dict)
779 env['MSVSSCONSCRIPT'] = ''
780 env['MSVS_VERSION'] = self.highest_version
781 env['MSVSBUILDTARGET'] = 'target'
783 # Call function to test
784 genDSP = function_test(dspfile, source, env)
786 # Check expected result
787 self.assertListEqual(list(genDSP.configs.keys()), list(expected_configs.keys()))
788 for key, v in genDSP.configs.items():
789 self.assertDictEqual(v.__dict__, expected_configs[key])
791 genDSP.Build()
793 # Delete the resulting file so we don't leave anything behind.
794 for file in [dspfile, dspfile + '.filters']:
795 path = os.path.realpath(file)
796 try:
797 os.remove(path)
798 except OSError:
799 pass
801 class msvs6aTestCase(msvsTestCase):
802 """Test MSVS 6 Registry"""
803 registry = DummyRegistry(regdata_6a + regdata_cv)
804 default_version = '6.0'
805 highest_version = '6.0'
806 number_of_versions = 1
807 install_locs = {
808 '6.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio\\VC98', 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio\\VC98\\Bin'},
809 '7.0' : {},
810 '7.1' : {},
811 '8.0' : {},
812 '8.0Exp' : {},
814 default_install_loc = install_locs['6.0']
816 class msvs6bTestCase(msvsTestCase):
817 """Test Other MSVS 6 Registry"""
818 registry = DummyRegistry(regdata_6b + regdata_cv)
819 default_version = '6.0'
820 highest_version = '6.0'
821 number_of_versions = 1
822 install_locs = {
823 '6.0' : {'VSINSTALLDIR': 'C:\\VS6\\VC98', 'VCINSTALLDIR': 'C:\\VS6\\VC98\\Bin'},
824 '7.0' : {},
825 '7.1' : {},
826 '8.0' : {},
827 '8.0Exp' : {},
829 default_install_loc = install_locs['6.0']
831 class msvs6and7TestCase(msvsTestCase):
832 """Test MSVS 6 & 7 Registry"""
833 registry = DummyRegistry(regdata_6b + regdata_7 + regdata_cv)
834 default_version = '7.0'
835 highest_version = '7.0'
836 number_of_versions = 2
837 install_locs = {
838 '6.0' : {'VSINSTALLDIR': 'C:\\VS6\\VC98',
839 'VCINSTALLDIR': 'C:\\VS6\\VC98\\Bin'},
840 '7.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\Common7',
841 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\Common7\\Tools'},
842 '7.1' : {},
843 '8.0' : {},
844 '8.0Exp' : {},
846 default_install_loc = install_locs['7.0']
848 class msvs7TestCase(msvsTestCase):
849 """Test MSVS 7 Registry"""
850 registry = DummyRegistry(regdata_7 + regdata_cv)
851 default_version = '7.0'
852 highest_version = '7.0'
853 number_of_versions = 1
854 install_locs = {
855 '6.0' : {},
856 '7.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\Common7',
857 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET\\Common7\\Tools'},
858 '7.1' : {},
859 '8.0' : {},
860 '8.0Exp' : {},
862 default_install_loc = install_locs['7.0']
864 class msvs71TestCase(msvsTestCase):
865 """Test MSVS 7.1 Registry"""
866 registry = DummyRegistry(regdata_7_1 + regdata_cv)
867 default_version = '7.1'
868 highest_version = '7.1'
869 number_of_versions = 1
870 install_locs = {
871 '6.0' : {},
872 '7.0' : {},
873 '7.1' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Common7',
874 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Common7\\Tools'},
875 '8.0' : {},
876 '8.0Exp' : {},
878 default_install_loc = install_locs['7.1']
880 class msvs8ExpTestCase(msvsTestCase): # XXX: only one still not working
881 """Test MSVS 8 Express Registry"""
882 registry = DummyRegistry(regdata_8exp + regdata_cv)
883 default_version = '8.0Exp'
884 highest_version = '8.0Exp'
885 number_of_versions = 1
886 install_locs = {
887 '6.0' : {},
888 '7.0' : {},
889 '7.1' : {},
890 '8.0' : {},
891 '8.0Exp' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 8',
892 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 8\\VC'},
894 default_install_loc = install_locs['8.0Exp']
896 class msvs80TestCase(msvsTestCase):
897 """Test MSVS 8 Registry"""
898 registry = DummyRegistry(regdata_80 + regdata_cv)
899 default_version = '8.0'
900 highest_version = '8.0'
901 number_of_versions = 1
902 install_locs = {
903 '6.0' : {},
904 '7.0' : {},
905 '7.1' : {},
906 '8.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 8',
907 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 8\\VC'},
908 '8.0Exp' : {},
910 default_install_loc = install_locs['8.0']
912 class msvs140TestCase(msvsTestCase):
913 """Test MSVS 140 Registry"""
914 registry = DummyRegistry(regdata_140 + regdata_cv)
915 default_version = '14.0'
916 highest_version = '14.0'
917 number_of_versions = 2
918 install_locs = {
919 '14.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 14.0',
920 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 14.0\\VC'},
922 default_install_loc = install_locs['14.0']
924 class msvsEmptyTestCase(msvsTestCase):
925 """Test Empty Registry"""
926 registry = DummyRegistry(regdata_none)
927 default_version = SupportedVSList[0].version
928 highest_version = None
929 number_of_versions = 0
930 install_locs = {
931 '6.0' : {},
932 '7.0' : {},
933 '7.1' : {},
934 '8.0' : {},
935 '8.0Exp' : {},
937 default_install_loc = install_locs['8.0Exp']
939 if __name__ == "__main__":
941 # only makes sense to test this on win32
942 if sys.platform != 'win32':
943 sys.stdout.write("NO RESULT for msvsTests.py: '%s' is not win32\n" % sys.platform)
944 sys.exit(0)
946 SCons.Util.RegOpenKeyEx = DummyOpenKeyEx
947 SCons.Util.RegEnumKey = DummyEnumKey
948 SCons.Util.RegEnumValue = DummyEnumValue
949 SCons.Util.RegQueryValueEx = DummyQueryValue
950 SCons.Tool.MSCommon.vc.find_vc_pdir_vswhere = DummyVsWhere
952 os.path.exists = DummyExists # make sure all files exist :-)
953 os.path.isfile = DummyExists # make sure all files are files :-)
954 os.path.isdir = DummyExists # make sure all dirs are dirs :-)
956 exit_val = 0
958 test_classes = [
959 msvs6aTestCase,
960 msvs6bTestCase,
961 msvs6and7TestCase,
962 msvs7TestCase,
963 msvs71TestCase,
964 msvs8ExpTestCase,
965 msvs80TestCase,
966 msvs140TestCase,
967 msvsEmptyTestCase,
970 for test_class in test_classes:
971 # DEBUG
972 # print("TEST: ", test_class.__doc__)
973 back_osenv = copy.deepcopy(os.environ)
974 try:
975 # XXX: overriding the os.environ is bad, but doing it
976 # correctly is too complicated for now. Those tests should
977 # be fixed
978 for k in ['VS71COMNTOOLS',
979 'VS80COMNTOOLS',
980 'VS90COMNTOOLS']:
981 if k in os.environ:
982 del os.environ[k]
984 loader = unittest.TestLoader()
985 loader.testMethodPrefix = 'test_'
986 suite = loader.loadTestsFromTestCase(test_class)
987 if not TestUnit.cli.get_runner()().run(suite).wasSuccessful():
988 exit_val = 1
989 finally:
990 os.env = back_osenv
992 sys.exit(exit_val)
994 # Local Variables:
995 # tab-width:4
996 # indent-tabs-mode:nil
997 # End:
998 # vim: set expandtab tabstop=4 shiftwidth=4: