def _run_compile(self, identifier, testid, staging): """Compiles the executable that was created for the specified identifier, returns True if the compile was successful.""" #We need to make sure that the fpy_auxiliary .mod and .o files are available #if the test uses auto-class functionality. from os import path from fortpy.testing.compilers import compile_general msg.blank() code, success, target = compile_general(staging, self.compiler, testid, self.debug, self.profile, self.quiet, strict=self.strict) if not success: #There are 21 lines in the compile.log file when everything runs correctly #Overwrite code with a bad exit value since we have some other problems. code = 1 #If the executable exists, we could still prompt them to run it (in case the #additional lines were just warnings). exe = path.join(target, "{}.x".format(testid)) if path.isfile(exe): choice = raw_input("\nWould you still like to run the executable? ").lower() code = 0 if "y" in choice else code if "n" in choice: msg.err("Unit testing terminated by user.") exit(0) else: msg.err("Could not compile executable {}.x".format(testid)) exit(-1) return code == 0, target
def _compile(auxdir, compiler=None, debug=False, profile=False): """Compiles the auxiliary module to generate a .mod and a .o file. :arg auxdir: the auxiliary directory to compile in. :arg tversion: the template version of fpy_auxiliary.f90 from fortpy. Needed to determine if the code-specific module is out of date. :arg compiler: the key of the compiler from the compilers.xml or None for default. """ from fortpy.testing.compilers import compile_general return compile_general(auxdir, compiler, "fpy_aux", debug, profile, vupdates=["fpy_auxiliary"], quiet=True)
def _run_compile(self, identifier, testid, staging): """Compiles the executable that was created for the specified identifier, returns True if the compile was successful.""" #We need to make sure that the fpy_auxiliary .mod and .o files are available #if the test uses auto-class functionality. from os import path from fortpy.testing.compilers import compile_general msg.blank() code, success, target = compile_general(staging, self.compiler, testid, self.debug, self.profile, self.quiet, strict=self.strict) if not success: #There are 21 lines in the compile.log file when everything runs correctly #Overwrite code with a bad exit value since we have some other problems. code = 1 #If the executable exists, we could still prompt them to run it (in case the #additional lines were just warnings). exe = path.join(target, "{}.x".format(testid)) if path.isfile(exe): choice = raw_input( "\nWould you still like to run the executable? ").lower() code = 0 if "y" in choice else code if "n" in choice: msg.err("Unit testing terminated by user.") exit(0) else: msg.err("Could not compile executable {}.x".format(testid)) exit(-1) return code == 0, target
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.")