Exemplo n.º 1
0
    def runall(self, compiler=None):
        """Compiles and runs each new or modified unit test executable.
        After the run is complete, the outcomes are checked for consistency.

        :arg compiler: the name of the compiler in 'compilers.xml' to use.
        """
        #We will likely need a file comparer for the outcomes testing
        self.comparer = FileComparer(self.fortpy_templates,
                                     self.compare_templates)

        if self._written:
            self.set_compiler(compiler)

            from fortpy.testing.compilers import replace
            from fortpy.testing.auxiliary import generate
            from fortpy.utility import symlink
            from fortpy.code import config
            #Run them each individually and return a dictionary of all the
            #test results
            result = {}
            fpyauxs = []
            for composite_id in self.tgenerator.tests_to_run:
                identifier, testid = composite_id.split("|")
                #Compile and copy fpy_auxiliary if it isn't in the identifiers directory yet.
                source = path.join(self.libraryroot(identifier), identifier)
                target = replace(source + ".[c]", self.compiler)
                if not path.isdir(target):
                    from os import mkdir
                    mkdir(target)
                if self.writer(
                        identifier).autoclass and identifier not in fpyauxs:
                    code, success, fpytarget = generate(
                        self.parser, self._codefolder,
                        self.libraryroot(identifier), self.compiler,
                        self.debug, self.profile, self.strict)
                    sopath = path.join(fpytarget, "fpy_aux.so")
                    sotarget = path.join(target, "fpy_aux.so")
                    mpath = path.join(fpytarget, "fpy_auxiliary.mod")
                    mtarget = path.join(target, "fpy_auxiliary.mod")
                    symlink(sopath, sotarget)
                    symlink(mpath, mtarget)
                    fpyauxs.append(identifier)

                oneresult = self._run_single(identifier, testid, source)
                if oneresult is not None:
                    result[composite_id] = oneresult

            return result
        else:
            msg.warn(
                "you can't run tests until the executables have been written. Exiting."
            )
            return None
Exemplo n.º 2
0
    def runall(self, compiler=None):
        """Compiles and runs each new or modified unit test executable.
        After the run is complete, the outcomes are checked for consistency.

        :arg compiler: the name of the compiler in 'compilers.xml' to use.
        """
        #We will likely need a file comparer for the outcomes testing
        self.comparer = FileComparer(self.fortpy_templates, self.compare_templates)

        if self._written:
            self.set_compiler(compiler)

            from fortpy.testing.compilers import replace
            from fortpy.testing.auxiliary import generate
            from fortpy.utility import symlink
            from fortpy.code import config
            #Run them each individually and return a dictionary of all the
            #test results
            result = {}
            fpyauxs= []            
            for composite_id in self.tgenerator.tests_to_run:
                identifier, testid = composite_id.split("|")
                #Compile and copy fpy_auxiliary if it isn't in the identifiers directory yet.
                source = path.join(self.libraryroot(identifier), identifier)
                target = replace(source + ".[c]", self.compiler)
                if not path.isdir(target):
                    from os import mkdir
                    mkdir(target)
                if self.writer(identifier).autoclass and identifier not in fpyauxs:
                    code, success, fpytarget = generate(self.parser, self._codefolder,
                                                        self.libraryroot(identifier), self.compiler,
                                                        self.debug, self.profile, self.strict)
                    sopath = path.join(fpytarget, "fpy_aux.so")
                    sotarget = path.join(target, "fpy_aux.so")
                    mpath = path.join(fpytarget, "fpy_auxiliary.mod")
                    mtarget = path.join(target, "fpy_auxiliary.mod")
                    symlink(sopath, sotarget)
                    symlink(mpath, mtarget)
                    fpyauxs.append(identifier)
                
                oneresult = self._run_single(identifier, testid, source)
                if oneresult is not None:
                    result[composite_id] = oneresult

            return result
        else:
            msg.warn("you can't run tests until the executables have been written. Exiting.")
            return None
Exemplo n.º 3
0
def _ensure_fileversion(compiler, modname, folder, target, trycompile=True):
    """Makes sure that the module's f90, mod and o files are up to date with the template
    version. If they aren't compile and copy them.

    :arg compiler: the compiler key from compilers.xml
    :arg modname: the name of the module to check file versions for and move (e.g. "fortpy").
    :arg folder: the folder that contains the up-to-date, "template" version of the module.
    :arg target: the folder to copy the compiled files to.
    :arg trycompile: if the codefile has not been compiled yet, or if the version is out of 
      date, should the code try a simple compile?
    """
    from os import path
    codefile = "{}.f90".format(modname)
    compfiles = ["{}.{}".format(modname, ext) for ext in ["o", "mod"]]

    tversion = template_version(compiler, codefile)
    for sdfile in compfiles:
        fdfile = replace(sdfile + ".[c]", compiler)
        ftarget = path.join(target, sdfile)
        dversion = get_fortpy_version(compiler, ftarget)

        if not path.isfile(ftarget) or dversion != tversion:
            source = path.join(folder, fdfile)
            sversion = get_fortpy_version(compiler, source)
            if trycompile and (not path.isfile(source)
                               or sversion != tversion):
                _compile_simple(compiler, [modname], folder)
                _vupdate_compiled_module(compiler, modname, folder, tversion)
            elif not path.isfile(source):
                msg.warn("{} does not exist.".format(source))
                continue
            elif sversion != tversion:
                msg.warn("{} has an old version number.".format(source))

            from fortpy.utility import symlink
            symlink(source, ftarget)
            #If the file is a binary, we need to save a .v with version
            #information as well for the next time we want to copy it.
            pre, ext = path.splitext(ftarget)
            if ext in [".o", ".so", ".mod"]:
                with open(ftarget + '.v', 'w') as f:
                    f.write("# <fortpy version=\"{}\" />".format('.'.join(
                        map(str, tversion))))
Exemplo n.º 4
0
def _ensure_fileversion(compiler, modname, folder, target, trycompile=True):
    """Makes sure that the module's f90, mod and o files are up to date with the template
    version. If they aren't compile and copy them.

    :arg compiler: the compiler key from compilers.xml
    :arg modname: the name of the module to check file versions for and move (e.g. "fortpy").
    :arg folder: the folder that contains the up-to-date, "template" version of the module.
    :arg target: the folder to copy the compiled files to.
    :arg trycompile: if the codefile has not been compiled yet, or if the version is out of 
      date, should the code try a simple compile?
    """
    from os import path
    codefile = "{}.f90".format(modname)
    compfiles = ["{}.{}".format(modname, ext) for ext in ["o", "mod"]]
    
    tversion = template_version(compiler, codefile)
    for sdfile in compfiles:
        fdfile = replace(sdfile + ".[c]", compiler)
        ftarget = path.join(target, sdfile)
        dversion = get_fortpy_version(compiler, ftarget)

        if not path.isfile(ftarget) or dversion != tversion:
            source = path.join(folder, fdfile)
            sversion = get_fortpy_version(compiler, source)
            if trycompile and (not path.isfile(source) or sversion != tversion):
                _compile_simple(compiler, [modname], folder)
                _vupdate_compiled_module(compiler, modname, folder, tversion)
            elif not path.isfile(source):
                msg.warn("{} does not exist.".format(source))
                continue
            elif sversion != tversion:
                msg.warn("{} has an old version number.".format(source))

            from fortpy.utility import symlink
            symlink(source, ftarget)
            #If the file is a binary, we need to save a .v with version
            #information as well for the next time we want to copy it.
            pre, ext = path.splitext(ftarget)
            if ext in [".o", ".so", ".mod"]:
                with open(ftarget + '.v', 'w') as f:
                    f.write("# <fortpy version=\"{}\" />".format('.'.join(map(str, tversion))))