summaryrefslogtreecommitdiff
path: root/src/engine/SCons/Tool/msvsTests.py
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-23 16:54:23 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2019-07-23 16:54:23 +0200
commitc2d9eaeffe9d77d8d5087fb21a3256fde32047d4 (patch)
tree144aeb4702d258b0cfaf99cffb9f21e94b026459 /src/engine/SCons/Tool/msvsTests.py
parent6ca68f29862bc7cbe5428426eee600cb1f3c05c1 (diff)
parentefdf3fdbcd2f7654cb8d1209a8b040914437bacd (diff)
Update upstream source from tag 'upstream/3.1.0'
Update to upstream version '3.1.0' with Debian dir e69b7671114411c368722827d87d86b44ed7cd40
Diffstat (limited to 'src/engine/SCons/Tool/msvsTests.py')
-rw-r--r--src/engine/SCons/Tool/msvsTests.py181
1 files changed, 151 insertions, 30 deletions
diff --git a/src/engine/SCons/Tool/msvsTests.py b/src/engine/SCons/Tool/msvsTests.py
index fd5e343..e0b5ced 100644
--- a/src/engine/SCons/Tool/msvsTests.py
+++ b/src/engine/SCons/Tool/msvsTests.py
@@ -22,7 +22,7 @@
#
from __future__ import print_function
-__revision__ = "src/engine/SCons/Tool/msvsTests.py 103260fce95bf5db1c35fb2371983087d85dd611 2019-07-13 18:25:30 bdbaddog"
+__revision__ = "src/engine/SCons/Tool/msvsTests.py e724ae812eb96f4858a132f5b8c769724744faf6 2019-07-21 00:04:47 bdeegan"
import os
import sys
@@ -34,6 +34,7 @@ import TestUnit
from SCons.Tool.msvs import *
from SCons.Tool.MSCommon.vs import SupportedVSList
+import SCons.Node.FS
import SCons.Util
import SCons.Warnings
@@ -352,6 +353,36 @@ regdata_80 = r'''
"VCXDCMakeTool"="*.xdc"
'''.split('\n')
+regdata_140 = r'''
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS]
+"MSMDir"="C:\\Program Files (x86)\\Common Files\\Merge Modules\\"
+"ProductDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\"
+"VS7EnvironmentLocation"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\devenv.exe"
+"EnvironmentPath"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\devenv.exe"
+"EnvironmentDirectory"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\"
+"VS7CommonDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\"
+"VS7CommonBinDir"=""
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\BuildNumber]
+"1033"="14.0"
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\Community]
+"ProductDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\"
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\JSLS_MSI]
+"Version"="14.0.25527"
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\JSPS_MSI]
+"Version"="14.0.25527"
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\Pro]
+"ProductDir"="C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\"
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\professional]
+"IsInstallInProgress"="0"
+"CurrentOperation"="install"
+"SetupFeedUri"="http://go.microsoft.com/fwlink/?LinkID=659004&clcid=0x409"
+"SetupFeedLocalCache"="C:\\ProgramData\\Microsoft\\VisualStudioSecondaryInstaller\\14.0\\LastUsedFeed\\{68432bbb-c9a5-4a7b-bab3-ae5a49b28303}\\Feed.xml"
+"InstallResult"="0"
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\SecondaryInstaller]
+[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\14.0\Setup\VS\SecondaryInstaller\AppInsightsTools]
+"Version"="7.0.20620.1"
+'''.split('\n')
+
regdata_cv = r'''[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion]
"ProgramFilesDir"="C:\Program Files"
"CommonFilesDir"="C:\Program Files\Common Files"
@@ -363,6 +394,7 @@ regdata_none = []
class DummyEnv(object):
def __init__(self, dict=None):
+ self.fs = SCons.Node.FS.FS()
if dict:
self.dict = dict
else:
@@ -385,6 +417,16 @@ class DummyEnv(object):
def has_key(self,name):
return name in self.dict
+ def get(self, name, value=None):
+ if self.has_key(name):
+ return self.dict[name]
+ else:
+ return value
+
+ def Dir(self, name):
+ return self.fs.Dir(name)
+
+
class RegKey(object):
"""key class for storing an 'open' registry key"""
def __init__(self,key):
@@ -554,6 +596,11 @@ class msvsTestCase(unittest.TestCase):
from SCons.Tool.MSCommon.vs import reset_installed_visual_studios
reset_installed_visual_studios()
+ self.test = TestCmd.TestCmd(workdir='')
+ # FS doesn't like the cwd to be something other than its root.
+ os.chdir(self.test.workpath(""))
+ self.fs = SCons.Node.FS.FS()
+
def test_get_default_version(self):
"""Test retrieval of the default visual studio version"""
@@ -607,13 +654,19 @@ class msvsTestCase(unittest.TestCase):
version_num, suite = msvs_parse_version(self.highest_version)
if version_num >= 10.0:
function_test = _GenerateV10DSP
+ suffix = '.vcxproj'
elif version_num >= 7.0:
function_test = _GenerateV7DSP
+ suffix = '.dsp'
else:
function_test = _GenerateV6DSP
+ suffix = '.dsp'
+
+ # Avoid any race conditions between the test cases when we test
+ # actually writing the files.
+ dspfile = 'test%s%s' % (hash(self), suffix)
str_function_test = str(function_test.__init__)
- dspfile = 'test.dsp'
source = 'test.cpp'
# Create the cmdargs test list
@@ -623,50 +676,95 @@ class msvsTestCase(unittest.TestCase):
'debug=False target_arch=32',
'debug=True target_arch=x64',
'debug=False target_arch=x64']
-
- # Tuple list : (parameter, dictionary of expected result per variant)
- tests_cmdargs = [(None, dict.fromkeys(list_variant, '')),
- ('', dict.fromkeys(list_variant, '')),
- (list_cmdargs[0], dict.fromkeys(list_variant, list_cmdargs[0])),
- (list_cmdargs, dict(list(zip(list_variant, list_cmdargs))))]
-
+ list_cppdefines = [['_A', '_B', 'C'], ['_B', '_C_'], ['D'], []]
+ list_cpppaths = [[r'C:\test1'], [r'C:\test1;C:\test2'],
+ [self.fs.Dir('subdir')], []]
+
+ def TestParamsFromList(test_variant, test_list):
+ """
+ Generates test data based on the parameters passed in.
+
+ Returns tuple list:
+ 1. Parameter.
+ 2. Dictionary of expected result per variant.
+ """
+ def normalizeParam(param):
+ """
+ Converts the raw data based into the AddConfig function of
+ msvs.py to the expected result.
+
+ Expects the following behavior:
+ 1. A value of None will be converted to an empty list.
+ 2. A File or Directory object will be converted to an
+ absolute path (because those objects can't be pickled).
+ 3. Otherwise, the parameter will be used.
+ """
+ if param is None:
+ return []
+ elif isinstance(param, list):
+ return [normalizeParam(p) for p in param]
+ elif hasattr(param, 'abspath'):
+ return param.abspath
+ else:
+ return param
+
+ return [
+ (None, dict.fromkeys(test_variant, '')),
+ ('', dict.fromkeys(test_variant, '')),
+ (test_list[0], dict.fromkeys(test_variant, normalizeParam(test_list[0]))),
+ (test_list, dict(list(zip(test_variant, [normalizeParam(x) for x in test_list]))))
+ ]
+
+ tests_cmdargs = TestParamsFromList(list_variant, list_cmdargs)
+ tests_cppdefines = TestParamsFromList(list_variant, list_cppdefines)
+ tests_cpppaths = TestParamsFromList(list_variant, list_cpppaths)
+
# Run the test for each test case
for param_cmdargs, expected_cmdargs in tests_cmdargs:
- debug('Testing %s. with :\n variant = %s \n cmdargs = "%s"' % \
- (str_function_test, list_variant, param_cmdargs))
- param_configs = []
- expected_configs = {}
- for platform in ['Win32', 'x64']:
- for variant in ['Debug', 'Release']:
- variant_platform = '%s|%s' % (variant, platform)
- runfile = '%s\\%s\\test.exe' % (platform, variant)
- buildtarget = '%s\\%s\\test.exe' % (platform, variant)
- outdir = '%s\\%s' % (platform, variant)
+ for param_cppdefines, expected_cppdefines in tests_cppdefines:
+ for param_cpppaths, expected_cpppaths in tests_cpppaths:
+ debug('Testing %s. with :\n variant = %s \n cmdargs = "%s" \n cppdefines = "%s" \n cpppaths = "%s"' % \
+ (str_function_test, list_variant, param_cmdargs, param_cppdefines, param_cpppaths))
+ param_configs = []
+ expected_configs = {}
+ for platform in ['Win32', 'x64']:
+ for variant in ['Debug', 'Release']:
+ variant_platform = '%s|%s' % (variant, platform)
+ runfile = '%s\\%s\\test.exe' % (platform, variant)
+ buildtarget = '%s\\%s\\test.exe' % (platform, variant)
+ outdir = '%s\\%s' % (platform, variant)
- # Create parameter list for this variant_platform
- param_configs.append([variant_platform, runfile, buildtarget, outdir])
-
- # Create expected dictionary result for this variant_platform
- expected_configs[variant_platform] = \
- {'variant': variant, 'platform': platform,
- 'runfile': runfile,
- 'buildtarget': buildtarget,
- 'outdir': outdir,
- 'cmdargs': expected_cmdargs[variant_platform]}
+ # Create parameter list for this variant_platform
+ param_configs.append([variant_platform, runfile, buildtarget, outdir])
+ # Create expected dictionary result for this variant_platform
+ expected_configs[variant_platform] = {
+ 'variant': variant,
+ 'platform': platform,
+ 'runfile': runfile,
+ 'buildtarget': buildtarget,
+ 'outdir': outdir,
+ 'cmdargs': expected_cmdargs[variant_platform],
+ 'cppdefines': expected_cppdefines[variant_platform],
+ 'cpppaths': expected_cpppaths[variant_platform],
+ }
+
# Create parameter environment with final parameter dictionary
param_dict = dict(list(zip(('variant', 'runfile', 'buildtarget', 'outdir'),
[list(l) for l in zip(*param_configs)])))
param_dict['cmdargs'] = param_cmdargs
+ param_dict['cppdefines'] = param_cppdefines
+ param_dict['cpppaths'] = param_cpppaths
# Hack to be able to run the test with a 'DummyEnv'
class _DummyEnv(DummyEnv):
- def subst(self, string) :
+ def subst(self, string, *args, **kwargs):
return string
env = _DummyEnv(param_dict)
env['MSVSSCONSCRIPT'] = ''
env['MSVS_VERSION'] = self.highest_version
+ env['MSVSBUILDTARGET'] = 'target'
# Call function to test
genDSP = function_test(dspfile, source, env)
@@ -676,6 +774,16 @@ class msvsTestCase(unittest.TestCase):
for key in list(genDSP.configs.keys()):
self.assertDictEqual(genDSP.configs[key].__dict__, expected_configs[key])
+ genDSP.Build()
+
+ # Delete the resulting file so we don't leave anything behind.
+ for file in [dspfile, dspfile + '.filters']:
+ path = os.path.realpath(file)
+ try:
+ os.remove(path)
+ except OSError:
+ pass
+
class msvs6aTestCase(msvsTestCase):
"""Test MSVS 6 Registry"""
registry = DummyRegistry(regdata_6a + regdata_cv)
@@ -787,6 +895,18 @@ class msvs80TestCase(msvsTestCase):
}
default_install_loc = install_locs['8.0']
+class msvs140TestCase(msvsTestCase):
+ """Test MSVS 140 Registry"""
+ registry = DummyRegistry(regdata_140 + regdata_cv)
+ default_version = '14.0'
+ highest_version = '14.0'
+ number_of_versions = 2
+ install_locs = {
+ '14.0' : {'VSINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 14.0',
+ 'VCINSTALLDIR': 'C:\\Program Files\\Microsoft Visual Studio 14.0\\VC'},
+ }
+ default_install_loc = install_locs['14.0']
+
class msvsEmptyTestCase(msvsTestCase):
"""Test Empty Registry"""
registry = DummyRegistry(regdata_none)
@@ -829,6 +949,7 @@ if __name__ == "__main__":
msvs71TestCase,
msvs8ExpTestCase,
msvs80TestCase,
+ msvs140TestCase,
msvsEmptyTestCase,
]