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.
25 Test windows registry functions for Microsoft Visual C/C++.
31 from SCons
.Tool
.MSCommon
.MSVC
import Config
32 from SCons
.Tool
.MSCommon
.MSVC
import Registry
34 @unittest.skipUnless(sys
.platform
.startswith("win"), "requires Windows")
35 class RegistryTests(unittest
.TestCase
):
40 def setUpClass(cls
) -> None:
41 cls
._sdk
_versions
= []
43 for vs_def
in Config
.VISUALSTUDIO_DEFINITION_LIST
:
44 if not vs_def
.vc_sdk_versions
:
46 for sdk_version
in vs_def
.vc_sdk_versions
:
47 if sdk_version
in sdk_seen
:
49 sdk_seen
.add(sdk_version
)
50 cls
._sdk
_versions
.append(sdk_version
)
52 def setUp(self
) -> None:
53 self
.sdk_versions
= self
.__class
__._sdk
_versions
55 def test_sdk_query_paths(self
) -> None:
56 for sdk_version
in self
.sdk_versions
:
57 _
= Registry
.sdk_query_paths(sdk_version
)
59 def test_vstudio_sxs_vc7(self
) -> None:
60 suffix
= Registry
.vstudio_sxs_vc7('14.0')
61 _
= Registry
.microsoft_query_paths(suffix
)
63 def test_microsoft_query_keys(self
) -> None:
64 val
= r
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment'
65 for suffix
in ['Temp', 'Tmp']:
66 _
= Registry
.registry_query_path(Registry
.HKEY_LOCAL_MACHINE
, val
, suffix
, expand
=True)
67 _
= Registry
.registry_query_path(Registry
.HKEY_LOCAL_MACHINE
, val
, suffix
, expand
=False)
69 def test_registry_query_path(self
) -> None:
70 # need a better test for when VS2015 is no longer installed
71 for component_reg
in ('enterprise', 'professional', 'community'):
72 suffix
= Registry
.devdiv_vs_servicing_component('14.0', component_reg
)
73 rval
= Registry
.microsoft_query_keys(suffix
, component_reg
)
77 def test_windows_kit_query_paths(self
) -> None:
78 for sdk_version
in self
.sdk_versions
:
79 _
= Registry
.windows_kit_query_paths(sdk_version
)
81 if __name__
== "__main__":