Example #1
0
    def _compiler_exists(self):
        """Tests whether the specified compiler is available on the machine. If
        it isn't give an error and exit."""
        from fortpy.testing.compilers import compilers
        if self.compiler in compilers:
            #Overwrite the *name* of the compiler with its full path; since
            #fortpy assumes that self.compiler is the name of a valid executable
            #this will still work correctly.
            compiler = compilers[self.compiler].path
        else:
            compiler = self.compiler

        from fortpy.utility import which
        if which(compiler) is None:
            msg.err("compiler {} not found. Exiting.".format(self.compiler))
            exit(1)
Example #2
0
    def _compiler_exists(self):
        """Tests whether the specified compiler is available on the machine. If
        it isn't give an error and exit."""
        from fortpy.testing.compilers import compilers
        if self.compiler in compilers:
            #Overwrite the *name* of the compiler with its full path; since
            #fortpy assumes that self.compiler is the name of a valid executable
            #this will still work correctly.
            compiler = compilers[self.compiler].path
        else:
            compiler = self.compiler

        from fortpy.utility import which
        if which(compiler) is None:
            msg.err("compiler {} not found. Exiting.".format(self.compiler))
            exit(1)
Example #3
0
 def _profiler_exists(self, profile):
     """Tests whether we have gprof available to do the profiling of the methods
     to unit test.
     
     :arg profile: the value specified in the UnitTester constructor.
     """
     if profile==True:
         from fortpy.utility import which
         gprof = which("gprof")
         if gprof is None:
             msg.err("gprof is required to run profiling with fortpy.")
             exit(1)
         else:
             return True
     else:
         return False
Example #4
0
 def _profiler_exists(self, profile):
     """Tests whether we have gprof available to do the profiling of the methods
     to unit test.
     
     :arg profile: the value specified in the UnitTester constructor.
     """
     if profile == True:
         from fortpy.utility import which
         gprof = which("gprof")
         if gprof is None:
             msg.err("gprof is required to run profiling with fortpy.")
             exit(1)
         else:
             return True
     else:
         return False
Example #5
0
def _start_debug(wizard, parameter, target):
    """Starts a debug session for the unit test executable of the current test
    specification and case identifier.
    """
    from fortpy.utility import which
    if which("gdb"):
        #Give the user the option of setting some breakpoints. Basically, list the
        #1) main program entry, 2) list of pre-req calls before the executable,
        #3) executable itself.
        brks = ["Main Unit Test Entry Point.", wizard.xauto.signature]
        xnames = ["main", wizard.xauto.name]
        from fortpy.testing.elements import Executable
        for method in wizard.tauto.methods:
            if not isinstance(method, Executable):
                #This is an executable that needs to be called before the main one.
                brks.append(method.signature)
                xnames.append(method.name)

        bchoice = _prompt_general("Which methods would you like breakpoints for?", brks)
        #Start a gdb session for the compiled unit test executable of the active
        #test and test case.
        xs = []
        for x in bchoice:
            if x < len(xnames):
                xs.append("-ex '{}'".format(xnames[x]))

        from os import system, path
        from fortpy.testing.compilers import compile_general          
        xstage = path.join(wizard.stagedir, wizard.xauto.full_name)
        code, success, target = compile_general(xstage, wizard.compiler, wizard.tauto.identifier,
                                                True, quiet=True)
        testpath = _get_casepath(wizard)
        cmd = "cd {}; gdb {} -ex 'run' ../../{}.x"
        system(cmd.format(testpath, ' '.join(xs), wizard.tauto.identifier))
    else:
        msg.err("The GNU debugger 'gdb' is not available on the system.")