forked from mirrors/gecko-dev
bug 1463425 - autopep8 on config/ r=gps
MozReview-Commit-ID: EaTAhH2CAee --HG-- extra : rebase_source : f278cd9fc6e8f9db720c1430121ba91e0417c9b9
This commit is contained in:
parent
dcfef841a7
commit
3d085810e5
20 changed files with 814 additions and 720 deletions
|
|
@ -15,6 +15,7 @@ class ZipFile(zipfile.ZipFile):
|
|||
Subclassing zipfile.ZipFile to allow for overwriting of existing
|
||||
entries, though only for writestr, not for write.
|
||||
"""
|
||||
|
||||
def __init__(self, file, mode="r", compression=zipfile.ZIP_STORED,
|
||||
lock=False):
|
||||
if lock:
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ import sys
|
|||
from mozversioncontrol import get_repository_from_env
|
||||
|
||||
|
||||
scriptname = os.path.basename(__file__);
|
||||
scriptname = os.path.basename(__file__)
|
||||
expected_encoding = 'ascii'
|
||||
|
||||
# The following files don't define JSErrorFormatString.
|
||||
|
|
@ -26,13 +26,16 @@ ignore_files = [
|
|||
'js/xpconnect/src/xpc.msg',
|
||||
]
|
||||
|
||||
|
||||
def log_pass(filename, text):
|
||||
print('TEST-PASS | {} | {} | {}'.format(scriptname, filename, text))
|
||||
|
||||
|
||||
def log_fail(filename, text):
|
||||
print('TEST-UNEXPECTED-FAIL | {} | {} | {}'.format(scriptname, filename,
|
||||
text))
|
||||
|
||||
|
||||
def check_single_file(filename):
|
||||
with open(filename, 'rb') as f:
|
||||
data = f.read()
|
||||
|
|
@ -44,6 +47,7 @@ def check_single_file(filename):
|
|||
log_pass(filename, 'ok')
|
||||
return True
|
||||
|
||||
|
||||
def check_files():
|
||||
result = True
|
||||
|
||||
|
|
@ -58,11 +62,13 @@ def check_files():
|
|||
|
||||
return result
|
||||
|
||||
|
||||
def main():
|
||||
if not check_files():
|
||||
sys.exit(1)
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -12,15 +12,18 @@ from __future__ import print_function
|
|||
import os
|
||||
import sys
|
||||
|
||||
scriptname = os.path.basename(__file__);
|
||||
scriptname = os.path.basename(__file__)
|
||||
topsrcdir = os.path.dirname(os.path.dirname(__file__))
|
||||
|
||||
|
||||
def log_pass(text):
|
||||
print('TEST-PASS | {} | {}'.format(scriptname, text))
|
||||
|
||||
|
||||
def log_fail(text):
|
||||
print('TEST-UNEXPECTED-FAIL | {} | {}'.format(scriptname, text))
|
||||
|
||||
|
||||
def check_opcode():
|
||||
sys.path.insert(0, os.path.join(topsrcdir, 'js', 'src', 'vm'))
|
||||
import opcode
|
||||
|
|
@ -33,11 +36,13 @@ def check_opcode():
|
|||
log_pass('ok')
|
||||
return True
|
||||
|
||||
|
||||
def main():
|
||||
if not check_opcode():
|
||||
sys.exit(1)
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -37,7 +37,8 @@ reArgType = "(?P<type>[\w\s:*&]+)"
|
|||
reArgName = "(?P<name>\s\w+)"
|
||||
reArgDefault = "(?P<default>(?:\s=[^,)]+)?)"
|
||||
reAfterArg = "(?=[,)])"
|
||||
reMatchArg = re.compile(reBeforeArg + reArgType + reArgName + reArgDefault + reAfterArg)
|
||||
reMatchArg = re.compile(reBeforeArg + reArgType +
|
||||
reArgName + reArgDefault + reAfterArg)
|
||||
|
||||
|
||||
def get_normalized_signatures(signature, fileAnnot=None):
|
||||
|
|
@ -58,7 +59,8 @@ def get_normalized_signatures(signature, fileAnnot=None):
|
|||
archs = [fileAnnot['arch']]
|
||||
|
||||
if 'DEFINED_ON(' in signature:
|
||||
archs = re.sub(r'.*DEFINED_ON\((?P<archs>[^()]*)\).*', '\g<archs>', signature).split(',')
|
||||
archs = re.sub(
|
||||
r'.*DEFINED_ON\((?P<archs>[^()]*)\).*', '\g<archs>', signature).split(',')
|
||||
archs = [a.strip() for a in archs]
|
||||
signature = re.sub(r'\s+DEFINED_ON\([^()]*\)', '', signature)
|
||||
|
||||
|
|
@ -157,7 +159,8 @@ def get_macroassembler_definitions(filename):
|
|||
line = re.sub(r'//.*', '', line)
|
||||
if line.startswith('{') or line.strip() == "{}":
|
||||
if 'MacroAssembler::' in lines:
|
||||
signatures.extend(get_normalized_signatures(lines, fileAnnot))
|
||||
signatures.extend(
|
||||
get_normalized_signatures(lines, fileAnnot))
|
||||
if line.strip() != "{}": # Empty declaration, no need to declare
|
||||
# a new code section
|
||||
code_section = True
|
||||
|
|
@ -244,7 +247,8 @@ def generate_file_content(signatures):
|
|||
elif len(archs.symmetric_difference(all_shared_architecture_names)) == 0:
|
||||
output.append(s + ' PER_SHARED_ARCH;\n')
|
||||
else:
|
||||
output.append(s + ' DEFINED_ON(' + ', '.join(sorted(archs)) + ');\n')
|
||||
output.append(
|
||||
s + ' DEFINED_ON(' + ', '.join(sorted(archs)) + ');\n')
|
||||
for a in sorted(archs):
|
||||
a = a.replace('_', '-')
|
||||
masm = '%s/MacroAssembler-%s' % (a, a)
|
||||
|
|
@ -271,8 +275,10 @@ def check_style():
|
|||
filepath = os.path.join(dirpath, filename).replace('\\', '/')
|
||||
|
||||
if filepath.endswith('MacroAssembler.h'):
|
||||
decls = append_signatures(decls, get_macroassembler_declaration(filepath))
|
||||
defs = append_signatures(defs, get_macroassembler_definitions(filepath))
|
||||
decls = append_signatures(
|
||||
decls, get_macroassembler_declaration(filepath))
|
||||
defs = append_signatures(
|
||||
defs, get_macroassembler_definitions(filepath))
|
||||
|
||||
if not decls or not defs:
|
||||
raise Exception("Did not find any definitions or declarations")
|
||||
|
|
|
|||
|
|
@ -54,4 +54,3 @@ else:
|
|||
for k in sorted(details):
|
||||
print("Found {0} occurences in {1}".format(details[k], k))
|
||||
sys.exit(-1)
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,8 @@ included_inclnames_to_ignore = set([
|
|||
oddly_ordered_inclnames = set([
|
||||
'ctypes/typedefs.h', # Included multiple times in the body of ctypes/CTypes.h
|
||||
'frontend/BinSource-auto.h', # Included in the body of frontend/BinSource.h
|
||||
'frontend/ReservedWordsGenerated.h', # Included in the body of frontend/TokenStream.h
|
||||
# Included in the body of frontend/TokenStream.h
|
||||
'frontend/ReservedWordsGenerated.h',
|
||||
'gc/StatsPhasesGenerated.h', # Included in the body of gc/Statistics.h
|
||||
'gc/StatsPhasesGenerated.cpp', # Included in the body of gc/Statistics.cpp
|
||||
'psapi.h', # Must be included after "util/Windows.h" on Windows
|
||||
|
|
@ -317,7 +318,8 @@ def check_style(enable_fixup):
|
|||
with open(filename, 'w') as f:
|
||||
f.write(code.to_source())
|
||||
|
||||
check_file(filename, inclname, file_kind, code, all_inclnames, included_h_inclnames)
|
||||
check_file(filename, inclname, file_kind, code,
|
||||
all_inclnames, included_h_inclnames)
|
||||
|
||||
edges[inclname] = included_h_inclnames
|
||||
|
||||
|
|
@ -435,6 +437,7 @@ class CppBlock(object):
|
|||
|
||||
Each kid is either an Include (representing a #include), OrdinaryCode, or
|
||||
a nested CppBlock.'''
|
||||
|
||||
def __init__(self, start_line=""):
|
||||
self.start = start_line
|
||||
self.end = ''
|
||||
|
|
@ -508,7 +511,8 @@ class CppBlock(object):
|
|||
cutoff = last_include_index + 1
|
||||
|
||||
if should_try_to_sort(includes):
|
||||
output.extend(pretty_sorted_includes(includes) + batch[cutoff:])
|
||||
output.extend(pretty_sorted_includes(
|
||||
includes) + batch[cutoff:])
|
||||
else:
|
||||
output.extend(batch)
|
||||
del batch[:]
|
||||
|
|
@ -540,6 +544,7 @@ class CppBlock(object):
|
|||
|
||||
class OrdinaryCode(object):
|
||||
''' A list of lines of code that aren't #include/#if/#else/#endif lines. '''
|
||||
|
||||
def __init__(self, lines=None):
|
||||
self.lines = lines if lines is not None else []
|
||||
|
||||
|
|
@ -566,14 +571,16 @@ def read_file(f):
|
|||
m = re.match(r'(\s*#\s*include\s+)"([^"]*)"(.*)', line)
|
||||
if m is not None:
|
||||
prefix, inclname, suffix = m.groups()
|
||||
block_stack[-1].kids.append(Include(prefix, inclname, suffix, linenum, is_system=False))
|
||||
block_stack[-1].kids.append(Include(prefix,
|
||||
inclname, suffix, linenum, is_system=False))
|
||||
continue
|
||||
|
||||
# Look for a |#include <...>| line.
|
||||
m = re.match(r'(\s*#\s*include\s+)<([^>]*)>(.*)', line)
|
||||
if m is not None:
|
||||
prefix, inclname, suffix = m.groups()
|
||||
block_stack[-1].kids.append(Include(prefix, inclname, suffix, linenum, is_system=True))
|
||||
block_stack[-1].kids.append(Include(prefix,
|
||||
inclname, suffix, linenum, is_system=True))
|
||||
continue
|
||||
|
||||
# Look for a |#{if,ifdef,ifndef}| line.
|
||||
|
|
@ -601,7 +608,8 @@ def read_file(f):
|
|||
# Close the current block.
|
||||
block_stack.pop().end = line
|
||||
if len(block_stack) == 0:
|
||||
raise ValueError("#endif without #if at line " + str(linenum))
|
||||
raise ValueError(
|
||||
"#endif without #if at line " + str(linenum))
|
||||
continue
|
||||
|
||||
# Otherwise, we have an ordinary line.
|
||||
|
|
@ -648,7 +656,8 @@ def check_file(filename, inclname, file_kind, code, all_inclnames, included_h_in
|
|||
# Check a file doesn't #include itself. (We do this here because the cycle
|
||||
# detection below doesn't detect this case.)
|
||||
if inclname == include.inclname:
|
||||
error(filename, include.linenum, 'the file includes itself')
|
||||
error(filename, include.linenum,
|
||||
'the file includes itself')
|
||||
|
||||
def check_includes_order(include1, include2):
|
||||
'''Check the ordering of two #include statements.'''
|
||||
|
|
@ -689,6 +698,7 @@ def find_cycles(all_inclnames, edges):
|
|||
def draw_SCC(c):
|
||||
cset = set(c)
|
||||
drawn = set()
|
||||
|
||||
def draw(v, indent):
|
||||
out(' ' * indent + ('-> ' if indent else ' ') + v)
|
||||
if v in drawn:
|
||||
|
|
@ -704,7 +714,8 @@ def find_cycles(all_inclnames, edges):
|
|||
for scc in sorted(SCCs):
|
||||
if len(scc) != 1:
|
||||
if not have_drawn_an_SCC:
|
||||
error('(multiple files)', None, 'header files form one or more cycles')
|
||||
error('(multiple files)', None,
|
||||
'header files form one or more cycles')
|
||||
have_drawn_an_SCC = True
|
||||
|
||||
draw_SCC(scc)
|
||||
|
|
|
|||
|
|
@ -159,7 +159,6 @@ def main():
|
|||
# Try to give more precise information about the offending code.
|
||||
emit_line_info = True
|
||||
|
||||
|
||||
# Check that all functions we expect are used in jsutil.cpp. (This will
|
||||
# fail if the function-detection code breaks at any point.)
|
||||
for fn in alloc_fns_unescaped:
|
||||
|
|
@ -199,7 +198,8 @@ def main():
|
|||
for line in lines:
|
||||
m = re.search(alloc_lines_re, line)
|
||||
if m:
|
||||
print('check_vanilla_allocations.py:', m.group(1), 'called at', m.group(3))
|
||||
print('check_vanilla_allocations.py:',
|
||||
m.group(1), 'called at', m.group(3))
|
||||
|
||||
if has_failed:
|
||||
sys.exit(1)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
import sys
|
||||
import os
|
||||
|
||||
|
||||
def get_build_entries(root_path):
|
||||
""" Iterates through the root_path, creating a list for each file and
|
||||
directory. Excludes any file paths ending with channel-prefs.js.
|
||||
|
|
@ -39,6 +40,7 @@ def get_build_entries(root_path):
|
|||
|
||||
return rel_file_path_list, rel_dir_path_list
|
||||
|
||||
|
||||
def generate_precomplete(root_path):
|
||||
""" Creates the precomplete file containing the remove and rmdir
|
||||
application update instructions. The given directory is used
|
||||
|
|
@ -63,5 +65,6 @@ def generate_precomplete(root_path):
|
|||
|
||||
precomplete_file.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
generate_precomplete(os.getcwd())
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ from optparse import OptionParser
|
|||
#####################################################################
|
||||
# Utility functions
|
||||
#####################################################################
|
||||
|
||||
|
||||
def run(args, stdin=None):
|
||||
class ThreadWorker(threading.Thread):
|
||||
def __init__(self, pipe):
|
||||
|
|
@ -40,7 +42,8 @@ def run(args, stdin=None):
|
|||
def run(self):
|
||||
while True:
|
||||
line = self.pipe.readline()
|
||||
if line == '': break
|
||||
if line == '':
|
||||
break
|
||||
else:
|
||||
self.all += line
|
||||
|
||||
|
|
@ -51,7 +54,8 @@ def run(args, stdin=None):
|
|||
args = [str(a) for a in args] # convert to strs
|
||||
|
||||
stdin_pipe = subprocess.PIPE if stdin else None
|
||||
proc = subprocess.Popen(args, stdin=stdin_pipe, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
proc = subprocess.Popen(args, stdin=stdin_pipe,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
if stdin_pipe:
|
||||
proc.stdin.write(stdin)
|
||||
proc.stdin.close()
|
||||
|
|
@ -72,6 +76,7 @@ def run(args, stdin=None):
|
|||
result = (stdout, stderr, proc.returncode)
|
||||
return result
|
||||
|
||||
|
||||
def get_js_files():
|
||||
(out, err, exit) = run('find ../jit-test/tests -name "*.js"')
|
||||
if (err, exit) != ("", 0):
|
||||
|
|
@ -79,18 +84,20 @@ def get_js_files():
|
|||
return out.split()
|
||||
|
||||
|
||||
|
||||
#####################################################################
|
||||
# Blacklisting
|
||||
#####################################################################
|
||||
def in_blacklist(sig):
|
||||
return sig in blacklist
|
||||
|
||||
|
||||
def add_to_blacklist(sig):
|
||||
blacklist[sig] = blacklist.get(sig, 0)
|
||||
blacklist[sig] += 1
|
||||
|
||||
# How often is a particular lines important for this.
|
||||
|
||||
|
||||
def count_lines():
|
||||
"""Keep track of the amount of times individual lines occur, in order to
|
||||
prioritize the errors which occur most frequently."""
|
||||
|
|
@ -116,15 +123,20 @@ def count_lines():
|
|||
#####################################################################
|
||||
def clean_voutput(err):
|
||||
# Skip what we can't reproduce
|
||||
err = re.sub(r"^--\d+-- run: /usr/bin/dsymutil \"shell/js\"$", "", err, flags=re.MULTILINE)
|
||||
err = re.sub(r"^--\d+-- run: /usr/bin/dsymutil \"shell/js\"$",
|
||||
"", err, flags=re.MULTILINE)
|
||||
err = re.sub(r"^==\d+==", "", err, flags=re.MULTILINE)
|
||||
err = re.sub(r"^\*\*\d+\*\*", "", err, flags=re.MULTILINE)
|
||||
err = re.sub(r"^\s+by 0x[0-9A-Fa-f]+: ", "by: ", err, flags=re.MULTILINE)
|
||||
err = re.sub(r"^\s+at 0x[0-9A-Fa-f]+: ", "at: ", err, flags=re.MULTILINE)
|
||||
err = re.sub(r"(^\s+Address 0x)[0-9A-Fa-f]+( is not stack'd)", r"\1\2", err, flags=re.MULTILINE)
|
||||
err = re.sub(r"(^\s+Invalid write of size )\d+", r"\1x", err, flags=re.MULTILINE)
|
||||
err = re.sub(r"(^\s+Invalid read of size )\d+", r"\1x", err, flags=re.MULTILINE)
|
||||
err = re.sub(r"(^\s+Address 0x)[0-9A-Fa-f]+( is )\d+( bytes inside a block of size )[0-9,]+( free'd)", r"\1\2\3\4", err, flags=re.MULTILINE)
|
||||
err = re.sub(
|
||||
r"(^\s+Address 0x)[0-9A-Fa-f]+( is not stack'd)", r"\1\2", err, flags=re.MULTILINE)
|
||||
err = re.sub(r"(^\s+Invalid write of size )\d+",
|
||||
r"\1x", err, flags=re.MULTILINE)
|
||||
err = re.sub(r"(^\s+Invalid read of size )\d+",
|
||||
r"\1x", err, flags=re.MULTILINE)
|
||||
err = re.sub(r"(^\s+Address 0x)[0-9A-Fa-f]+( is )\d+( bytes inside a block of size )[0-9,]+( free'd)",
|
||||
r"\1\2\3\4", err, flags=re.MULTILINE)
|
||||
|
||||
# Skip the repeating bit due to the segfault
|
||||
lines = []
|
||||
|
|
@ -136,6 +148,7 @@ def clean_voutput(err):
|
|||
|
||||
return err
|
||||
|
||||
|
||||
def remove_failed_allocation_backtraces(err):
|
||||
lines = []
|
||||
|
||||
|
|
@ -151,14 +164,14 @@ def remove_failed_allocation_backtraces(err):
|
|||
if add:
|
||||
lines.append(l)
|
||||
|
||||
|
||||
err = '\n'.join(lines)
|
||||
|
||||
return err
|
||||
|
||||
|
||||
def clean_output(err):
|
||||
err = re.sub(r"^js\(\d+,0x[0-9a-f]+\) malloc: \*\*\* error for object 0x[0-9a-f]+: pointer being freed was not allocated\n\*\*\* set a breakppoint in malloc_error_break to debug\n$", "pointer being freed was not allocated", err, flags=re.MULTILINE)
|
||||
err = re.sub(r"^js\(\d+,0x[0-9a-f]+\) malloc: \*\*\* error for object 0x[0-9a-f]+: pointer being freed was not allocated\n\*\*\* set a breakppoint in malloc_error_break to debug\n$",
|
||||
"pointer being freed was not allocated", err, flags=re.MULTILINE)
|
||||
|
||||
return err
|
||||
|
||||
|
|
@ -179,7 +192,8 @@ command_template = 'shell/js' \
|
|||
# logs again, principally because the information we have isn't enough.
|
||||
|
||||
blacklist = {}
|
||||
add_to_blacklist(r"('', '', 1)") # 1 means OOM if the shell hasn't launched yet.
|
||||
# 1 means OOM if the shell hasn't launched yet.
|
||||
add_to_blacklist(r"('', '', 1)")
|
||||
add_to_blacklist(r"('', 'out of memory\n', 1)")
|
||||
|
||||
whitelist = set()
|
||||
|
|
@ -187,7 +201,6 @@ whitelist.add(r"('', 'out of memory\n', -11)") # -11 means OOM
|
|||
whitelist.add(r"('', 'out of memory\nout of memory\n', -11)")
|
||||
|
||||
|
||||
|
||||
#####################################################################
|
||||
# Program
|
||||
#####################################################################
|
||||
|
|
@ -224,7 +237,8 @@ for f in files:
|
|||
# Run it once to establish boundaries
|
||||
command = (command_template + ' -O').format(f)
|
||||
out, err, exit = run(command)
|
||||
max = re.match(".*OOM max count: (\d+).*", out, flags=re.DOTALL).groups()[0]
|
||||
max = re.match(".*OOM max count: (\d+).*", out,
|
||||
flags=re.DOTALL).groups()[0]
|
||||
max = int(max)
|
||||
|
||||
# OOMs don't recover well for the first 20 allocations or so.
|
||||
|
|
@ -234,7 +248,8 @@ for f in files:
|
|||
if OPTIONS.regression == None:
|
||||
print("Testing allocation {0}/{1} in {2}".format(i, max, f))
|
||||
else:
|
||||
sys.stdout.write('.') # something short for tinderbox, no space or \n
|
||||
# something short for tinderbox, no space or \n
|
||||
sys.stdout.write('.')
|
||||
|
||||
command = (command_template + ' -A {0}').format(f, i)
|
||||
out, err, exit = run(command)
|
||||
|
|
@ -263,7 +278,6 @@ for f in files:
|
|||
|
||||
add_to_blacklist(problem)
|
||||
|
||||
|
||||
# Get valgrind output for a good stack trace
|
||||
vcommand = "valgrind --dsymutil=yes -q --log-file=OOM_valgrind_log_file " + command
|
||||
run(vcommand)
|
||||
|
|
@ -280,7 +294,8 @@ for f in files:
|
|||
|
||||
log.write("\n")
|
||||
log.write("\n")
|
||||
log.write ("=========================================================================")
|
||||
log.write(
|
||||
"=========================================================================")
|
||||
log.write("\n")
|
||||
log.write("An allocation failure at\n\tallocation {0}/{1} in {2}\n\t"
|
||||
"causes problems (detected using bug 624094)"
|
||||
|
|
@ -288,16 +303,19 @@ for f in files:
|
|||
log.write("\n")
|
||||
log.write("\n")
|
||||
|
||||
log.write ("Command (from obj directory, using patch from bug 624094):\n " + command)
|
||||
log.write(
|
||||
"Command (from obj directory, using patch from bug 624094):\n " + command)
|
||||
log.write("\n")
|
||||
log.write("\n")
|
||||
log.write("stdout, stderr, exitcode:\n " + problem)
|
||||
log.write("\n")
|
||||
log.write("\n")
|
||||
|
||||
double_free = err.find("pointer being freed was not allocated") != -1
|
||||
double_free = err.find(
|
||||
"pointer being freed was not allocated") != -1
|
||||
oom_detected = err.find("out of memory") != -1
|
||||
multiple_oom_detected = err.find("out of memory\nout of memory") != -1
|
||||
multiple_oom_detected = err.find(
|
||||
"out of memory\nout of memory") != -1
|
||||
segfault_detected = exit == -11
|
||||
|
||||
log.write("Diagnosis: ")
|
||||
|
|
@ -338,7 +356,8 @@ if OPTIONS.regression != None:
|
|||
print("More out-of-memory errors were found ({0}) than expected ({1}). "
|
||||
"This probably means an allocation site has been added without a "
|
||||
"NULL-check. If this is unavoidable, you can account for it by "
|
||||
"updating Makefile.in.".format(num_failures, expected_num_failures),
|
||||
"updating Makefile.in.".format(
|
||||
num_failures, expected_num_failures),
|
||||
end='')
|
||||
else:
|
||||
print("Congratulations, you have removed {0} out-of-memory error(s) "
|
||||
|
|
@ -349,4 +368,3 @@ if OPTIONS.regression != None:
|
|||
else:
|
||||
print('TEST-PASS | find_OOM_errors | Found the expected number of OOM '
|
||||
'errors ({0})'.format(expected_num_failures))
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,13 @@
|
|||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
from __future__ import print_function
|
||||
import os, re, string, sys
|
||||
import os
|
||||
import re
|
||||
import string
|
||||
import sys
|
||||
from mozbuild.util import FileAvoidWrite
|
||||
|
||||
|
||||
def find_in_path(file, searchpath):
|
||||
for dir in searchpath.split(os.pathsep):
|
||||
f = os.path.join(dir, file)
|
||||
|
|
@ -12,6 +16,7 @@ def find_in_path(file, searchpath):
|
|||
return f
|
||||
return ''
|
||||
|
||||
|
||||
def header_path(header, compiler):
|
||||
if compiler == 'gcc':
|
||||
# we use include_next on gcc
|
||||
|
|
@ -24,6 +29,8 @@ def header_path(header, compiler):
|
|||
|
||||
# The 'unused' arg is the output file from the file_generate action. We actually
|
||||
# generate all the files in header_list
|
||||
|
||||
|
||||
def gen_wrappers(unused, outdir, compiler, template_file, *header_list):
|
||||
template = open(template_file, 'r').read()
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import sys
|
|||
import shutil
|
||||
import stat
|
||||
|
||||
|
||||
def _nsinstall_internal(argv):
|
||||
usage = "usage: %prog [options] arg1 [arg2 ...] target-directory"
|
||||
p = OptionParser(usage=usage)
|
||||
|
|
@ -81,7 +82,8 @@ def _nsinstall_internal(argv):
|
|||
# We might have hit EEXIST due to a race condition (see bug 463411) -- try again once
|
||||
if try_again:
|
||||
return maybe_create_dir(dir, mode, False)
|
||||
print("nsinstall: failed to create directory {0}: {1}".format(dir, e))
|
||||
print(
|
||||
"nsinstall: failed to create directory {0}: {1}".format(dir, e))
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
|
|
@ -120,7 +122,8 @@ def _nsinstall_internal(argv):
|
|||
if os.path.isdir(srcpath):
|
||||
if not os.path.exists(targetpath):
|
||||
os.mkdir(targetpath)
|
||||
entries = [os.path.join(srcpath, e) for e in os.listdir(srcpath)]
|
||||
entries = [os.path.join(srcpath, e)
|
||||
for e in os.listdir(srcpath)]
|
||||
copy_all_entries(entries, targetpath)
|
||||
# options.t is not relevant for directories
|
||||
if options.m:
|
||||
|
|
@ -148,9 +151,12 @@ def _nsinstall_internal(argv):
|
|||
return 0
|
||||
|
||||
# nsinstall as a native command is always UTF-8
|
||||
|
||||
|
||||
def nsinstall(argv):
|
||||
return _nsinstall_internal([unicode(arg, "utf-8") for arg in argv])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# sys.argv corrupts characters outside the system code page on Windows
|
||||
# <http://bugs.python.org/issue2128>. Use ctypes instead. This is also
|
||||
|
|
@ -165,7 +171,8 @@ if __name__ == '__main__':
|
|||
GetCommandLine.restype = wintypes.LPWSTR
|
||||
|
||||
CommandLineToArgv = ctypes.windll.shell32.CommandLineToArgvW
|
||||
CommandLineToArgv.argtypes = [wintypes.LPWSTR, ctypes.POINTER(ctypes.c_int)]
|
||||
CommandLineToArgv.argtypes = [
|
||||
wintypes.LPWSTR, ctypes.POINTER(ctypes.c_int)]
|
||||
CommandLineToArgv.restype = ctypes.POINTER(wintypes.LPWSTR)
|
||||
|
||||
argc = ctypes.c_int(0)
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ from __future__ import print_function
|
|||
import sys
|
||||
import re
|
||||
|
||||
|
||||
def get_prerelease_suffix(version):
|
||||
""" Returns the prerelease suffix from the version string argument """
|
||||
|
||||
|
|
@ -27,5 +28,6 @@ def get_prerelease_suffix(version):
|
|||
return ''
|
||||
return result
|
||||
|
||||
|
||||
if len(sys.argv) == 2:
|
||||
print(get_prerelease_suffix(sys.argv[1]))
|
||||
|
|
|
|||
|
|
@ -47,10 +47,12 @@ def main(args):
|
|||
|
||||
execfile(script, frozenglobals)
|
||||
|
||||
|
||||
# Freeze scope here ... why this makes things work I have no idea ...
|
||||
frozenglobals = globals()
|
||||
|
||||
import sys, os
|
||||
import sys
|
||||
import os
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv[1:])
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
import os
|
||||
import errno
|
||||
|
||||
|
||||
def mtime(path):
|
||||
try:
|
||||
return os.stat(path).st_mtime
|
||||
|
|
@ -13,6 +14,7 @@ def mtime(path):
|
|||
return -1
|
||||
raise
|
||||
|
||||
|
||||
def rebuild_check(args):
|
||||
target = args[0]
|
||||
deps = args[1:]
|
||||
|
|
@ -31,14 +33,17 @@ def rebuild_check(args):
|
|||
newer.append(dep)
|
||||
|
||||
if newer and removed:
|
||||
print 'Rebuilding %s because %s changed and %s was removed' % (target, ', '.join(newer), ', '.join(removed))
|
||||
print 'Rebuilding %s because %s changed and %s was removed' % (
|
||||
target, ', '.join(newer), ', '.join(removed))
|
||||
elif newer:
|
||||
print 'Rebuilding %s because %s changed' % (target, ', '.join(newer))
|
||||
elif removed:
|
||||
print 'Rebuilding %s because %s was removed' % (target, ', '.join(removed))
|
||||
print 'Rebuilding %s because %s was removed' % (
|
||||
target, ', '.join(removed))
|
||||
else:
|
||||
print 'Rebuilding %s for an unknown reason' % target
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
rebuild_check(sys.argv[1:])
|
||||
|
|
|
|||
|
|
@ -6,8 +6,10 @@ import buildconfig
|
|||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def main(output, lib_file, *scripts):
|
||||
for script in scripts:
|
||||
retcode = subprocess.call([sys.executable, script], cwd=buildconfig.topsrcdir)
|
||||
retcode = subprocess.call(
|
||||
[sys.executable, script], cwd=buildconfig.topsrcdir)
|
||||
if retcode != 0:
|
||||
raise Exception(script + " failed")
|
||||
|
|
|
|||
|
|
@ -68,7 +68,6 @@ class TestMozbuildReading(unittest.TestCase):
|
|||
self.assertEqual(set(paths.keys()), all_paths)
|
||||
self.assertGreaterEqual(len(contexts), len(paths))
|
||||
|
||||
|
||||
def test_orphan_file_patterns(self):
|
||||
if sys.platform == 'win32':
|
||||
raise unittest.SkipTest('failing on windows builds')
|
||||
|
|
@ -111,5 +110,6 @@ class TestMozbuildReading(unittest.TestCase):
|
|||
"Please update this entry." %
|
||||
(p, ctx.main_path))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -8,12 +8,13 @@ from mozunit import main, MockedOpen
|
|||
import unittest
|
||||
from tempfile import mkstemp
|
||||
|
||||
|
||||
class TestMozUnit(unittest.TestCase):
|
||||
def test_mocked_open(self):
|
||||
# Create a temporary file on the file system.
|
||||
(fd, path) = mkstemp()
|
||||
with os.fdopen(fd, 'w') as file:
|
||||
file.write('foobar');
|
||||
file.write('foobar')
|
||||
|
||||
self.assertFalse(os.path.exists('file1'))
|
||||
self.assertFalse(os.path.exists('file2'))
|
||||
|
|
@ -82,5 +83,6 @@ class TestMozUnit(unittest.TestCase):
|
|||
# created.
|
||||
self.assertRaises(IOError, open, 'file3', 'r')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
import unittest
|
||||
|
||||
import os, sys, os.path, time
|
||||
import os
|
||||
import sys
|
||||
import os.path
|
||||
import time
|
||||
from tempfile import mkdtemp
|
||||
from shutil import rmtree
|
||||
import mozunit
|
||||
|
|
@ -17,10 +20,12 @@ RUN_NON_ASCII_TESTS = (sys.platform == "win32" or
|
|||
(sys.stdin.encoding is not None and
|
||||
codecs.lookup(sys.stdin.encoding) == codecs.lookup("utf-8")))
|
||||
|
||||
|
||||
class TestNsinstall(unittest.TestCase):
|
||||
"""
|
||||
Unit tests for nsinstall.py
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
self.tmpdir = mkdtemp()
|
||||
|
||||
|
|
@ -80,7 +85,8 @@ class TestNsinstall(unittest.TestCase):
|
|||
self.assert_(os.path.isfile(os.path.join(testdir, "testfile")))
|
||||
self.assert_(not os.path.exists(os.path.join(testdir, "Xfile")))
|
||||
self.assert_(os.path.isdir(os.path.join(testdir, "copieddir")))
|
||||
self.assert_(os.path.isfile(os.path.join(testdir, "copieddir", "testfile2")))
|
||||
self.assert_(os.path.isfile(os.path.join(
|
||||
testdir, "copieddir", "testfile2")))
|
||||
self.assert_(not os.path.exists(os.path.join(testdir, "Xdir")))
|
||||
|
||||
def test_nsinstall_multiple(self):
|
||||
|
|
@ -170,5 +176,6 @@ class TestNsinstall(unittest.TestCase):
|
|||
|
||||
# TODO: implement -R, -l, -L and test them!
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
mozunit.main()
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import mozunit
|
|||
|
||||
from printprereleasesuffix import get_prerelease_suffix
|
||||
|
||||
|
||||
class TestGetPreReleaseSuffix(unittest.TestCase):
|
||||
"""
|
||||
Unit tests for the get_prerelease_suffix function
|
||||
|
|
@ -76,5 +77,6 @@ class TestGetPreReleaseSuffix(unittest.TestCase):
|
|||
self.c = get_prerelease_suffix('1.2+')
|
||||
self.assertEqual(self.c, '')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
mozunit.main()
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ _lengths = map(lambda n: n * 64, [16, 64, 80])
|
|||
lengths = 3
|
||||
writes = 5
|
||||
|
||||
|
||||
def givenlength(i):
|
||||
'''Return a length given in the _lengths array to allow manual
|
||||
tuning of which lengths of zip entries to use.
|
||||
|
|
@ -81,6 +82,7 @@ def createWriter(sizer, *items):
|
|||
locitems = copy.deepcopy(items)
|
||||
for item in locitems:
|
||||
item['length'] = sizer(item.pop('length', 0))
|
||||
|
||||
def helper(self):
|
||||
mode = 'w'
|
||||
if os.path.isfile(self.f):
|
||||
|
|
@ -92,11 +94,13 @@ def createWriter(sizer, *items):
|
|||
pass
|
||||
return helper
|
||||
|
||||
|
||||
def createTester(name, *writes):
|
||||
'''Helper method to fill in tests, calls into a list of write
|
||||
helper methods.
|
||||
'''
|
||||
_writes = copy.copy(writes)
|
||||
|
||||
def tester(self):
|
||||
for w in _writes:
|
||||
getattr(self, w)()
|
||||
|
|
@ -106,6 +110,7 @@ def createTester(name, *writes):
|
|||
tester.__name__ = name
|
||||
return tester
|
||||
|
||||
|
||||
class TestExtensiveStored(unittest.TestCase):
|
||||
'''Unit tests for MozZipFile
|
||||
|
||||
|
|
@ -118,6 +123,7 @@ class TestExtensiveStored(unittest.TestCase):
|
|||
|
||||
def leaf(self, *leafs):
|
||||
return os.path.join(self.stage, *leafs)
|
||||
|
||||
def setUp(self):
|
||||
if os.path.exists(self.stage):
|
||||
shutil.rmtree(self.stage)
|
||||
|
|
@ -157,6 +163,7 @@ class TestExtensiveStored(unittest.TestCase):
|
|||
os.makedirs(dir)
|
||||
open(self.leaf('stage', leaf), 'w').write(content)
|
||||
|
||||
|
||||
# all leafs in all lengths
|
||||
atomics = list(prod(xrange(len(leafs)), xrange(lengths)))
|
||||
|
||||
|
|
@ -193,9 +200,11 @@ for first in allfiles:
|
|||
test[2] = '_write' + getid([second])
|
||||
setattr(TestExtensiveStored, test[0], createTester(*test))
|
||||
|
||||
|
||||
class TestExtensiveDeflated(TestExtensiveStored):
|
||||
'Test all that has been tested with ZIP_STORED with DEFLATED, too.'
|
||||
compression = zipfile.ZIP_DEFLATED
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
|||
Loading…
Reference in a new issue