diff --git a/test/generator-output/gyptest-symlink.py b/test/generator-output/gyptest-symlink.py index 8b29b348..d7fe0583 100755 --- a/test/generator-output/gyptest-symlink.py +++ b/test/generator-output/gyptest-symlink.py @@ -12,10 +12,12 @@ import TestGyp import os +import sys test = TestGyp.TestGyp() -if not hasattr(os, 'symlink'): - test.skip_test('Missing os.symlink -- skipping test.\n') +if not hasattr(os, 'symlink') or sys.platform == 'win32': + # Python3 on windows has symlink but it doesn't work reliably. + test.skip_test('Missing or bad os.symlink -- skipping test.\n') test.writable(test.workpath('src'), False) diff --git a/test/lib/TestGyp.py b/test/lib/TestGyp.py index bbeca6aa..083fdc41 100644 --- a/test/lib/TestGyp.py +++ b/test/lib/TestGyp.py @@ -648,7 +648,8 @@ def GetDefaultKeychainPath(): # Format is: # $ security default-keychain # "/Some/Path/To/default.keychain" - path = subprocess.check_output(['security', 'default-keychain']).strip() + path = subprocess.check_output(['security', 'default-keychain']).decode( + 'utf-8', 'ignore').strip() return path[1:-1] def FindMSBuildInstallation(msvs_version = 'auto'): @@ -743,13 +744,15 @@ def FindVisualStudioInstallation(): args1 = ['reg', 'query', 'HKLM\Software\Microsoft\VisualStudio\SxS\VS7', '/v', '15.0', '/reg:32'] - build_tool = subprocess.check_output(args1)\ - .strip().split('\r\n').pop().split(' ').pop() + build_tool = subprocess.check_output(args1).decode( + 'utf-8', 'ignore').strip().split(b'\r\n').pop().split(b' ').pop() + build_tool = build_tool.decode('utf-8') if build_tool: args2 = ['cmd.exe', '/d', '/c', 'cd', '/d', build_tool, '&', 'dir', '/b', '/s', 'msbuild.exe'] - msbuild_exes = subprocess.check_output(args2).strip().split('\r\n') + msbuild_exes = subprocess.check_output(args2).strip().split(b'\r\n') + msbuild_exes = [m.decode('utf-8') for m in msbuild_exes] if len(msbuild_exes): msbuild_Path = os.path.join(build_tool, msbuild_exes[0]) if os.path.exists(msbuild_Path): @@ -819,7 +822,7 @@ def run_dumpbin(self, *dumpbin_args): arguments = [cmd, '/c', self.vsvars_path, '&&', 'dumpbin'] arguments.extend(dumpbin_args) proc = subprocess.Popen(arguments, stdout=subprocess.PIPE) - output = proc.communicate()[0] + output = proc.communicate()[0].decode('utf-8', 'ignore') assert not proc.returncode return output diff --git a/test/lib/TestWin.py b/test/lib/TestWin.py index 2234253a..ef676db1 100644 --- a/test/lib/TestWin.py +++ b/test/lib/TestWin.py @@ -37,7 +37,7 @@ def _QueryBase(self, sysdir, key, value): p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # Get the stdout from reg.exe, reading to the end so p.returncode is valid # Note that the error text may be in [1] in some cases - text = p.communicate()[0] + text = p.communicate()[0].decode('utf-8', 'ignore') # Check return code from reg.exe; officially 0==success and 1==error if p.returncode: return None diff --git a/test/relative/gyptest-default.py b/test/relative/gyptest-default.py index 2d657aa6..685cdfd7 100755 --- a/test/relative/gyptest-default.py +++ b/test/relative/gyptest-default.py @@ -16,7 +16,7 @@ # Run from down in foo. test.run_gyp('a.gyp', chdir='foo/a') sln = test.workpath('foo/a/a.sln') -sln_data = open(sln, 'rb').read() +sln_data = open(sln, 'rb').read().decode('utf-8', 'ignore') vcproj = sln_data.count('b.vcproj') vcxproj = sln_data.count('b.vcxproj') if (vcproj, vcxproj) not in [(1, 0), (0, 1)]: diff --git a/test/win/gyptest-link-embed-manifest.py b/test/win/gyptest-link-embed-manifest.py index 5b9d2c25..0e2b628b 100644 --- a/test/win/gyptest-link-embed-manifest.py +++ b/test/win/gyptest-link-embed-manifest.py @@ -40,7 +40,8 @@ def extract_manifest(path, resource_name): Returns None is there is no such manifest.""" with LoadLibrary(path) as handle: try: - return win32api.LoadResource(handle, RT_MANIFEST, resource_name) + return win32api.LoadResource( + handle, RT_MANIFEST, resource_name).decode('utf-8', 'ignore') except pywintypes.error as error: if error.args[0] == winerror.ERROR_RESOURCE_DATA_NOT_FOUND: return None diff --git a/test/win/gyptest-link-enable-uac.py b/test/win/gyptest-link-enable-uac.py index 131e07ec..0ddbde5f 100644 --- a/test/win/gyptest-link-enable-uac.py +++ b/test/win/gyptest-link-enable-uac.py @@ -67,9 +67,18 @@ def extract_manifest(path, resource_name): execution_level = manifest.getElementsByTagName('requestedExecutionLevel') test.fail_test(len(execution_level) != 1) execution_level = execution_level[0].attributes + + def _has_key(node, key): + # 'in' doesn't work with the NamedNodeMap interface in Python2, + # but 'has_key' was removed from it in Python3, so we need to + # shim things :(. + if hasattr(node, 'has_key'): + return node.has_key(key) + return key in node + test.fail_test(not ( - execution_level.has_key('level') and - execution_level.has_key('uiAccess') and + _has_key(execution_level, 'level') and + _has_key(execution_level, 'uiAccess') and execution_level['level'].nodeValue == 'asInvoker' and execution_level['uiAccess'].nodeValue == 'false')) @@ -87,8 +96,8 @@ def extract_manifest(path, resource_name): test.fail_test(len(execution_level) != 1) execution_level = execution_level[0].attributes test.fail_test(not ( - execution_level.has_key('level') and - execution_level.has_key('uiAccess') and + _has_key(execution_level, 'level') and + _has_key(execution_level, 'uiAccess') and execution_level['level'].nodeValue == 'requireAdministrator' and execution_level['uiAccess'].nodeValue == 'true')) diff --git a/test/win/gyptest-link-update-manifest.py b/test/win/gyptest-link-update-manifest.py index 693db270..7bad1eca 100644 --- a/test/win/gyptest-link-update-manifest.py +++ b/test/win/gyptest-link-update-manifest.py @@ -39,7 +39,8 @@ def extract_manifest(path, resource_name): Returns None is there is no such manifest.""" with LoadLibrary(path) as handle: try: - return win32api.LoadResource(handle, RT_MANIFEST, resource_name) + return win32api.LoadResource( + handle, RT_MANIFEST, resource_name).decode('utf-8', 'ignore') except pywintypes.error as error: if error.args[0] == winerror.ERROR_RESOURCE_DATA_NOT_FOUND: return None