diff options
author | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-06-21 07:55:31 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff-webhosting.net> | 2015-06-21 07:55:31 +0200 |
commit | 39fa0bace059116d9a45e09fcd18691390b166bd (patch) | |
tree | 77f5abf2964bd92dc9e338654a4ffaaffc24d9ce /src/engine/SCons/Tool/msvsTests.py | |
parent | f9b0c331d8b9d03be91b56e324f59424af45302b (diff) | |
parent | f7e5d2b46b03cc4bc09c38f7e0873378bb9c3b78 (diff) |
Merge tag 'upstream/2.3.5'
Upstream version 2.3.5
Diffstat (limited to 'src/engine/SCons/Tool/msvsTests.py')
-rw-r--r-- | src/engine/SCons/Tool/msvsTests.py | 83 |
1 files changed, 81 insertions, 2 deletions
diff --git a/src/engine/SCons/Tool/msvsTests.py b/src/engine/SCons/Tool/msvsTests.py index 600085f..3454c6c 100644 --- a/src/engine/SCons/Tool/msvsTests.py +++ b/src/engine/SCons/Tool/msvsTests.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2001 - 2014 The SCons Foundation +# Copyright (c) 2001 - 2015 The SCons Foundation # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -21,7 +21,7 @@ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # -__revision__ = "src/engine/SCons/Tool/msvsTests.py 2014/09/27 12:51:43 garyo" +__revision__ = "src/engine/SCons/Tool/msvsTests.py pchdll:3325:cd517fae59a4 2015/06/18 06:53:27 bdbaddog" import os import sys @@ -40,6 +40,7 @@ from SCons.Tool.MSCommon.common import debug from SCons.Tool.MSCommon import get_default_version, \ query_versions +from SCons.Tool.msvs import _GenerateV6DSP, _GenerateV7DSP, _GenerateV10DSP regdata_6a = r'''[HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio] [HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\6.0] @@ -591,6 +592,84 @@ class msvsTestCase(unittest.TestCase): assert not v1 or str(v1[0]) == self.highest_version, \ (v1, self.highest_version) assert len(v1) == self.number_of_versions, v1 + + def test_config_generation(self): + """Test _DSPGenerator.__init__(...)""" + if not self.highest_version : + return + + # Initialize 'static' variables + version_num, suite = msvs_parse_version(self.highest_version) + if version_num >= 10.0: + function_test = _GenerateV10DSP + elif version_num >= 7.0: + function_test = _GenerateV7DSP + else: + function_test = _GenerateV6DSP + + str_function_test = str(function_test.__init__) + dspfile = 'test.dsp' + source = 'test.cpp' + + # Create the cmdargs test list + list_variant = ['Debug|Win32','Release|Win32', + 'Debug|x64', 'Release|x64'] + list_cmdargs = ['debug=True target_arch=32', + '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(zip(list_variant, list_cmdargs)))] + + # 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) + + # 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 environment with final parameter dictionary + param_dict = dict(zip(('variant', 'runfile', 'buildtarget', 'outdir'), + [list(l) for l in zip(*param_configs)])) + param_dict['cmdargs'] = param_cmdargs + + # Hack to be able to run the test with a 'DummyEnv' + class _DummyEnv(DummyEnv): + def subst(self, string) : + return string + + env = _DummyEnv(param_dict) + env['MSVSSCONSCRIPT'] = '' + env['MSVS_VERSION'] = self.highest_version + + # Call function to test + genDSP = function_test(dspfile, source, env) + + # Check expected result + self.assertListEqual(genDSP.configs.keys(), expected_configs.keys()) + for key in genDSP.configs.keys(): + self.assertDictEqual(genDSP.configs[key].__dict__, expected_configs[key]) class msvs6aTestCase(msvsTestCase): """Test MSVS 6 Registry""" |