From: Martin Quinson Date: Sun, 17 Mar 2019 15:48:18 +0000 (+0100) Subject: autopep8 --max-line-length 120 -i --aggressive `find -name '*.py'` X-Git-Tag: v3_22~76 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/5ab9431deaa127bb5664f70cf66973f4d4dc494f autopep8 --max-line-length 120 -i --aggressive `find -name '*.py'` --- diff --git a/docs/source/conf.py b/docs/source/conf.py index 227dfcf051..18435dc172 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -12,14 +12,14 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # -import os, subprocess +import os +import subprocess # Search for our extensions too import sys sys.path.append(os.path.abspath('_ext')) # -- Run doxygen on readthedocs.org ------------------------------------------ -import subprocess, os read_the_docs_build = os.environ.get('READTHEDOCS', None) == 'True' @@ -52,10 +52,10 @@ release = u'alpha 3.22' extensions = [ 'sphinx.ext.todo', 'breathe', -# 'exhale', + # 'exhale', 'sphinx.ext.autodoc', 'sphinx.ext.intersphinx', -# 'sphinx.ext.napoleon', + # 'sphinx.ext.napoleon', 'sphinx.ext.autosummary', 'hidden_code_block', 'javasphinx', @@ -63,19 +63,19 @@ extensions = [ todo_include_todos = True -breathe_projects = { 'simgrid': '../build/xml' } +breathe_projects = {'simgrid': '../build/xml'} breathe_default_project = "simgrid" # Setup the exhale extension exhale_args = { # These arguments are required - "containmentFolder": "./api", - "rootFileName": "library_root.rst", - "rootFileTitle": "SimGrid Full API", - "doxygenStripFromPath": "..", + "containmentFolder": "./api", + "rootFileName": "library_root.rst", + "rootFileTitle": "SimGrid Full API", + "doxygenStripFromPath": "..", # Suggested optional arguments - "createTreeView": True, + "createTreeView": True, "exhaleExecutesDoxygen": False, # "exhaleUseDoxyfile": True, } @@ -122,7 +122,7 @@ html_theme = 'sphinx_rtd_theme' # documentation. # html_theme_options = { - 'navigation_depth' : 4, + 'navigation_depth': 4, 'sticky_navigation': True, 'display_version': True, 'includehidden': True, @@ -151,11 +151,10 @@ htmlhelp_basename = 'SimGrid-doc' # -- Options for GitLab integration ------------------------------------------ html_context = { - "display_gitlab": True, # Integrate Gitlab + "display_gitlab": True, # Integrate Gitlab "gitlab_host": "framagit.org", "gitlab_user": "simgrid", "gitlab_repo": "simgrid", - "gitlab_version": "master", # Version - "conf_py_path": "/docs/source/", # Path in the checkout to the docs root + "gitlab_version": "master", # Version + "conf_py_path": "/docs/source/", # Path in the checkout to the docs root } - diff --git a/examples/python/actor-create/actor-create.py b/examples/python/actor-create/actor-create.py index 4bb1d52c01..2c03dfa2b2 100644 --- a/examples/python/actor-create/actor-create.py +++ b/examples/python/actor-create/actor-create.py @@ -59,7 +59,7 @@ class Sender: Later, this actor class is instantiated twice in the simulation. """ - def __init__(self, msg = "GaBuZoMeu", mbox = "mb42"): + def __init__(self, msg="GaBuZoMeu", mbox="mb42"): self.msg = msg self.mbox = mbox diff --git a/examples/python/actor-lifetime/actor-lifetime.py b/examples/python/actor-lifetime/actor-lifetime.py index f408dc1093..7c9f56912a 100644 --- a/examples/python/actor-lifetime/actor-lifetime.py +++ b/examples/python/actor-lifetime/actor-lifetime.py @@ -14,7 +14,8 @@ class Sleeper: """This actor just sleeps until termination""" def __init__(self, *args): - this_actor.on_exit(lambda: print("BAAA")) # sys.exit(1); simgrid.info("Exiting now (done sleeping or got killed).")) + # sys.exit(1); simgrid.info("Exiting now (done sleeping or got killed).")) + this_actor.on_exit(lambda: print("BAAA")) def __call__(self): this_actor.info("Hello! I go to sleep.") diff --git a/examples/python/async-wait/async-wait.py b/examples/python/async-wait/async-wait.py index 198f779c60..2d6d549e32 100644 --- a/examples/python/async-wait/async-wait.py +++ b/examples/python/async-wait/async-wait.py @@ -13,14 +13,15 @@ from simgrid import * # # The sender then loops until there is no ongoing communication. + class Sender: def __init__(self, *args): if len(args) != 3: raise AssertionError( "Actor sender requires 3 parameters, but got {:d}".format(len(args))) - self.messages_count = int(args[0]) # number of tasks - self.msg_size = int(args[1]) # communication cost (in bytes) - self.receivers_count = int(args[2]) # number of receivers + self.messages_count = int(args[0]) # number of tasks + self.msg_size = int(args[1]) # communication cost (in bytes) + self.receivers_count = int(args[2]) # number of receivers def __call__(self): # List in which we store all ongoing communications @@ -54,9 +55,10 @@ class Sender: comm.wait() this_actor.info("Goodbye now!") + class Receiver: def __init__(self, *args): - if len(args) != 1: # Receiver actor expects 1 argument: its ID + if len(args) != 1: # Receiver actor expects 1 argument: its ID raise AssertionError("Actor receiver requires 1 parameter, but got {:d}".format(len(args))) self.mbox = Mailbox.by_name("receiver-{:s}".format(args[0])) @@ -66,7 +68,7 @@ class Receiver: received = self.mbox.get() this_actor.info("I got a '{:s}'.".format(received)) if received == "finalize": - break # If it's a finalize message, we're done. + break # If it's a finalize message, we're done. if __name__ == '__main__': diff --git a/examples/python/async-waitany/async-waitany.py b/examples/python/async-waitany/async-waitany.py index 1bc5891a0c..274b96a93b 100644 --- a/examples/python/async-waitany/async-waitany.py +++ b/examples/python/async-waitany/async-waitany.py @@ -18,6 +18,7 @@ from simgrid import * # other messages of this application. As expected, the trace shows that the finalize of worker 1 is # processed before 'Message 5' that is sent to worker 0. + class Sender: def __init__(self, *args): if len(args) != 3: @@ -60,10 +61,11 @@ class Sender: # terminated. # Even in this simple example, the pending comms do not terminate in the exact same order of creation. while pending_comms: - changed_pos = Comm.wait_any(pending_comms) - del pending_comms[changed_pos] - if (changed_pos != 0): - this_actor.info("Remove the {:d}th pending comm: it terminated earlier than another comm that was initiated first.".format(changed_pos)); + changed_pos = Comm.wait_any(pending_comms) + del pending_comms[changed_pos] + if (changed_pos != 0): + this_actor.info( + "Remove the {:d}th pending comm: it terminated earlier than another comm that was initiated first.".format(changed_pos)) this_actor.info("Goodbye now!") diff --git a/examples/python/exec-basic/exec-basic.py b/examples/python/exec-basic/exec-basic.py index fa001b9397..7d088474f8 100644 --- a/examples/python/exec-basic/exec-basic.py +++ b/examples/python/exec-basic/exec-basic.py @@ -34,7 +34,7 @@ i = 0 if "--" in sys.argv: i = sys.argv.index("--") e = Engine(sys.argv[0:i]) -e.load_platform(sys.argv[i+1]) +e.load_platform(sys.argv[i + 1]) Actor.create("executor", Host.by_name("Tremblay"), executor) Actor.create("privileged", Host.by_name("Tremblay"), privileged) diff --git a/src/simix/simcalls.py b/src/simix/simcalls.py index 3d71623a0b..c25d5192f2 100755 --- a/src/simix/simcalls.py +++ b/src/simix/simcalls.py @@ -9,6 +9,7 @@ import re import glob + class Arg(object): def __init__(self, name, thetype): @@ -21,6 +22,7 @@ class Arg(object): def rettype(self): return self.type + class Simcall(object): simcalls_body = None simcalls_pre = None @@ -42,7 +44,7 @@ class Simcall(object): print ('# ERROR: No function calling simcall_BODY_%s' % self.name) print ('# Add something like this to libsmx.c:') print ('%s simcall_%s(%s)' % (self.res.rettype(), self.name, ', '. - join('%s %s' % (arg.rettype(), arg.name) for arg in self.args))) + join('%s %s' % (arg.rettype(), arg.name) for arg in self.args))) print ('{') print (' return simcall_BODY_%s(%s);' % (self.name, "...")) print ('}') @@ -52,7 +54,8 @@ class Simcall(object): # smx_host_t h) if self.simcalls_pre is None: self.simcalls_pre = set() - for fn in glob.glob('smx_*') + glob.glob('ActorImpl*') + glob.glob('../mc/*cpp') + glob.glob('../kernel/activity/*cpp'): + for fn in glob.glob('smx_*') + glob.glob('ActorImpl*') + \ + glob.glob('../mc/*cpp') + glob.glob('../kernel/activity/*cpp'): f = open(fn) self.simcalls_pre |= set(re.findall(r'simcall_HANDLER_(.*?)\(', f.read())) f.close() @@ -61,14 +64,16 @@ class Simcall(object): print ('# ERROR: No function called simcall_HANDLER_%s' % self.name) print ('# Add something like this to the relevant C file (like smx_io.c if it\'s an IO call):') print ('%s simcall_HANDLER_%s(smx_simcall_t simcall%s)' % (self.res.rettype(), self.name, ''. - join(', %s %s' % (arg.rettype(), arg.name)for arg in self.args))) + join(', %s %s' % (arg.rettype(), arg.name)for arg in self.args))) print ('{') print (' // Your code handling the simcall') print ('}') return False else: if self.name in self.simcalls_pre: - print ('# ERROR: You have a function called simcall_HANDLER_%s, but that simcall is not using any handler' % self.name) + print ( + '# ERROR: You have a function called simcall_HANDLER_%s, but that simcall is not using any handler' % + self.name) print ('# Either change your simcall definition, or kill that function') return False return True @@ -82,7 +87,7 @@ class Simcall(object): def accessors(self): res = [] res.append('') - regex = re.compile(r"^boost::intrusive_ptr<(.*?)>(.*)$") # to compute the raw type + regex = re.compile(r"^boost::intrusive_ptr<(.*?)>(.*)$") #  to compute the raw type # Arguments getter/setters for i in range(len(self.args)): arg = self.args[i] @@ -124,19 +129,19 @@ class Simcall(object): def case(self): res = [] - args = [ "simgrid::simix::unmarshal<%s>(simcall->args[%d])" % (arg.rettype(), i) - for i, arg in enumerate(self.args) ] + args = ["simgrid::simix::unmarshal<%s>(simcall->args[%d])" % (arg.rettype(), i) + for i, arg in enumerate(self.args)] res.append('case SIMCALL_%s:' % (self.name.upper())) if self.need_handler: call = "simcall_HANDLER_%s(simcall%s%s)" % (self.name, - ", " if len(args) > 0 else "", - ', '.join(args)) + ", " if len(args) > 0 else "", + ', '.join(args)) else: call = "SIMIX_%s(%s)" % (self.name, ', '.join(args)) if self.call_kind == 'Func': res.append(" simgrid::simix::marshal<%s>(simcall->result, %s);" % (self.res.rettype(), call)) else: - res.append(" " + call + ";"); + res.append(" " + call + ";") if self.call_kind != 'Blck': res.append(' SIMIX_simcall_answer(simcall);') res.append(' break;') @@ -147,8 +152,8 @@ class Simcall(object): res = [''] res.append( 'inline static %s simcall_BODY_%s(%s)' % (self.res.rettype(), - self.name, - ', '.join('%s %s' % (arg.rettype(), arg.name) for arg in self.args))) + self.name, + ', '.join('%s %s' % (arg.rettype(), arg.name) for arg in self.args))) res.append('{') res.append(' if (0) /* Go to that function to follow the code flow through the simcall barrier */') if self.need_handler: @@ -156,13 +161,13 @@ class Simcall(object): ', '.join(["&SIMIX_process_self()->simcall"] + [arg.name for arg in self.args]))) else: res.append(' SIMIX_%s(%s);' % (self.name, - ', '.join(arg.name for arg in self.args))) + ', '.join(arg.name for arg in self.args))) res.append(' return simcall<%s%s>(SIMCALL_%s%s);' % ( self.res.rettype(), - "".join([ ", " + arg.rettype() for i, arg in enumerate(self.args) ]), + "".join([", " + arg.rettype() for i, arg in enumerate(self.args)]), self.name.upper(), - "".join([ ", " + arg.name for i, arg in enumerate(self.args) ]) - )); + "".join([", " + arg.name for i, arg in enumerate(self.args)]) + )) res.append('}') return '\n'.join(res) @@ -261,6 +266,7 @@ def handle(fd, func, simcalls, guarded_simcalls): fd.write('\n'.join(func(simcall) for simcall in ll)) fd.write('\n#endif\n') + if __name__ == '__main__': simcalls, simcalls_dict = parse('simcalls.in') @@ -277,7 +283,7 @@ if __name__ == '__main__': # popping_accessors.hpp # fd = header('popping_accessors.hpp') - fd.write('#include "src/simix/popping_private.hpp"'); + fd.write('#include "src/simix/popping_private.hpp"') handle(fd, Simcall.accessors, simcalls, simcalls_dict) fd.write( "\n\n/* The prototype of all simcall handlers, automatically generated for you */\n\n") @@ -384,5 +390,5 @@ inline static R simcall(e_smx_simcall_t call, T const&... t) } ''') handle(fd, Simcall.body, simcalls, simcalls_dict) - fd.write(" /** @endcond */\n"); + fd.write(" /** @endcond */\n") fd.close() diff --git a/tools/appveyor-irc-notify.py b/tools/appveyor-irc-notify.py index 84b70b7f4c..463104f386 100644 --- a/tools/appveyor-irc-notify.py +++ b/tools/appveyor-irc-notify.py @@ -62,7 +62,11 @@ in Appveyor's YAML: """ -import random, socket, ssl, sys, time +import random +import socket +import ssl +import sys +import time def appveyor_vars(): @@ -170,7 +174,7 @@ if __name__ == '__main__': # leave the channel irc_sock.send('PART #{}\r\n'.format(channel).encode('utf_8')) sys.exit() - except: + except BaseException: e = sys.exc_info()[0] print(e) sys.exit() diff --git a/tools/sg_xml_unit_converter.py b/tools/sg_xml_unit_converter.py index b68e431840..f7cc5c4fd9 100644 --- a/tools/sg_xml_unit_converter.py +++ b/tools/sg_xml_unit_converter.py @@ -49,6 +49,7 @@ def convert(xml, formats, attrib): def formats(ll): return sorted(((Decimal(i), j) for i, j in ll), key=lambda x: x[0], reverse=True) + for root, dirnames, filenames in os.walk(sys.argv[1]): for filename in fnmatch.filter(filenames, '*.xml'): print root, dirnames, filename diff --git a/tools/simgrid_convert_TI_traces.py b/tools/simgrid_convert_TI_traces.py index f1a5ed7bd3..995d3288b6 100755 --- a/tools/simgrid_convert_TI_traces.py +++ b/tools/simgrid_convert_TI_traces.py @@ -35,7 +35,7 @@ def convert_trace(trace_path, base_path, output_path, trace_version="1.0"): new_file_path = os.path.join(output_path, trace_path) pathlib.Path(os.path.dirname(new_file_path)).mkdir( - parents=True, exist_ok=True) + parents=True, exist_ok=True) with open(new_file_path, "w") as new_trace: # Write header @@ -44,7 +44,7 @@ def convert_trace(trace_path, base_path, output_path, trace_version="1.0"): last_async_call_src = None last_async_call_dst = None for line_num, line in enumerate(trace_file.readlines()): - #print(line) + # print(line) new_line = None split_line = line.lower().strip().split(" ") mpi_call = split_line[1] @@ -63,8 +63,8 @@ def convert_trace(trace_path, base_path, output_path, trace_version="1.0"): if (last_async_call_src is None or last_async_call_dst is None): raise Exception("Invalid traces: No Isend or Irecv " - "found before the wait in line " + - str(line_num) + " in file " + old_file_path ) + "found before the wait in line " + + str(line_num) + " in file " + old_file_path) new_line = insert_elem(split_line, 2, last_async_call_src) new_line = insert_elem(split_line, 3, last_async_call_dst) new_line = insert_elem(split_line, 4, "0") @@ -81,14 +81,13 @@ if __name__ == "__main__": import argparse import sys - parser = argparse.ArgumentParser(description=sys.modules[__name__].__doc__) parser.add_argument('trace_list_file', type=argparse.FileType('r'), - default=sys.stdin, help="The trace list file (e.g. smpi_simgrid.txt)") + default=sys.stdin, help="The trace list file (e.g. smpi_simgrid.txt)") parser.add_argument('--output_path', '-o', default="converted_traces", - help="The path where converted traces will be put") + help="The path where converted traces will be put") args = parser.parse_args() @@ -96,7 +95,7 @@ if __name__ == "__main__": # creates results dir pathlib.Path(args.output_path).mkdir( - parents=True, exist_ok=True) + parents=True, exist_ok=True) # copy trace list file try: @@ -106,7 +105,6 @@ if __name__ == "__main__": "Please, select another output path") sys.exit(-1) - with open(trace_list_file_path) as tracelist_file: trace_list = tracelist_file.readlines() diff --git a/tools/tesh/tesh.py b/tools/tesh/tesh.py index 16116ee001..dc7b629bb3 100755 --- a/tools/tesh/tesh.py +++ b/tools/tesh/tesh.py @@ -26,7 +26,8 @@ under the terms of the license (GNU LGPL) which comes with this package. """ -import sys, os +import sys +import os import shlex import re import difflib @@ -45,57 +46,65 @@ else: # # + def isWindows(): return sys.platform.startswith('win') # Singleton metaclass that works in Python 2 & 3 # http://stackoverflow.com/questions/6760685/creating-a-singleton-in-python + + class _Singleton(type): """ A metaclass that creates a Singleton base class when called. """ _instances = {} + def __call__(cls, *args, **kwargs): if cls not in cls._instances: cls._instances[cls] = super(_Singleton, cls).__call__(*args, **kwargs) return cls._instances[cls] -class Singleton(_Singleton('SingletonMeta', (object,), {})): pass -SIGNALS_TO_NAMES_DICT = dict((getattr(signal, n), n) \ - for n in dir(signal) if n.startswith('SIG') and '_' not in n ) +class Singleton(_Singleton('SingletonMeta', (object,), {})): + pass + + +SIGNALS_TO_NAMES_DICT = dict((getattr(signal, n), n) + for n in dir(signal) if n.startswith('SIG') and '_' not in n) -#exit correctly +# exit correctly def tesh_exit(errcode): - #If you do not flush some prints are skipped + # If you do not flush some prints are skipped sys.stdout.flush() - #os._exit exit even when executed within a thread + # os._exit exit even when executed within a thread os._exit(errcode) def fatal_error(msg): - print("[Tesh/CRITICAL] "+str(msg)) + print("[Tesh/CRITICAL] " + str(msg)) tesh_exit(1) -#Set an environment variable. +# Set an environment variable. # arg must be a string with the format "variable=value" def setenv(arg): - print("[Tesh/INFO] setenv "+arg) + print("[Tesh/INFO] setenv " + arg) t = arg.split("=", 1) os.environ[t[0]] = t[1] - #os.putenv(t[0], t[1]) does not work - #see http://stackoverflow.com/questions/17705419/python-os-environ-os-putenv-usr-bin-env + # os.putenv(t[0], t[1]) does not work + # see http://stackoverflow.com/questions/17705419/python-os-environ-os-putenv-usr-bin-env -#http://stackoverflow.com/questions/30734967/how-to-expand-environment-variables-in-python-as-bash-does +# http://stackoverflow.com/questions/30734967/how-to-expand-environment-variables-in-python-as-bash-does def expandvars2(path): return re.sub(r'(? timeout after "+str(self.timeout)+" sec)") + print("Test suite `" + FileReader().filename + "': NOK (<" + + cmdName + "> timeout after " + str(self.timeout) + " sec)") kill_process_group(pgtokill) tesh_exit(3) if self.output_display: print(stdout_data) - #remove text colors + # remove text colors ansi_escape = re.compile(r'\x1b[^m]*m') stdout_data = ansi_escape.sub('', stdout_data) #print ((stdout_data, stderr_data)) if self.ignore_output: - print("(ignoring the output of <"+cmdName+"> as requested)") + print("(ignoring the output of <" + cmdName + "> as requested)") else: stdouta = stdout_data.split("\n") while len(stdouta) > 0 and stdouta[-1] == "": @@ -374,13 +396,19 @@ class Cmd(object): stdouta.sort(key=lambda x: x[:self.sort].lower()) self.output_pipe_stdout.sort(key=lambda x: x[:self.sort].lower()) - diff = list(difflib.unified_diff(self.output_pipe_stdout, stdouta,lineterm="",fromfile='expected', tofile='obtained')) + diff = list( + difflib.unified_diff( + self.output_pipe_stdout, + stdouta, + lineterm="", + fromfile='expected', + tofile='obtained')) if len(diff) > 0: - print("Output of <"+cmdName+"> mismatch:") - if self.sort >= 0: # If sorted, truncate the diff output and show the unsorted version - difflen = 0; + print("Output of <" + cmdName + "> mismatch:") + if self.sort >= 0: # If sorted, truncate the diff output and show the unsorted version + difflen = 0 for line in diff: - if difflen<50: + if difflen < 50: print(line) difflen += 1 if difflen > 50: @@ -388,46 +416,48 @@ class Cmd(object): print("Unsorted observed output:\n") for line in stdcpy: print(line) - else: # If not sorted, just display the diff + else: # If not sorted, just display the diff for line in diff: print(line) - print("Test suite `"+FileReader().filename+"': NOK (<"+cmdName+"> output mismatch)") - if lock is not None: lock.release() + print("Test suite `" + FileReader().filename + "': NOK (<" + cmdName + "> output mismatch)") + if lock is not None: + lock.release() if TeshState().keep: - f = open('obtained','w') + f = open('obtained', 'w') obtained = stdout_data.split("\n") while len(obtained) > 0 and obtained[-1] == "": del obtained[-1] obtained = self.remove_ignored_lines(obtained) for line in obtained: - f.write("> "+line+"\n") + f.write("> " + line + "\n") f.close() - print("Obtained output kept as requested: "+os.path.abspath("obtained")) + print("Obtained output kept as requested: " + os.path.abspath("obtained")) tesh_exit(2) #print ((proc.returncode, self.expect_return)) if proc.returncode != self.expect_return: if proc.returncode >= 0: - print("Test suite `"+FileReader().filename+"': NOK (<"+cmdName+"> returned code "+str(proc.returncode)+")") - if lock is not None: lock.release() + print("Test suite `" + FileReader().filename + "': NOK (<" + + cmdName + "> returned code " + str(proc.returncode) + ")") + if lock is not None: + lock.release() tesh_exit(2) else: - print("Test suite `"+FileReader().filename+"': NOK (<"+cmdName+"> got signal "+SIGNALS_TO_NAMES_DICT[-proc.returncode]+")") - if lock is not None: lock.release() + print("Test suite `" + FileReader().filename + "': NOK (<" + cmdName + + "> got signal " + SIGNALS_TO_NAMES_DICT[-proc.returncode] + ")") + if lock is not None: + lock.release() tesh_exit(-proc.returncode) - if lock is not None: lock.release() - - + if lock is not None: + lock.release() def can_run(self): return self.args is not None - - ############## # # Main @@ -435,7 +465,6 @@ class Cmd(object): # - if __name__ == '__main__': signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGTERM, signal_handler) @@ -443,13 +472,22 @@ if __name__ == '__main__': parser = argparse.ArgumentParser(description='tesh -- testing shell', add_help=True) group1 = parser.add_argument_group('Options') group1.add_argument('teshfile', nargs='?', help='Name of teshfile, stdin if omitted') - group1.add_argument('--cd', metavar='some/directory', help='ask tesh to switch the working directory before launching the tests') + group1.add_argument( + '--cd', + metavar='some/directory', + help='ask tesh to switch the working directory before launching the tests') group1.add_argument('--setenv', metavar='var=value', action='append', help='set a specific environment variable') group1.add_argument('--cfg', metavar='arg', action='append', help='add parameter --cfg=arg to each command line') group1.add_argument('--log', metavar='arg', action='append', help='add parameter --log=arg to each command line') - group1.add_argument('--ignore-jenkins', action='store_true', help='ignore all cruft generated on SimGrid continous integration servers') + group1.add_argument( + '--ignore-jenkins', + action='store_true', + help='ignore all cruft generated on SimGrid continous integration servers') group1.add_argument('--wrapper', metavar='arg', help='Run each command in the provided wrapper (eg valgrind)') - group1.add_argument('--keep', action='store_true', help='Keep the obtained output when it does not match the expected one') + group1.add_argument( + '--keep', + action='store_true', + help='Keep the obtained output when it does not match the expected one') try: options = parser.parse_args() @@ -464,32 +502,33 @@ if __name__ == '__main__': print("Ignore all cruft seen on SimGrid's continous integration servers") # Note: regexps should match at the beginning of lines TeshState().ignore_regexps_common = [ - re.compile(r"profiling:"), - re.compile(r"Unable to clean temporary file C:"), - re.compile(r".*Configuration change: Set 'contexts/"), - re.compile(r"Picked up JAVA_TOOL_OPTIONS: "), - re.compile(r"Picked up _JAVA_OPTIONS: "), - re.compile(r"==[0-9]+== ?WARNING: ASan doesn't fully support"), - re.compile(r"==[0-9]+== ?WARNING: ASan is ignoring requested __asan_handle_no_return: stack top:"), - re.compile(r"False positive error reports may follow"), - re.compile(r"For details see http://code.google.com/p/address-sanitizer/issues/detail\?id=189"), - re.compile(r"For details see https://github.com/google/sanitizers/issues/189"), - re.compile(r"Python runtime initialized with LC_CTYPE=C .*"), - re.compile(r"cmake: /usr/local/lib/libcurl\.so\.4: no version information available \(required by cmake\)"), # Seen on CircleCI - re.compile(r".*mmap broken on FreeBSD, but dlopen\+thread broken too. Switching to dlopen\+raw contexts\."), - re.compile(r".*dlopen\+thread broken on Apple and BSD\. Switching to raw contexts\."), - ] - TeshState().jenkins = True # This is a Jenkins build + re.compile(r"profiling:"), + re.compile(r"Unable to clean temporary file C:"), + re.compile(r".*Configuration change: Set 'contexts/"), + re.compile(r"Picked up JAVA_TOOL_OPTIONS: "), + re.compile(r"Picked up _JAVA_OPTIONS: "), + re.compile(r"==[0-9]+== ?WARNING: ASan doesn't fully support"), + re.compile(r"==[0-9]+== ?WARNING: ASan is ignoring requested __asan_handle_no_return: stack top:"), + re.compile(r"False positive error reports may follow"), + re.compile(r"For details see http://code.google.com/p/address-sanitizer/issues/detail\?id=189"), + re.compile(r"For details see https://github.com/google/sanitizers/issues/189"), + re.compile(r"Python runtime initialized with LC_CTYPE=C .*"), + # Seen on CircleCI + re.compile(r"cmake: /usr/local/lib/libcurl\.so\.4: no version information available \(required by cmake\)"), + re.compile(r".*mmap broken on FreeBSD, but dlopen\+thread broken too. Switching to dlopen\+raw contexts\."), + re.compile(r".*dlopen\+thread broken on Apple and BSD\. Switching to raw contexts\."), + ] + TeshState().jenkins = True # This is a Jenkins build if options.teshfile is None: f = FileReader(None) print("Test suite from stdin") else: if not os.path.isfile(options.teshfile): - print("Cannot open teshfile '"+options.teshfile+"': File not found") + print("Cannot open teshfile '" + options.teshfile + "': File not found") tesh_exit(3) f = FileReader(options.teshfile) - print("Test suite '"+f.abspath+"'") + print("Test suite '" + f.abspath + "'") if options.setenv is not None: for e in options.setenv: @@ -508,14 +547,14 @@ if __name__ == '__main__': if options.keep: TeshState().keep = True - #cmd holds the current command line + # cmd holds the current command line # tech commands will add some parameters to it # when ready, we execute it. cmd = Cmd() line = f.readfullline() while line is not None: - #print(">>============="+line+"==<<") + # print(">>============="+line+"==<<") if len(line) == 0: #print ("END CMD block") if cmd.run_if_possible(): @@ -525,7 +564,7 @@ if __name__ == '__main__': pass elif line[0:2] == "p ": - print("["+str(FileReader())+"] "+line[2:]) + print("[" + str(FileReader()) + "] " + line[2:]) elif line[0:2] == "< ": cmd.add_input_pipe(line[2:]) @@ -559,11 +598,11 @@ if __name__ == '__main__': #print("expect return "+str(int(line[16:]))) elif line[0:15] == "! expect signal": sig = line[16:] - #get the signal integer value from the signal module + # get the signal integer value from the signal module if sig not in signal.__dict__: - fatal_error("unrecognized signal '"+sig+"'") + fatal_error("unrecognized signal '" + sig + "'") sig = int(signal.__dict__[sig]) - #popen return -signal when a process ends with a signal + # popen return -signal when a process ends with a signal cmd.expect_return = -sig elif line[0:len("! timeout ")] == "! timeout ": if "no" in line[len("! timeout "):]: @@ -586,7 +625,6 @@ if __name__ == '__main__': else: fatal_error("UNRECOGNIZED OPTION") - line = f.readfullline() cmd.run_if_possible() @@ -596,4 +634,4 @@ if __name__ == '__main__': if f.filename == "(stdin)": print("Test suite from stdin OK") else: - print("Test suite `"+f.filename+"' OK") + print("Test suite `" + f.filename + "' OK")