# Check if we should run only Python tests, use for quick testing if len(sys.argv) == 2 and sys.argv[1] == "--only-python": only_python = True else: only_python = False # Check if we should skip C++ demos if only_python: print "Skipping C++ demos" cppdemos = [] # Build prefix list prefixes = [""] mpi_prefix = "mpirun -np 3 " if has_mpi() and (has_parmetis() or has_scotch()): prefixes.append(mpi_prefix) else: print "Not running regression tests in parallel." # Allow to disable parallel testing if "DISABLE_PARALLEL_TESTING" in os.environ: prefixes = [""] # Run in serial, then in parallel for prefix in prefixes: # List of demos to run if prefix == mpi_prefix: cppdemos_to_run = list(set(cppdemos) - set(not_working_in_parallel)) pydemos_to_run = list(set(pydemos) - set(not_working_in_parallel))
# # Modified by Johan Hake # Modified by Johannes Ring 2011 # Modified by Garth N. Wells 2013 # # First added: 2009-08-17 # Last changed: 2013-07-06 import sys import subprocess from dolfin import has_mpi, has_parmetis, has_scotch if not (has_mpi()): print "DOLFIN has not been compiled with MPI. Test is not run." sys.exit(0) elif not (has_parmetis() or has_scotch()): print "DOLFIN has not been compiled with ParMETIS or SCOTCH. Test is not run." sys.exit(0) # Number of processes num_processes = 3 # Run solver.py output = subprocess.check_output(['mpirun', '-np', str(num_processes), sys.executable, 'solver.py']) if len(sys.argv) > 1 and sys.argv[1] == "--debug": print output # Return exit status if "ERROR" in output: print output
def main(): # Location of all demos demodir = os.path.join(os.curdir, "..", "..", "demo") appsdir = os.path.join(os.curdir, "..", "..", "apps") rootdir = os.path.abspath(os.curdir) # List of demos that have demo dir but are not currently implemented # NOTE: Demo must be listed here iff unimplemented otherwse the test will # fail. This is meant to protect against usual bad named demos not # executed for ages in regression tests. not_implemented = [] # Demos to run cppdemos = [] pydemos = [] for dpath, dnames, fnames in chain(os.walk(demodir), os.walk(appsdir)): if os.path.basename(dpath) == 'cpp': if os.path.isfile(os.path.join(dpath, 'Makefile')): cppdemos.append(dpath) assert not dpath in not_implemented, \ "Demo '%s' marked as not_implemented" % dpath else: assert dpath in not_implemented, \ "Non-existing demo '%s' not marked as not_implemented" % dpath elif os.path.basename(dpath) == 'python': tmp = dpath.split(os.path.sep)[-2] if os.path.isfile(os.path.join(dpath, 'demo_' + tmp + '.py')): pydemos.append(dpath) assert not dpath in not_implemented, \ "Demo '%s' marked as not_implemented" % dpath else: assert dpath in not_implemented, \ "Non-existing demo '%s' not marked as not_implemented" % dpath # This is the codepath currently followed in FENaPack else: for f in fnames: if len(f) > 3 and f[-3:] == '.py': pydemos.append(os.path.join(dpath, f)) # Set non-interactive os.putenv('DOLFIN_NOPLOT', '1') print("Running all demos (non-interactively)") print("") print("Found %d C++ demos" % len(cppdemos)) print("Found %d Python demos" % len(pydemos)) print("") import pprint # Push slow demos to the end pyslow = [] cppslow = [] for s in pyslow: if s in pydemos: pydemos.remove(s) pydemos.append(s) for s in cppslow: if s in cppdemos: cppdemos.remove(s) cppdemos.append(s) # List of demos that throw expected errors in parallel not_working_in_parallel = [] failed = [] timing = [] # Check if we should run only Python tests, use for quick testing if len(sys.argv) == 2 and sys.argv[1] == "--only-python": only_python = True else: only_python = False # Check if we should skip C++ demos if only_python: print("Skipping C++ demos") cppdemos = [] # Build prefix list prefixes = [""] mpi_prefix = "mpirun -np %s " % os.environ.get("NP", 3) if has_mpi() and (has_parmetis() or has_scotch()): prefixes.append(mpi_prefix) else: print("Not running regression tests in parallel.") # Allow to disable parallel testing if "DISABLE_PARALLEL_TESTING" in os.environ: prefixes = [""] # Run in serial, then in parallel for prefix in prefixes: # List of demos to run if prefix == mpi_prefix: cppdemos_to_run = list(set(cppdemos) - set(not_working_in_parallel)) pydemos_to_run = list(set(pydemos) - set(not_working_in_parallel)) else: cppdemos_to_run = cppdemos pydemos_to_run = pydemos # Run demos for demo in cppdemos_to_run: run_cpp_demo(prefix, demo, rootdir, timing, failed) for demo in pydemos_to_run: run_python_demo(prefix, demo, rootdir, timing, failed) # Print summary of time to run demos timing.sort() print("") print("Time to run demos:") print("\n".join("%.2fs: %s" % t for t in timing)) total_no_demos = len(pydemos) if not only_python: total_no_demos += len(cppdemos) # Print output for failed tests print("") if len(failed) > 0: print("%d demo(s) out of %d failed, see demo.log for details." % (len(failed), total_no_demos)) file = open("demo.log", "w") for (test, interface, prefix, output) in failed: file.write("----------------------------------------------------------------------\n") file.write("%s%s (%s)\n" % (prefix, test, interface)) file.write("\n") file.write(output) file.write("\n") file.write("\n") else: print("All demos checked: OK") # Return error code if tests failed return len(failed)
def main(): # Location of all demos demodir = os.path.join(os.curdir, "..", "..", "demo") rootdir = os.path.abspath(os.curdir) # List of demos that have demo dir but are not currently implemented # NOTE: Demo must be listed here iff unimplemented otherwse the test will # fail. This is meant to protect against usual bad named demos not # executed for ages in regression tests. not_implemented = \ [os.path.join(demodir, 'undocumented', 'projection-interpolation', 'cpp'), os.path.join(demodir, 'undocumented', 'interpolation', 'cpp'), os.path.join(demodir, 'undocumented', 'adaptive-poisson', 'cpp'), os.path.join(demodir, 'undocumented', 'multistage-solver', 'cpp'), os.path.join(demodir, 'undocumented', 'smoothing', 'cpp'), os.path.join(demodir, 'undocumented', 'overlapping-regions', 'cpp'), os.path.join(demodir, 'undocumented', 'sub-function-assignment', 'cpp'), os.path.join(demodir, 'undocumented', 'compiled-extension-module', 'cpp'), os.path.join(demodir, 'undocumented', 'timing', 'cpp'), os.path.join(demodir, 'undocumented', 'mplot', 'cpp'), os.path.join(demodir, 'undocumented', 'coordinates', 'cpp'), os.path.join(demodir, 'documented', 'stokes-mini', 'cpp'), os.path.join(demodir, 'documented', 'tensor-weighted-poisson', 'cpp'), os.path.join(demodir, 'documented', 'subdomains-poisson', 'cpp'), ] # Demos to run cppdemos = [] pydemos = [] for dpath, dnames, fnames in os.walk(demodir): if os.path.basename(dpath) == 'cpp': if os.path.isfile(os.path.join(dpath, 'Makefile')): cppdemos.append(dpath) assert not dpath in not_implemented, \ "Demo '%s' marked as not_implemented" % dpath else: assert dpath in not_implemented, \ "Non-existing demo '%s' not marked as not_implemented" % dpath elif os.path.basename(dpath) == 'python': tmp = dpath.split(os.path.sep)[-2] if os.path.isfile(os.path.join(dpath, 'demo_' + tmp + '.py')): pydemos.append(dpath) assert not dpath in not_implemented, \ "Demo '%s' marked as not_implemented" % dpath else: assert dpath in not_implemented, \ "Non-existing demo '%s' not marked as not_implemented" % dpath # Set non-interactive os.putenv('DOLFIN_NOPLOT', '1') print("Running all demos (non-interactively)") print("") print("Found %d C++ demos" % len(cppdemos)) print("Found %d Python demos" % len(pydemos)) print("") import pprint # Push slow demos to the end pyslow = [] cppslow = [] for s in pyslow: if s in pydemos: pydemos.remove(s) pydemos.append(s) for s in cppslow: if s in cppdemos: cppdemos.remove(s) cppdemos.append(s) # List of demos that throw expected errors in parallel not_working_in_parallel = \ [os.path.join(demodir, 'undocumented', 'adaptive-poisson', 'python'), os.path.join(demodir, 'undocumented', 'auto-adaptive-navier-stokes', 'cpp'), os.path.join(demodir, 'undocumented', 'auto-adaptive-navier-stokes', 'python'), os.path.join(demodir, 'documented', 'auto-adaptive-poisson', 'cpp'), os.path.join(demodir, 'documented', 'auto-adaptive-poisson', 'python'), os.path.join(demodir, 'undocumented', 'eval', 'cpp'), os.path.join(demodir, 'undocumented', 'eval', 'python'), os.path.join(demodir, 'undocumented', 'extrapolation', 'cpp'), os.path.join(demodir, 'undocumented', 'extrapolation', 'python'), os.path.join(demodir, 'undocumented', 'meshfunction-refinement', 'cpp'), os.path.join(demodir, 'undocumented', 'nonmatching-interpolation', 'cpp'), os.path.join(demodir, 'undocumented', 'nonmatching-interpolation', 'python'), os.path.join(demodir, 'undocumented', 'nonmatching-projection', 'cpp'), os.path.join(demodir, 'undocumented', 'nonmatching-projection', 'python'), os.path.join(demodir, 'undocumented', 'poisson-disc', 'python'), os.path.join(demodir, 'undocumented', 'poisson-disc', 'cpp'), os.path.join(demodir, 'undocumented', 'smoothing', 'python'), os.path.join(demodir, 'documented', 'subdomains', 'cpp'), os.path.join(demodir, 'documented', 'subdomains', 'python'), os.path.join(demodir, 'undocumented', 'submesh', 'cpp'), os.path.join(demodir, 'undocumented', 'submesh', 'python'), os.path.join(demodir, 'undocumented', 'time-series', 'cpp'), os.path.join(demodir, 'undocumented', 'time-series', 'python'), os.path.join(demodir, 'undocumented', 'triangulate', 'cpp'), os.path.join(demodir, 'undocumented', 'triangulate', 'python'), os.path.join(demodir, 'undocumented', 'poisson1D-in-2D', 'cpp'), os.path.join(demodir, 'undocumented', 'poisson1D-in-2D', 'python'), os.path.join(demodir, 'undocumented', 'compiled-extension-module', 'python'), os.path.join(demodir, 'undocumented', 'coordinates', 'python'), ] failed = [] timing = [] # Check if we should run only Python tests, use for quick testing if len(sys.argv) == 2 and sys.argv[1] == "--only-python": only_python = True else: only_python = False # Check if we should skip C++ demos if only_python: print("Skipping C++ demos") cppdemos = [] # Build prefix list prefixes = [""] mpi_prefix = "mpirun -np 3 " if has_mpi() and (has_parmetis() or has_scotch()): prefixes.append(mpi_prefix) else: print("Not running regression tests in parallel.") # Allow to disable parallel testing if "DISABLE_PARALLEL_TESTING" in os.environ: prefixes = [""] # Run in serial, then in parallel for prefix in prefixes: # List of demos to run if prefix == mpi_prefix: cppdemos_to_run = list( set(cppdemos) - set(not_working_in_parallel)) pydemos_to_run = list(set(pydemos) - set(not_working_in_parallel)) else: cppdemos_to_run = cppdemos pydemos_to_run = pydemos # Run demos for demo in cppdemos_to_run: run_cpp_demo(prefix, demo, rootdir, timing, failed) for demo in pydemos_to_run: run_python_demo(prefix, demo, rootdir, timing, failed) # Print summary of time to run demos timing.sort() print("") print("Time to run demos:") print("\n".join("%.2fs: %s" % t for t in timing)) total_no_demos = len(pydemos) if not only_python: total_no_demos += len(cppdemos) # Print output for failed tests print("") if len(failed) > 0: print("%d demo(s) out of %d failed, see demo.log for details." % (len(failed), total_no_demos)) file = open("demo.log", "w") for (test, interface, prefix, output) in failed: file.write( "----------------------------------------------------------------------\n" ) file.write("%s%s (%s)\n" % (prefix, test, interface)) file.write("\n") file.write(output) file.write("\n") file.write("\n") else: print("All demos checked: OK") # Return error code if tests failed return len(failed)
def main(): # Location of all demos demodir = os.path.join(os.curdir, "..", "..", "demo") appsdir = os.path.join(os.curdir, "..", "..", "apps") rootdir = os.path.abspath(os.curdir) # List of demos that have demo dir but are not currently implemented # NOTE: Demo must be listed here iff unimplemented otherwse the test will # fail. This is meant to protect against usual bad named demos not # executed for ages in regression tests. not_implemented = [ os.path.join(demodir, "defcon", "navier-stokes.py"), os.path.join(demodir, "defcon", "mesh", "genmesh.py"), ] # Demos to run cppdemos = [] pydemos = [] for dpath, dnames, fnames in chain(os.walk(demodir), os.walk(appsdir)): if os.path.basename(dpath) == 'cpp': if os.path.isfile(os.path.join(dpath, 'Makefile')): cppdemos.append(dpath) assert not dpath in not_implemented, \ "Demo '%s' marked as not_implemented" % dpath else: assert dpath in not_implemented, \ "Non-existing demo '%s' not marked as not_implemented" % dpath elif os.path.basename(dpath) == 'python': tmp = dpath.split(os.path.sep)[-2] if os.path.isfile(os.path.join(dpath, 'demo_' + tmp + '.py')): pydemos.append(dpath) assert not dpath in not_implemented, \ "Demo '%s' marked as not_implemented" % dpath else: assert dpath in not_implemented, \ "Non-existing demo '%s' not marked as not_implemented" % dpath # This is the codepath currently followed in FENaPack else: for f in fnames: if len(f) > 3 and f[-3:] == '.py': d = os.path.join(dpath, f) if d in not_implemented: print( "***Skipping demo '%s' marked as not_implemented" % d) continue pydemos.append(d) print("Running all demos (non-interactively)") print("") print("Found %d C++ demos" % len(cppdemos)) print("Found %d Python demos" % len(pydemos)) print("") import pprint # Push slow demos to the end pyslow = [] cppslow = [] for s in pyslow: if s in pydemos: pydemos.remove(s) pydemos.append(s) for s in cppslow: if s in cppdemos: cppdemos.remove(s) cppdemos.append(s) # List of demos that throw expected errors in parallel not_working_in_parallel = [] failed = [] timing = [] # Check if we should run only Python tests, use for quick testing if len(sys.argv) == 2 and sys.argv[1] == "--only-python": only_python = True else: only_python = False # Check if we should skip C++ demos if only_python: print("Skipping C++ demos") cppdemos = [] # Build prefix list prefixes = [""] mpi_prefix = "mpirun -np %s " % os.environ.get("NP", 3) if has_mpi() and (has_parmetis() or has_scotch()): prefixes.append(mpi_prefix) else: print("Not running regression tests in parallel.") # Allow to disable parallel testing if "DISABLE_PARALLEL_TESTING" in os.environ: prefixes = [""] # Run in serial, then in parallel for prefix in prefixes: # List of demos to run if prefix == mpi_prefix: cppdemos_to_run = list( set(cppdemos) - set(not_working_in_parallel)) pydemos_to_run = list(set(pydemos) - set(not_working_in_parallel)) else: cppdemos_to_run = cppdemos pydemos_to_run = pydemos # Run demos for demo in cppdemos_to_run: run_cpp_demo(prefix, demo, rootdir, timing, failed) for demo in pydemos_to_run: run_python_demo(prefix, demo, rootdir, timing, failed) # Print summary of time to run demos timing.sort() print("") print("Time to run demos:") print("\n".join("%.2fs: %s" % t for t in timing)) total_no_demos = len(pydemos) if not only_python: total_no_demos += len(cppdemos) # Print output for failed tests print("") if len(failed) > 0: print("%d demo(s) out of %d failed, see demo.log for details." % (len(failed), total_no_demos)) file = open("demo.log", "w") for (test, interface, prefix, output) in failed: file.write( "----------------------------------------------------------------------\n" ) file.write("%s%s (%s)\n" % (prefix, test, interface)) file.write("\n") file.write(output) file.write("\n") file.write("\n") else: print("All demos checked: OK") # Return error code if tests failed return len(failed)
def main(): # Location of all demos demodir = os.path.join(os.curdir, "..", "..", "demo") rootdir = os.path.abspath(os.curdir) # List of demos that have demo dir but are not currently implemented # NOTE: Demo must be listed here iff unimplemented otherwse the test will # fail. This is meant to protect against usual bad named demos not # executed for ages in regression tests. not_implemented = \ [os.path.join(demodir, 'undocumented', 'projection-interpolation', 'cpp'), \ os.path.join(demodir, 'undocumented', 'interpolation', 'cpp'), \ os.path.join(demodir, 'undocumented', 'adaptive-poisson', 'cpp'), \ os.path.join(demodir, 'undocumented', 'multistage-solver', 'cpp'), \ os.path.join(demodir, 'undocumented', 'smoothing', 'cpp'), \ os.path.join(demodir, 'undocumented', 'overlapping-regions', 'cpp'), \ os.path.join(demodir, 'undocumented', 'sub-function-assignment', 'cpp'), \ os.path.join(demodir, 'undocumented', 'compiled-extension-module', 'cpp'), \ os.path.join(demodir, 'undocumented', 'timing', 'cpp'), \ os.path.join(demodir, 'documented', 'stokes-mini', 'cpp'), \ os.path.join(demodir, 'documented', 'tensor-weighted-poisson', 'cpp'), \ os.path.join(demodir, 'documented', 'subdomains-poisson', 'cpp'), \ ] # Demos to run cppdemos = [] pydemos = [] for dpath, dnames, fnames in os.walk(demodir): if os.path.basename(dpath) == 'cpp': if os.path.isfile(os.path.join(dpath, 'Makefile')): cppdemos.append(dpath) assert not dpath in not_implemented, \ "Demo '%s' marked as not_implemented" % dpath else: assert dpath in not_implemented, \ "Non-existing demo '%s' not marked as not_implemented" % dpath elif os.path.basename(dpath) == 'python': tmp = dpath.split(os.path.sep)[-2] if os.path.isfile(os.path.join(dpath, 'demo_' + tmp + '.py')): pydemos.append(dpath) assert not dpath in not_implemented, \ "Demo '%s' marked as not_implemented" % dpath else: assert dpath in not_implemented, \ "Non-existing demo '%s' not marked as not_implemented" % dpath # Set non-interactive os.putenv('DOLFIN_NOPLOT', '1') print("Running all demos (non-interactively)") print("") print("Found %d C++ demos" % len(cppdemos)) print("Found %d Python demos" % len(pydemos)) print("") import pprint # Push slow demos to the end pyslow = [] cppslow = [] for s in pyslow: if s in pydemos: pydemos.remove(s) pydemos.append(s) for s in cppslow: if s in cppdemos: cppdemos.remove(s) cppdemos.append(s) # List of demos that throw expected errors in parallel not_working_in_parallel = \ [os.path.join(demodir, 'undocumented', 'adaptive-poisson', 'python'), \ os.path.join(demodir, 'undocumented', 'auto-adaptive-navier-stokes', 'cpp'), \ os.path.join(demodir, 'undocumented', 'auto-adaptive-navier-stokes', 'python'), \ os.path.join(demodir, 'documented', 'auto-adaptive-poisson', 'cpp'), \ os.path.join(demodir, 'documented', 'auto-adaptive-poisson', 'python'), \ os.path.join(demodir, 'undocumented', 'eval', 'cpp'), \ os.path.join(demodir, 'undocumented', 'eval', 'python'), \ os.path.join(demodir, 'undocumented', 'extrapolation', 'cpp'), \ os.path.join(demodir, 'undocumented', 'extrapolation', 'python'), \ os.path.join(demodir, 'undocumented', 'meshfunction-refinement', 'cpp'), \ os.path.join(demodir, 'undocumented', 'nonmatching-interpolation', 'cpp'), \ os.path.join(demodir, 'undocumented', 'nonmatching-interpolation', 'python'), \ os.path.join(demodir, 'undocumented', 'nonmatching-projection', 'cpp'), \ os.path.join(demodir, 'undocumented', 'nonmatching-projection', 'python'), \ os.path.join(demodir, 'undocumented', 'smoothing', 'python'), \ os.path.join(demodir, 'documented', 'subdomains', 'cpp'), \ os.path.join(demodir, 'documented', 'subdomains', 'python'), \ os.path.join(demodir, 'undocumented', 'submesh', 'cpp'), \ os.path.join(demodir, 'undocumented', 'submesh', 'python'), \ os.path.join(demodir, 'undocumented', 'time-series', 'cpp'), \ os.path.join(demodir, 'undocumented', 'time-series', 'python'), \ os.path.join(demodir, 'undocumented', 'triangulate', 'cpp'), \ os.path.join(demodir, 'undocumented', 'triangulate', 'python'), \ os.path.join(demodir, 'undocumented', 'poisson1D-in-2D', 'cpp'), \ os.path.join(demodir, 'undocumented', 'poisson1D-in-2D', 'python'), \ os.path.join(demodir, 'undocumented', 'compiled-extension-module', 'python'), \ ] failed = [] timing = [] # Check if we should run only Python tests, use for quick testing if len(sys.argv) == 2 and sys.argv[1] == "--only-python": only_python = True else: only_python = False # Check if we should skip C++ demos if only_python: print("Skipping C++ demos") cppdemos = [] # Build prefix list prefixes = [""] mpi_prefix = "mpirun -np 3 " if has_mpi() and (has_parmetis() or has_scotch()): prefixes.append(mpi_prefix) else: print("Not running regression tests in parallel.") # Allow to disable parallel testing if "DISABLE_PARALLEL_TESTING" in os.environ: prefixes = [""] # Run in serial, then in parallel for prefix in prefixes: # List of demos to run if prefix == mpi_prefix: cppdemos_to_run = list(set(cppdemos) - set(not_working_in_parallel)) pydemos_to_run = list(set(pydemos) - set(not_working_in_parallel)) else: cppdemos_to_run = cppdemos pydemos_to_run = pydemos # Run demos for demo in cppdemos_to_run: run_cpp_demo(prefix, demo, rootdir, timing, failed) for demo in pydemos_to_run: run_python_demo(prefix, demo, rootdir, timing, failed) # Print summary of time to run demos timing.sort() print("") print("Time to run demos:") print("\n".join("%.2fs: %s" % t for t in timing)) total_no_demos = len(pydemos) if not only_python: total_no_demos += len(cppdemos) # Print output for failed tests print("") if len(failed) > 0: print("%d demo(s) out of %d failed, see demo.log for details." % \ (len(failed), total_no_demos)) file = open("demo.log", "w") for (test, interface, prefix, output) in failed: file.write("----------------------------------------------------------------------\n") file.write("%s%s (%s)\n" % (prefix, test, interface)) file.write("\n") file.write(output) file.write("\n") file.write("\n") else: print("All demos checked: OK") # Return error code if tests failed return len(failed)
def main(): # Check that we can find pylit.py for converting foo.py.rst to # foo.py pylit_parser = os.path.join(os.environ['PYLIT_DIR'], "pylit.py") if os.path.isfile(pylit_parser): pass else: raise RuntimeError("Cannot find pylit.py") # Location of all demos demodir = os.path.join(os.curdir, "..", "..", "demo") appsdir = os.path.join(os.curdir, "..", "..", "apps") rootdir = os.path.abspath(os.curdir) # List of demos that have demo dir but are not currently implemented # NOTE: Demo must be listed here iff unimplemented otherwse the test will # fail. This is meant to protect against usual bad named demos not # executed for ages in regression tests. not_implemented = [ os.path.join(demodir, "2phase-rising-bubble", "2phase-rising-bubble.py.rst"), ] # Demos to run cppdemos = [] pydemos = [] for dpath, dnames, fnames in chain(os.walk(demodir), os.walk(appsdir)): if os.path.basename(dpath) == 'cpp': if os.path.isfile(os.path.join(dpath, 'Makefile')): cppdemos.append(dpath) assert not dpath in not_implemented, \ "Demo '%s' marked as not_implemented" % dpath else: assert dpath in not_implemented, \ "Non-existing demo '%s' not marked as not_implemented" % dpath elif os.path.basename(dpath) == 'python': tmp = dpath.split(os.path.sep)[-2] if os.path.isfile(os.path.join(dpath, 'demo_' + tmp + '.py')): pydemos.append(dpath) assert not dpath in not_implemented, \ "Demo '%s' marked as not_implemented" % dpath else: assert dpath in not_implemented, \ "Non-existing demo '%s' not marked as not_implemented" % dpath # This is the codepath currently followed in MUFLON else: for f in fnames: # Run pylit on py.rst files (files with 'double extensions') if len(f) > 7 and f[-7:] == ".py.rst": rst_file = os.path.join(dpath, f) command = pylit_parser + " " + rst_file ret = os.system(command) if not ret == 0: print("***Unable to convert rst file to a .py ({})".format(f)) continue d = os.path.join(dpath, os.path.splitext(f)[0]) if d in not_implemented: print("***Skipping demo '%s' marked as not_implemented" % d) continue pydemos.append(d) # Store converted '.py' files for later manual garbage collection pydemos_2delete = pydemos cppdemos_2delete = cppdemos # Set non-interactive os.putenv('DOLFIN_NOPLOT', '1') print("Running all demos (non-interactively)") print("") print("Found %d C++ demos" % len(cppdemos)) print("Found %d Python demos" % len(pydemos)) print("") import pprint # Push slow demos to the end pyslow = [] cppslow = [] for s in pyslow: if s in pydemos: pydemos.remove(s) pydemos.append(s) for s in cppslow: if s in cppdemos: cppdemos.remove(s) cppdemos.append(s) # List of demos that throw expected errors in parallel not_working_in_parallel = [] failed = [] timing = [] # Check if we should run only Python tests, use for quick testing if len(sys.argv) == 2 and sys.argv[1] == "--only-python": only_python = True else: only_python = False # Check if we should skip C++ demos if only_python: print("Skipping C++ demos") cppdemos = [] # Build prefix list prefixes = [""] mpi_prefix = "mpirun -np %s " % os.environ.get("NP", 3) if has_mpi() and (has_parmetis() or has_scotch()): prefixes.append(mpi_prefix) else: print("Not running regression tests in parallel.") # Allow to disable parallel testing if "DISABLE_PARALLEL_TESTING" in os.environ: prefixes = [""] # Run in serial, then in parallel for prefix in prefixes: # List of demos to run if prefix == mpi_prefix: cppdemos_to_run = list(set(cppdemos) - set(not_working_in_parallel)) pydemos_to_run = list(set(pydemos) - set(not_working_in_parallel)) else: cppdemos_to_run = cppdemos pydemos_to_run = pydemos # Run demos for demo in cppdemos_to_run: run_cpp_demo(prefix, demo, rootdir, timing, failed) for demo in pydemos_to_run: run_python_demo(prefix, demo, rootdir, timing, failed) # Print summary of time to run demos timing.sort() print("") print("Time to run demos:") print("\n".join("%.2fs: %s" % t for t in timing)) total_no_demos = len(pydemos) if not only_python: total_no_demos += len(cppdemos) # Print output for failed tests print("") if len(failed) > 0: print("%d demo(s) out of %d failed, see demo.log for details." % (len(failed), total_no_demos)) file = open("demo.log", "w") for (test, interface, prefix, output) in failed: file.write("----------------------------------------------------------------------\n") file.write("%s%s (%s)\n" % (prefix, test, interface)) file.write("\n") file.write(output) file.write("\n") file.write("\n") else: print("All demos checked: OK") # Manual garbage collection # print("Removing all executable demo files") # for f in pydemos_2delete + cppdemos_2delete: # os.remove(f) # Return error code if tests failed return len(failed)
# # Modified by Johan Hake # Modified by Johannes Ring 2011 # Modified by Garth N. Wells 2013 # # First added: 2009-08-17 # Last changed: 2013-07-06 import sys import subprocess from dolfin import has_mpi, has_parmetis, has_scotch if not (has_mpi()): print "DOLFIN has not been compiled with MPI. Test is not run." sys.exit(0) elif not (has_parmetis() or has_scotch()): print "DOLFIN has not been compiled with ParMETIS or SCOTCH. Test is not run." sys.exit(0) # Number of processes num_processes = 3 # Run solver.py output = subprocess.check_output( ['mpirun', '-np', str(num_processes), sys.executable, 'solver.py']) if len(sys.argv) > 1 and sys.argv[1] == "--debug": print output # Return exit status if "ERROR" in output: