tools: python: ignore instead of select flake8 rules
PR-URL: https://github.com/nodejs/node/pull/25614 Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This commit is contained in:
parent
a16a0fe962
commit
1fc4255221
2
.flake8
2
.flake8
@ -1,3 +1,3 @@
|
|||||||
[flake8]
|
[flake8]
|
||||||
exclude=.git,deps,lib,src,tools/gyp,tools/inspector_protocol,tools/pip,tools/v8_gypfiles/broken
|
exclude=.git,deps,lib,src,tools/gyp,tools/inspector_protocol,tools/pip,tools/v8_gypfiles/broken
|
||||||
select=E9,F63,F72,F82
|
ignore=E1,E2,E3,E4,E5,E7,W5,W6
|
||||||
|
@ -1110,7 +1110,7 @@ def configure_library(lib, output):
|
|||||||
output['libraries'] += [pkg_libpath]
|
output['libraries'] += [pkg_libpath]
|
||||||
|
|
||||||
default_libs = getattr(options, shared_lib + '_libname')
|
default_libs = getattr(options, shared_lib + '_libname')
|
||||||
default_libs = ['-l{0}'.format(lib) for lib in default_libs.split(',')]
|
default_libs = ['-l{0}'.format(l) for l in default_libs.split(',')]
|
||||||
|
|
||||||
if default_libs:
|
if default_libs:
|
||||||
output['libraries'] += default_libs
|
output['libraries'] += default_libs
|
||||||
|
@ -30,16 +30,7 @@ import test
|
|||||||
import os
|
import os
|
||||||
from os.path import join, exists, basename, isdir
|
from os.path import join, exists, basename, isdir
|
||||||
import re
|
import re
|
||||||
|
from functools import reduce
|
||||||
try:
|
|
||||||
reduce # Python 2
|
|
||||||
except NameError: # Python 3
|
|
||||||
from functools import reduce
|
|
||||||
|
|
||||||
try:
|
|
||||||
xrange # Python 2
|
|
||||||
except NameError:
|
|
||||||
xrange = range # Python 3
|
|
||||||
|
|
||||||
FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
|
FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
|
||||||
|
|
||||||
@ -82,13 +73,13 @@ class MessageTestCase(test.TestCase):
|
|||||||
print("expect=%d" % len(patterns))
|
print("expect=%d" % len(patterns))
|
||||||
print("actual=%d" % len(outlines))
|
print("actual=%d" % len(outlines))
|
||||||
print("patterns:")
|
print("patterns:")
|
||||||
for i in xrange(len(patterns)):
|
for i in range(len(patterns)):
|
||||||
print("pattern = %s" % patterns[i])
|
print("pattern = %s" % patterns[i])
|
||||||
print("outlines:")
|
print("outlines:")
|
||||||
for i in xrange(len(outlines)):
|
for i in range(len(outlines)):
|
||||||
print("outline = %s" % outlines[i])
|
print("outline = %s" % outlines[i])
|
||||||
return True
|
return True
|
||||||
for i in xrange(len(patterns)):
|
for i in range(len(patterns)):
|
||||||
if not re.match(patterns[i], outlines[i]):
|
if not re.match(patterns[i], outlines[i]):
|
||||||
print("match failed")
|
print("match failed")
|
||||||
print("line=%d" % i)
|
print("line=%d" % i)
|
||||||
@ -129,13 +120,13 @@ class MessageTestConfiguration(test.TestConfiguration):
|
|||||||
def ListTests(self, current_path, path, arch, mode):
|
def ListTests(self, current_path, path, arch, mode):
|
||||||
all_tests = [current_path + [t] for t in self.Ls(self.root)]
|
all_tests = [current_path + [t] for t in self.Ls(self.root)]
|
||||||
result = []
|
result = []
|
||||||
for test in all_tests:
|
for tst in all_tests:
|
||||||
if self.Contains(path, test):
|
if self.Contains(path, tst):
|
||||||
file_path = join(self.root, reduce(join, test[1:], ''))
|
file_path = join(self.root, reduce(join, tst[1:], ''))
|
||||||
output_path = file_path[:file_path.rfind('.')] + '.out'
|
output_path = file_path[:file_path.rfind('.')] + '.out'
|
||||||
if not exists(output_path):
|
if not exists(output_path):
|
||||||
raise Exception("Could not find %s" % output_path)
|
raise Exception("Could not find %s" % output_path)
|
||||||
result.append(MessageTestCase(test, file_path, output_path,
|
result.append(MessageTestCase(tst, file_path, output_path,
|
||||||
arch, mode, self.context, self))
|
arch, mode, self.context, self))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -32,34 +32,25 @@ import os
|
|||||||
from os.path import join, exists, basename, isdir
|
from os.path import join, exists, basename, isdir
|
||||||
import re
|
import re
|
||||||
import utils
|
import utils
|
||||||
|
from functools import reduce
|
||||||
try:
|
|
||||||
reduce # Python 2
|
|
||||||
except NameError: # Python 3
|
|
||||||
from functools import reduce
|
|
||||||
|
|
||||||
try:
|
|
||||||
xrange # Python 2
|
|
||||||
except NameError:
|
|
||||||
xrange = range # Python 3
|
|
||||||
|
|
||||||
FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
|
FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
|
||||||
|
|
||||||
class TTYTestCase(test.TestCase):
|
class TTYTestCase(test.TestCase):
|
||||||
|
|
||||||
def __init__(self, path, file, expected, input, arch, mode, context, config):
|
def __init__(self, path, file, expected, input_arg, arch, mode, context, config):
|
||||||
super(TTYTestCase, self).__init__(context, path, arch, mode)
|
super(TTYTestCase, self).__init__(context, path, arch, mode)
|
||||||
self.file = file
|
self.file = file
|
||||||
self.expected = expected
|
self.expected = expected
|
||||||
self.input = input
|
self.input = input_arg
|
||||||
self.config = config
|
self.config = config
|
||||||
self.arch = arch
|
self.arch = arch
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
|
|
||||||
def IgnoreLine(self, str):
|
def IgnoreLine(self, str_arg):
|
||||||
"""Ignore empty lines and valgrind output."""
|
"""Ignore empty lines and valgrind output."""
|
||||||
if not str.strip(): return True
|
if not str_arg.strip(): return True
|
||||||
else: return str.startswith('==') or str.startswith('**')
|
else: return str_arg.startswith('==') or str_arg.startswith('**')
|
||||||
|
|
||||||
def IsFailureOutput(self, output):
|
def IsFailureOutput(self, output):
|
||||||
f = open(self.expected)
|
f = open(self.expected)
|
||||||
@ -81,13 +72,13 @@ class TTYTestCase(test.TestCase):
|
|||||||
print("expect=%d" % len(patterns))
|
print("expect=%d" % len(patterns))
|
||||||
print("actual=%d" % len(outlines))
|
print("actual=%d" % len(outlines))
|
||||||
print("patterns:")
|
print("patterns:")
|
||||||
for i in xrange(len(patterns)):
|
for i in range(len(patterns)):
|
||||||
print("pattern = %s" % patterns[i])
|
print("pattern = %s" % patterns[i])
|
||||||
print("outlines:")
|
print("outlines:")
|
||||||
for i in xrange(len(outlines)):
|
for i in range(len(outlines)):
|
||||||
print("outline = %s" % outlines[i])
|
print("outline = %s" % outlines[i])
|
||||||
return True
|
return True
|
||||||
for i in xrange(len(patterns)):
|
for i in range(len(patterns)):
|
||||||
if not re.match(patterns[i], outlines[i]):
|
if not re.match(patterns[i], outlines[i]):
|
||||||
print("match failed")
|
print("match failed")
|
||||||
print("line=%d" % i)
|
print("line=%d" % i)
|
||||||
@ -117,16 +108,16 @@ class TTYTestCase(test.TestCase):
|
|||||||
+ open(self.expected).read())
|
+ open(self.expected).read())
|
||||||
|
|
||||||
def RunCommand(self, command, env):
|
def RunCommand(self, command, env):
|
||||||
input = None
|
input_arg = None
|
||||||
if self.input is not None and exists(self.input):
|
if self.input is not None and exists(self.input):
|
||||||
input = open(self.input).read()
|
input_arg = open(self.input).read()
|
||||||
full_command = self.context.processor(command)
|
full_command = self.context.processor(command)
|
||||||
output = test.Execute(full_command,
|
output = test.Execute(full_command,
|
||||||
self.context,
|
self.context,
|
||||||
self.context.GetTimeout(self.mode),
|
self.context.GetTimeout(self.mode),
|
||||||
env,
|
env,
|
||||||
faketty=True,
|
faketty=True,
|
||||||
input=input)
|
input=input_arg)
|
||||||
return test.TestOutput(self,
|
return test.TestOutput(self,
|
||||||
full_command,
|
full_command,
|
||||||
output,
|
output,
|
||||||
@ -148,15 +139,15 @@ class TTYTestConfiguration(test.TestConfiguration):
|
|||||||
print ("Skipping pseudo-tty tests, as pseudo terminals are not available"
|
print ("Skipping pseudo-tty tests, as pseudo terminals are not available"
|
||||||
" on Windows.")
|
" on Windows.")
|
||||||
return result
|
return result
|
||||||
for test in all_tests:
|
for tst in all_tests:
|
||||||
if self.Contains(path, test):
|
if self.Contains(path, tst):
|
||||||
file_prefix = join(self.root, reduce(join, test[1:], ""))
|
file_prefix = join(self.root, reduce(join, tst[1:], ""))
|
||||||
file_path = file_prefix + ".js"
|
file_path = file_prefix + ".js"
|
||||||
input_path = file_prefix + ".in"
|
input_path = file_prefix + ".in"
|
||||||
output_path = file_prefix + ".out"
|
output_path = file_prefix + ".out"
|
||||||
if not exists(output_path):
|
if not exists(output_path):
|
||||||
raise Exception("Could not find %s" % output_path)
|
raise Exception("Could not find %s" % output_path)
|
||||||
result.append(TTYTestCase(test, file_path, output_path,
|
result.append(TTYTestCase(tst, file_path, output_path,
|
||||||
input_path, arch, mode, self.context, self))
|
input_path, arch, mode, self.context, self))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -27,18 +27,12 @@
|
|||||||
|
|
||||||
import test
|
import test
|
||||||
import os
|
import os
|
||||||
from os.path import join, dirname, exists, splitext
|
|
||||||
import re
|
import re
|
||||||
import ast
|
from functools import reduce
|
||||||
|
|
||||||
try:
|
|
||||||
reduce
|
|
||||||
except NameError:
|
|
||||||
from functools import reduce
|
|
||||||
|
|
||||||
|
|
||||||
FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
|
FLAGS_PATTERN = re.compile(r"//\s+Flags:(.*)")
|
||||||
|
LS_RE = re.compile(r'^test-.*\.m?js$')
|
||||||
|
|
||||||
class SimpleTestCase(test.TestCase):
|
class SimpleTestCase(test.TestCase):
|
||||||
|
|
||||||
@ -107,15 +101,15 @@ class SimpleTestConfiguration(test.TestConfiguration):
|
|||||||
self.additional_flags = []
|
self.additional_flags = []
|
||||||
|
|
||||||
def Ls(self, path):
|
def Ls(self, path):
|
||||||
return [f for f in os.listdir(path) if re.match('^test-.*\.m?js$', f)]
|
return [f for f in os.listdir(path) if LS_RE.match(f)]
|
||||||
|
|
||||||
def ListTests(self, current_path, path, arch, mode):
|
def ListTests(self, current_path, path, arch, mode):
|
||||||
all_tests = [current_path + [t] for t in self.Ls(join(self.root))]
|
all_tests = [current_path + [t] for t in self.Ls(os.path.join(self.root))]
|
||||||
result = []
|
result = []
|
||||||
for test in all_tests:
|
for tst in all_tests:
|
||||||
if self.Contains(path, test):
|
if self.Contains(path, tst):
|
||||||
file_path = join(self.root, reduce(join, test[1:], ""))
|
file_path = os.path.join(self.root, reduce(os.path.join, tst[1:], ""))
|
||||||
test_name = test[:-1] + [splitext(test[-1])[0]]
|
test_name = tst[:-1] + [os.path.splitext(tst[-1])[0]]
|
||||||
result.append(SimpleTestCase(test_name, file_path, arch, mode,
|
result.append(SimpleTestCase(test_name, file_path, arch, mode,
|
||||||
self.context, self, self.additional_flags))
|
self.context, self, self.additional_flags))
|
||||||
return result
|
return result
|
||||||
@ -131,8 +125,8 @@ class ParallelTestConfiguration(SimpleTestConfiguration):
|
|||||||
def ListTests(self, current_path, path, arch, mode):
|
def ListTests(self, current_path, path, arch, mode):
|
||||||
result = super(ParallelTestConfiguration, self).ListTests(
|
result = super(ParallelTestConfiguration, self).ListTests(
|
||||||
current_path, path, arch, mode)
|
current_path, path, arch, mode)
|
||||||
for test in result:
|
for tst in result:
|
||||||
test.parallel = True
|
tst.parallel = True
|
||||||
return result
|
return result
|
||||||
|
|
||||||
class AddonTestConfiguration(SimpleTestConfiguration):
|
class AddonTestConfiguration(SimpleTestConfiguration):
|
||||||
@ -145,20 +139,20 @@ class AddonTestConfiguration(SimpleTestConfiguration):
|
|||||||
|
|
||||||
result = []
|
result = []
|
||||||
for subpath in os.listdir(path):
|
for subpath in os.listdir(path):
|
||||||
if os.path.isdir(join(path, subpath)):
|
if os.path.isdir(os.path.join(path, subpath)):
|
||||||
for f in os.listdir(join(path, subpath)):
|
for f in os.listdir(os.path.join(path, subpath)):
|
||||||
if SelectTest(f):
|
if SelectTest(f):
|
||||||
result.append([subpath, f[:-3]])
|
result.append([subpath, f[:-3]])
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def ListTests(self, current_path, path, arch, mode):
|
def ListTests(self, current_path, path, arch, mode):
|
||||||
all_tests = [current_path + t for t in self.Ls(join(self.root))]
|
all_tests = [current_path + t for t in self.Ls(os.path.join(self.root))]
|
||||||
result = []
|
result = []
|
||||||
for test in all_tests:
|
for tst in all_tests:
|
||||||
if self.Contains(path, test):
|
if self.Contains(path, tst):
|
||||||
file_path = join(self.root, reduce(join, test[1:], "") + ".js")
|
file_path = os.path.join(self.root, reduce(os.path.join, tst[1:], "") + ".js")
|
||||||
result.append(
|
result.append(
|
||||||
SimpleTestCase(test, file_path, arch, mode, self.context, self, self.additional_flags))
|
SimpleTestCase(tst, file_path, arch, mode, self.context, self, self.additional_flags))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
class AbortTestConfiguration(SimpleTestConfiguration):
|
class AbortTestConfiguration(SimpleTestConfiguration):
|
||||||
@ -169,6 +163,6 @@ class AbortTestConfiguration(SimpleTestConfiguration):
|
|||||||
def ListTests(self, current_path, path, arch, mode):
|
def ListTests(self, current_path, path, arch, mode):
|
||||||
result = super(AbortTestConfiguration, self).ListTests(
|
result = super(AbortTestConfiguration, self).ListTests(
|
||||||
current_path, path, arch, mode)
|
current_path, path, arch, mode)
|
||||||
for test in result:
|
for tst in result:
|
||||||
test.disable_core_files = True
|
tst.disable_core_files = True
|
||||||
return result
|
return result
|
||||||
|
@ -2,6 +2,7 @@ from __future__ import print_function
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
def get_version():
|
def get_version():
|
||||||
node_version_h = os.path.join(
|
node_version_h = os.path.join(
|
||||||
os.path.dirname(__file__),
|
os.path.dirname(__file__),
|
||||||
@ -17,8 +18,9 @@ def get_version():
|
|||||||
if re.match(regex, line):
|
if re.match(regex, line):
|
||||||
major = line.split()[2]
|
major = line.split()[2]
|
||||||
return major
|
return major
|
||||||
|
|
||||||
raise Exception('Could not find pattern matching %s' % regex)
|
raise Exception('Could not find pattern matching %s' % regex)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print(get_version())
|
print(get_version())
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import ast
|
import ast
|
||||||
import errno
|
import errno
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
from getmoduleversion import get_version
|
|
||||||
|
|
||||||
# set at init time
|
# set at init time
|
||||||
node_prefix = '/usr/local' # PREFIX variable from Makefile
|
node_prefix = '/usr/local' # PREFIX variable from Makefile
|
||||||
install_path = None # base target directory (DESTDIR + PREFIX from Makefile)
|
install_path = '' # base target directory (DESTDIR + PREFIX from Makefile)
|
||||||
target_defaults = None
|
target_defaults = None
|
||||||
variables = None
|
variables = None
|
||||||
|
|
||||||
@ -101,7 +100,7 @@ def npm_files(action):
|
|||||||
elif action == install:
|
elif action == install:
|
||||||
try_symlink('../lib/node_modules/npm/bin/npm-cli.js', link_path)
|
try_symlink('../lib/node_modules/npm/bin/npm-cli.js', link_path)
|
||||||
else:
|
else:
|
||||||
assert(0) # unhandled action type
|
assert 0 # unhandled action type
|
||||||
|
|
||||||
# create/remove symlink
|
# create/remove symlink
|
||||||
link_path = abspath(install_path, 'bin/npx')
|
link_path = abspath(install_path, 'bin/npx')
|
||||||
@ -110,15 +109,15 @@ def npm_files(action):
|
|||||||
elif action == install:
|
elif action == install:
|
||||||
try_symlink('../lib/node_modules/npm/bin/npx-cli.js', link_path)
|
try_symlink('../lib/node_modules/npm/bin/npx-cli.js', link_path)
|
||||||
else:
|
else:
|
||||||
assert(0) # unhandled action type
|
assert 0 # unhandled action type
|
||||||
|
|
||||||
def subdir_files(path, dest, action):
|
def subdir_files(path, dest, action):
|
||||||
ret = {}
|
ret = {}
|
||||||
for dirpath, dirnames, filenames in os.walk(path):
|
for dirpath, dirnames, filenames in os.walk(path):
|
||||||
files = [dirpath + '/' + f for f in filenames if f.endswith('.h')]
|
files_in_path = [dirpath + '/' + f for f in filenames if f.endswith('.h')]
|
||||||
ret[dest + dirpath.replace(path, '')] = files
|
ret[dest + dirpath.replace(path, '')] = files_in_path
|
||||||
for subdir, files in ret.items():
|
for subdir, files_in_path in ret.items():
|
||||||
action(files, subdir + '/')
|
action(files_in_path, subdir + '/')
|
||||||
|
|
||||||
def files(action):
|
def files(action):
|
||||||
is_windows = sys.platform == 'win32'
|
is_windows = sys.platform == 'win32'
|
||||||
@ -162,13 +161,13 @@ def files(action):
|
|||||||
headers(action)
|
headers(action)
|
||||||
|
|
||||||
def headers(action):
|
def headers(action):
|
||||||
def ignore_inspector_headers(files, dest):
|
def ignore_inspector_headers(files_arg, dest):
|
||||||
inspector_headers = [
|
inspector_headers = [
|
||||||
'deps/v8/include/v8-inspector.h',
|
'deps/v8/include/v8-inspector.h',
|
||||||
'deps/v8/include/v8-inspector-protocol.h'
|
'deps/v8/include/v8-inspector-protocol.h'
|
||||||
]
|
]
|
||||||
files = [name for name in files if name not in inspector_headers]
|
files_arg = [name for name in files_arg if name not in inspector_headers]
|
||||||
action(files, dest)
|
action(files_arg, dest)
|
||||||
|
|
||||||
action([
|
action([
|
||||||
'common.gypi',
|
'common.gypi',
|
||||||
|
@ -34,17 +34,10 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import string
|
|
||||||
import hashlib
|
|
||||||
|
|
||||||
try:
|
|
||||||
xrange # Python 2
|
|
||||||
except NameError:
|
|
||||||
xrange = range # Python 3
|
|
||||||
|
|
||||||
|
|
||||||
def ToCArray(elements, step=10):
|
def ToCArray(elements, step=10):
|
||||||
slices = (elements[i:i+step] for i in xrange(0, len(elements), step))
|
slices = (elements[i:i+step] for i in range(0, len(elements), step))
|
||||||
slices = map(lambda s: ','.join(str(x) for x in s), slices)
|
slices = map(lambda s: ','.join(str(x) for x in s), slices)
|
||||||
return ',\n'.join(slices)
|
return ',\n'.join(slices)
|
||||||
|
|
||||||
@ -160,14 +153,14 @@ def ReadMacros(lines):
|
|||||||
macro_match = MACRO_PATTERN.match(line)
|
macro_match = MACRO_PATTERN.match(line)
|
||||||
if macro_match:
|
if macro_match:
|
||||||
name = macro_match.group(1)
|
name = macro_match.group(1)
|
||||||
args = map(string.strip, macro_match.group(2).split(','))
|
args = [s.strip() for s in macro_match.group(2).split(',')]
|
||||||
body = macro_match.group(3).strip()
|
body = macro_match.group(3).strip()
|
||||||
macros[name] = TextMacro(args, body)
|
macros[name] = TextMacro(args, body)
|
||||||
else:
|
else:
|
||||||
python_match = PYTHON_MACRO_PATTERN.match(line)
|
python_match = PYTHON_MACRO_PATTERN.match(line)
|
||||||
if python_match:
|
if python_match:
|
||||||
name = python_match.group(1)
|
name = python_match.group(1)
|
||||||
args = map(string.strip, python_match.group(2).split(','))
|
args = [s.strip() for s in python_match.group(2).split(',')]
|
||||||
body = python_match.group(3).strip()
|
body = python_match.group(3).strip()
|
||||||
fun = eval("lambda " + ",".join(args) + ': ' + body)
|
fun = eval("lambda " + ",".join(args) + ': ' + body)
|
||||||
macros[name] = PythonMacro(args, fun)
|
macros[name] = PythonMacro(args, fun)
|
||||||
@ -238,7 +231,7 @@ def JS2C(source, target):
|
|||||||
# Treat non-ASCII as UTF-8 and convert it to UTF-16.
|
# Treat non-ASCII as UTF-8 and convert it to UTF-16.
|
||||||
if any(ord(c) > 127 for c in source):
|
if any(ord(c) > 127 for c in source):
|
||||||
source = map(ord, source.decode('utf-8').encode('utf-16be'))
|
source = map(ord, source.decode('utf-8').encode('utf-16be'))
|
||||||
source = [source[i] * 256 + source[i+1] for i in xrange(0, len(source), 2)]
|
source = [source[i] * 256 + source[i+1] for i in range(0, len(source), 2)]
|
||||||
source = ToCArray(source)
|
source = ToCArray(source)
|
||||||
return TWO_BYTE_STRING.format(var=var, data=source)
|
return TWO_BYTE_STRING.format(var=var, data=source)
|
||||||
else:
|
else:
|
||||||
|
@ -52,21 +52,7 @@ try:
|
|||||||
except ImportError:
|
except ImportError:
|
||||||
from Queue import Queue, Empty # Python 2
|
from Queue import Queue, Empty # Python 2
|
||||||
|
|
||||||
try:
|
from functools import reduce
|
||||||
cmp # Python 2
|
|
||||||
except NameError:
|
|
||||||
def cmp(x, y): # Python 3
|
|
||||||
return (x > y) - (x < y)
|
|
||||||
|
|
||||||
try:
|
|
||||||
reduce # Python 2
|
|
||||||
except NameError: # Python 3
|
|
||||||
from functools import reduce
|
|
||||||
|
|
||||||
try:
|
|
||||||
xrange # Python 2
|
|
||||||
except NameError:
|
|
||||||
xrange = range # Python 3
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from urllib.parse import unquote # Python 3
|
from urllib.parse import unquote # Python 3
|
||||||
@ -135,9 +121,9 @@ class ProgressIndicator(object):
|
|||||||
for thread in threads:
|
for thread in threads:
|
||||||
# Use a timeout so that signals (ctrl-c) will be processed.
|
# Use a timeout so that signals (ctrl-c) will be processed.
|
||||||
thread.join(timeout=10000000)
|
thread.join(timeout=10000000)
|
||||||
except (KeyboardInterrupt, SystemExit) as e:
|
except (KeyboardInterrupt, SystemExit):
|
||||||
self.shutdown_event.set()
|
self.shutdown_event.set()
|
||||||
except Exception as e:
|
except Exception:
|
||||||
# If there's an exception we schedule an interruption for any
|
# If there's an exception we schedule an interruption for any
|
||||||
# remaining threads.
|
# remaining threads.
|
||||||
self.shutdown_event.set()
|
self.shutdown_event.set()
|
||||||
@ -174,7 +160,7 @@ class ProgressIndicator(object):
|
|||||||
output = case.Run()
|
output = case.Run()
|
||||||
output.diagnostic.append('ECONNREFUSED received, test retried')
|
output.diagnostic.append('ECONNREFUSED received, test retried')
|
||||||
case.duration = (datetime.now() - start)
|
case.duration = (datetime.now() - start)
|
||||||
except IOError as e:
|
except IOError:
|
||||||
return
|
return
|
||||||
if self.shutdown_event.is_set():
|
if self.shutdown_event.is_set():
|
||||||
return
|
return
|
||||||
@ -383,9 +369,10 @@ class DeoptsCheckProgressIndicator(SimpleProgressIndicator):
|
|||||||
stdout = output.output.stdout.strip()
|
stdout = output.output.stdout.strip()
|
||||||
printed_file = False
|
printed_file = False
|
||||||
for line in stdout.splitlines():
|
for line in stdout.splitlines():
|
||||||
if (line.startswith("[aborted optimiz") or \
|
if (
|
||||||
line.startswith("[disabled optimiz")) and \
|
(line.startswith("[aborted optimiz") or line.startswith("[disabled optimiz")) and
|
||||||
("because:" in line or "reason:" in line):
|
("because:" in line or "reason:" in line)
|
||||||
|
):
|
||||||
if not printed_file:
|
if not printed_file:
|
||||||
printed_file = True
|
printed_file = True
|
||||||
print('==== %s ====' % command)
|
print('==== %s ====' % command)
|
||||||
@ -522,9 +509,6 @@ class TestCase(object):
|
|||||||
def IsNegative(self):
|
def IsNegative(self):
|
||||||
return self.context.expect_fail
|
return self.context.expect_fail
|
||||||
|
|
||||||
def CompareTime(self, other):
|
|
||||||
return cmp(other.duration, self.duration)
|
|
||||||
|
|
||||||
def DidFail(self, output):
|
def DidFail(self, output):
|
||||||
if output.failed is None:
|
if output.failed is None:
|
||||||
output.failed = self.IsFailureOutput(output)
|
output.failed = self.IsFailureOutput(output)
|
||||||
@ -597,7 +581,7 @@ class TestOutput(object):
|
|||||||
return self.output.exit_code < 0
|
return self.output.exit_code < 0
|
||||||
|
|
||||||
def HasTimedOut(self):
|
def HasTimedOut(self):
|
||||||
return self.output.timed_out;
|
return self.output.timed_out
|
||||||
|
|
||||||
def HasFailed(self):
|
def HasFailed(self):
|
||||||
execution_failed = self.test.DidFail(self.output)
|
execution_failed = self.test.DidFail(self.output)
|
||||||
@ -731,7 +715,9 @@ def CheckedUnlink(name):
|
|||||||
PrintError("os.unlink() " + str(e))
|
PrintError("os.unlink() " + str(e))
|
||||||
break
|
break
|
||||||
|
|
||||||
def Execute(args, context, timeout=None, env={}, faketty=False, disable_core_files=False, input=None):
|
def Execute(args, context, timeout=None, env=None, faketty=False, disable_core_files=False, input=None):
|
||||||
|
if env is None:
|
||||||
|
env = {}
|
||||||
if faketty:
|
if faketty:
|
||||||
import pty
|
import pty
|
||||||
(out_master, fd_out) = pty.openpty()
|
(out_master, fd_out) = pty.openpty()
|
||||||
@ -897,7 +883,7 @@ class LiteralTestSuite(TestSuite):
|
|||||||
if not name or name.match(test_name):
|
if not name or name.match(test_name):
|
||||||
full_path = current_path + [test_name]
|
full_path = current_path + [test_name]
|
||||||
test.AddTestsToList(result, full_path, path, context, arch, mode)
|
test.AddTestsToList(result, full_path, path, context, arch, mode)
|
||||||
result.sort(cmp=lambda a, b: cmp(a.GetName(), b.GetName()))
|
result.sort(key=lambda x: x.GetName())
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def GetTestStatus(self, context, sections, defs):
|
def GetTestStatus(self, context, sections, defs):
|
||||||
@ -1283,7 +1269,7 @@ class Rule(object):
|
|||||||
HEADER_PATTERN = re.compile(r'\[([^]]+)\]')
|
HEADER_PATTERN = re.compile(r'\[([^]]+)\]')
|
||||||
RULE_PATTERN = re.compile(r'\s*([^: ]*)\s*:(.*)')
|
RULE_PATTERN = re.compile(r'\s*([^: ]*)\s*:(.*)')
|
||||||
DEF_PATTERN = re.compile(r'^def\s*(\w+)\s*=(.*)$')
|
DEF_PATTERN = re.compile(r'^def\s*(\w+)\s*=(.*)$')
|
||||||
PREFIX_PATTERN = re.compile(r'^\s*prefix\s+([\w\_\.\-\/]+)$')
|
PREFIX_PATTERN = re.compile(r'^\s*prefix\s+([\w_.\-/]+)$')
|
||||||
|
|
||||||
|
|
||||||
def ReadConfigurationInto(path, sections, defs):
|
def ReadConfigurationInto(path, sections, defs):
|
||||||
@ -1470,9 +1456,9 @@ class Pattern(object):
|
|||||||
return self.pattern
|
return self.pattern
|
||||||
|
|
||||||
|
|
||||||
def SplitPath(s):
|
def SplitPath(path_arg):
|
||||||
stripped = [ c.strip() for c in s.split('/') ]
|
stripped = [c.strip() for c in path_arg.split('/')]
|
||||||
return [ Pattern(s) for s in stripped if len(s) > 0 ]
|
return [Pattern(s) for s in stripped if len(s) > 0]
|
||||||
|
|
||||||
def NormalizePath(path, prefix='test/'):
|
def NormalizePath(path, prefix='test/'):
|
||||||
# strip the extra path information of the specified test
|
# strip the extra path information of the specified test
|
||||||
@ -1753,7 +1739,7 @@ def Main():
|
|||||||
print()
|
print()
|
||||||
sys.stderr.write("--- Total time: %s ---\n" % FormatTime(duration))
|
sys.stderr.write("--- Total time: %s ---\n" % FormatTime(duration))
|
||||||
timed_tests = [ t for t in cases_to_run if not t.duration is None ]
|
timed_tests = [ t for t in cases_to_run if not t.duration is None ]
|
||||||
timed_tests.sort(lambda a, b: a.CompareTime(b))
|
timed_tests.sort(key=lambda x: x.duration)
|
||||||
for i, entry in enumerate(timed_tests[:20], start=1):
|
for i, entry in enumerate(timed_tests[:20], start=1):
|
||||||
t = FormatTimedelta(entry.duration)
|
t = FormatTimedelta(entry.duration)
|
||||||
sys.stderr.write("%4i (%s) %s\n" % (i, t, entry.GetLabel()))
|
sys.stderr.write("%4i (%s) %s\n" % (i, t, entry.GetLabel()))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user