diff options
author | Joseph Brill <48932340+jcbrill@users.noreply.github.com> | 2022-07-17 23:43:09 (GMT) |
---|---|---|
committer | Joseph Brill <48932340+jcbrill@users.noreply.github.com> | 2022-07-17 23:43:09 (GMT) |
commit | d7664eb17d902d3540cfcdda226bd55e9c86cdf0 (patch) | |
tree | d11ed052f84242d45aa8ae6e3c70ccbc2e79a31d /test | |
parent | f4efe6bcd4694c34c391fe92422b059e3f737e1d (diff) | |
download | SCons-d7664eb17d902d3540cfcdda226bd55e9c86cdf0.zip SCons-d7664eb17d902d3540cfcdda226bd55e9c86cdf0.tar.gz SCons-d7664eb17d902d3540cfcdda226bd55e9c86cdf0.tar.bz2 |
Add msvc spectre libs test. Add library path checks to msvc sdk version and msvc toolset version tests.
Diffstat (limited to 'test')
-rw-r--r-- | test/MSVC/MSVC_SDK_VERSION.py | 14 | ||||
-rw-r--r-- | test/MSVC/MSVC_SPECTRE_LIBS.py | 153 | ||||
-rw-r--r-- | test/MSVC/MSVC_TOOLSET_VERSION.py | 23 |
3 files changed, 184 insertions, 6 deletions
diff --git a/test/MSVC/MSVC_SDK_VERSION.py b/test/MSVC/MSVC_SDK_VERSION.py index 4a3537b..1d9f0f4 100644 --- a/test/MSVC/MSVC_SDK_VERSION.py +++ b/test/MSVC/MSVC_SDK_VERSION.py @@ -84,8 +84,11 @@ if GE_VS2015_versions: test.write('SConstruct', textwrap.dedent( """ DefaultEnvironment(tools=[]) - env = Environment(MSVC_VERSION={}, MSVC_SDK_VERSION={}, tools=['msvc']) - """.format(repr(supported.msvc_version), repr(sdk_version)) + env = Environment(MSVC_VERSION={0}, MSVC_SDK_VERSION={1}, tools=['msvc']) + lib_path = env['ENV']['LIB'] + if '\\\\{2}\\\\' not in lib_path: + raise RuntimeError("{1} not found in lib_path " + lib_path) + """.format(repr(supported.msvc_version), repr(sdk_version), sdk_version) )) test.run(arguments='-Q -s', stdout='') @@ -93,8 +96,11 @@ if GE_VS2015_versions: test.write('SConstruct', textwrap.dedent( """ DefaultEnvironment(tools=[]) - env = Environment(MSVC_VERSION={}, MSVC_SCRIPT_ARGS={}, tools=['msvc']) - """.format(repr(supported.msvc_version), repr(sdk_version)) + env = Environment(MSVC_VERSION={0}, MSVC_SCRIPT_ARGS={1}, tools=['msvc']) + lib_path = env['ENV']['LIB'] + if '\\\\{2}\\\\' not in lib_path: + raise RuntimeError("{1} not found in lib_path " + lib_path) + """.format(repr(supported.msvc_version), repr(sdk_version), sdk_version) )) test.run(arguments='-Q -s', stdout='') diff --git a/test/MSVC/MSVC_SPECTRE_LIBS.py b/test/MSVC/MSVC_SPECTRE_LIBS.py new file mode 100644 index 0000000..d5e57c9 --- /dev/null +++ b/test/MSVC/MSVC_SPECTRE_LIBS.py @@ -0,0 +1,153 @@ +# MIT License +# +# Copyright The SCons Foundation +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +""" +Test the MSVC_SPECTRE_LIBS construction variable. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.skip_if_not_msvc() + +import textwrap + +from SCons.Tool.MSCommon.vc import get_installed_vcs_components +from SCons.Tool.MSCommon import msvc_toolset_versions_spectre + +installed_versions = get_installed_vcs_components() + +GE_VS2017_versions = [v for v in installed_versions if v.msvc_vernum >= 14.1] +LT_VS2017_versions = [v for v in installed_versions if v.msvc_vernum < 14.1] + +if GE_VS2017_versions: + # VS2017 and later for toolset argument + + for supported in GE_VS2017_versions: + + spectre_toolset_versions = msvc_toolset_versions_spectre(supported.msvc_version) + spectre_toolset_version = spectre_toolset_versions[0] if spectre_toolset_versions else None + + if spectre_toolset_version: + + # spectre libs using construction variable + test.write('SConstruct', textwrap.dedent( + """ + DefaultEnvironment(tools=[]) + env = Environment(MSVC_VERSION={}, MSVC_SPECTRE_LIBS=True, tools=['msvc']) + lib_path = env['ENV']['LIB'] + if '\\\\lib\\\\spectre\\\\' not in lib_path.lower(): + raise RuntimeError("'spectre' not found in lib_path " + lib_path) + """.format(repr(supported.msvc_version)) + )) + test.run(arguments='-Q -s', stdout='') + + # spectre libs using script argument + test.write('SConstruct', textwrap.dedent( + """ + DefaultEnvironment(tools=[]) + env = Environment(MSVC_VERSION={}, MSVC_SCRIPT_ARGS='-vcvars_spectre_libs=spectre', tools=['msvc']) + lib_path = env['ENV']['LIB'] + if '\\\\lib\\\\spectre\\\\' not in lib_path.lower(): + raise RuntimeError("'spectre' not found in lib_path " + lib_path) + """.format(repr(supported.msvc_version)) + )) + test.run(arguments='-Q -s', stdout='') + + # error construction variable and script argument + test.write('SConstruct', textwrap.dedent( + """ + DefaultEnvironment(tools=[]) + env = Environment(MSVC_VERSION={}, MSVC_SPECTRE_LIBS=True, MSVC_SCRIPT_ARGS='-vcvars_spectre_libs=spectre', tools=['msvc']) + """.format(repr(supported.msvc_version)) + )) + test.run(arguments='-Q -s', status=2, stderr=None) + expect = "MSVCArgumentError: multiple spectre declarations: MSVC_SPECTRE_LIBS=True and MSVC_SCRIPT_ARGS='-vcvars_spectre_libs=spectre':" + test.must_contain_all(test.stderr(), expect) + + else: + + # spectre libs using construction variable + test.write('SConstruct', textwrap.dedent( + """ + DefaultEnvironment(tools=[]) + env = Environment(MSVC_VERSION={}, MSVC_SPECTRE_LIBS=True, tools=['msvc']) + """.format(repr(supported.msvc_version)) + )) + test.run(arguments='-Q -s', status=2, stderr=None) + if not test.stderr().strip().startswith('MSVCSpectreLibsNotFound: Spectre libraries not found'): + test.fail_test() + + # spectre libs using script argument + test.write('SConstruct', textwrap.dedent( + """ + DefaultEnvironment(tools=[]) + env = Environment(MSVC_VERSION={}, MSVC_SCRIPT_ARGS='-vcvars_spectre_libs=spectre', MSVC_SCRIPTERROR_POLICY='error', tools=['msvc']) + """.format(repr(supported.msvc_version)) + )) + test.run(arguments='-Q -s', status=2, stderr=None) + if not test.stderr().strip().startswith('MSVCScriptExecutionError: vc script errors detected:'): + test.fail_test() + + # spectre libs using construction variable + test.write('SConstruct', textwrap.dedent( + """ + DefaultEnvironment(tools=[]) + env = Environment(MSVC_VERSION={}, MSVC_SPECTRE_LIBS=False, tools=['msvc']) + lib_path = env['ENV']['LIB'] + if '\\\\lib\\\\spectre\\\\' in lib_path.lower(): + raise RuntimeError("'spectre' found in lib_path " + lib_path) + """.format(repr(supported.msvc_version)) + )) + test.run(arguments='-Q -s', stdout='') + +if LT_VS2017_versions: + # VS2015 and earlier for toolset argument error + + for unsupported in LT_VS2017_versions: + + # must be VS2017 or later + test.write('SConstruct', textwrap.dedent( + """ + DefaultEnvironment(tools=[]) + env = Environment(MSVC_VERSION={}, MSVC_SPECTRE_LIBS=True, tools=['msvc']) + """.format(repr(unsupported.msvc_version)) + )) + test.run(arguments='-Q -s', status=2, stderr=None) + if not test.stderr().strip().startswith('MSVCArgumentError: MSVC_SPECTRE_LIBS (True) constraint violation:'): + test.fail_test() + + for disabled in (False, None): + + # ignore + test.write('SConstruct', textwrap.dedent( + """ + DefaultEnvironment(tools=[]) + env = Environment(MSVC_VERSION={}, MSVC_SPECTRE_LIBS={}, tools=['msvc']) + """.format(repr(unsupported.msvc_version), disabled) + )) + test.run(arguments='-Q -s', stdout='') + +test.pass_test() + diff --git a/test/MSVC/MSVC_TOOLSET_VERSION.py b/test/MSVC/MSVC_TOOLSET_VERSION.py index aa3c44c..b016147 100644 --- a/test/MSVC/MSVC_TOOLSET_VERSION.py +++ b/test/MSVC/MSVC_TOOLSET_VERSION.py @@ -56,15 +56,34 @@ if GE_VS2017_versions: toolset_sxs_version = toolset_sxs_versions[0] if toolset_sxs_versions else None if toolset_full_version: + + # toolset version using construction variable test.write('SConstruct', textwrap.dedent( """ DefaultEnvironment(tools=[]) - env = Environment(MSVC_VERSION={}, MSVC_TOOLSET_VERSION={}, tools=['msvc']) - """.format(repr(supported.msvc_version), repr(toolset_full_version)) + env = Environment(MSVC_VERSION={0}, MSVC_TOOLSET_VERSION={1}, tools=['msvc']) + lib_path = env['ENV']['LIB'] + if '\\\\{2}\\\\' not in lib_path: + raise RuntimeError("{1} not found in lib_path " + lib_path) + """.format(repr(supported.msvc_version), repr(toolset_full_version), toolset_full_version) + )) + test.run(arguments='-Q -s', stdout='') + + # toolset version using script argument + test.write('SConstruct', textwrap.dedent( + """ + DefaultEnvironment(tools=[]) + env = Environment(MSVC_VERSION={0}, MSVC_SCRIPT_ARGS='-vcvars_ver={1}', tools=['msvc']) + lib_path = env['ENV']['LIB'] + if '\\\\{1}\\\\' not in lib_path: + raise RuntimeError("'{1}' not found in lib_path " + lib_path) + """.format(repr(supported.msvc_version), toolset_full_version) )) test.run(arguments='-Q -s', stdout='') if toolset_sxs_version: + + # sxs toolset version using construction variable test.write('SConstruct', textwrap.dedent( """ DefaultEnvironment(tools=[]) |