Bug 1292439 - Use a fake _winreg module during tests. r?chmanchester
While on automation, there is no MSVC to find through the registry, the
story is different on local builds, and that can interfere with tests.
Specifically, it breaks test_toolchain_configure.py because it's not
expecting the registry to provide a valid path to an almost valid
compiler, and then fails because that compiler doesn't match the
expected target CPU.
And because build/moz.configure/toolchain.configure also affects the PATH
environment variable, subsequent tests end up failing even earlier
because executing the empty mozconfig with the modified environment then
fails because of the unicode value of PATH.
This change implements enough of _winreg to make the get_registry_values
function return nothing.
--- a/python/mozbuild/mozbuild/test/configure/common.py
+++ b/python/mozbuild/mozbuild/test/configure/common.py
@@ -140,16 +140,25 @@ class ConfigureTestSandbox(ConfigureSand
create_unicode_buffer=self.create_unicode_buffer,
windll=ReadOnlyNamespace(
kernel32=ReadOnlyNamespace(
GetShortPathNameW=CTypesFunc(self.GetShortPathNameW),
)
),
)
+ if what == '_winreg':
+ def OpenKey(*args, **kwargs):
+ raise WindowsError()
+
+ return ReadOnlyNamespace(
+ HKEY_LOCAL_MACHINE=0,
+ OpenKey=OpenKey,
+ )
+
return super(ConfigureTestSandbox, self)._get_one_import(what)
def create_unicode_buffer(self, *args, **kwargs):
class Buffer(object):
def __init__(self):
self.value = ''
return Buffer()