def get_inverse_dictionary(dataDict, field, srcdir): """ Create a dictionary with the values of field as the keys, and the name of the tests as the results. """ invDict = {} if field == 'name': invDict['name'] = [] for root in dataDict: for exfile in dataDict[root]: for test in dataDict[root][exfile]: if test in testparse.buildkeys: continue defroot = testparse.getDefaultOutputFileRoot(test) name = nameSpace(defroot, os.path.relpath(root, srcdir)) if field == 'name': invDict['name'].append(name) continue if field not in dataDict[root][exfile][test]: continue values = dataDict[root][exfile][test][field] for val in values.split(): if val in invDict: invDict[val].append(name) else: invDict[val] = [name] return invDict
def get_inverse_dictionary(dataDict,fields,srcdir): """ Create a dictionary with the values of field as the keys, and the name of the tests as the results. """ invDict={} # Comma-delimited lists denote union for field in fields.replace('|',',').split(','): if field not in invDict: if field == 'name': invDict[field]=[] # List for ease else: invDict[field]={} for root in dataDict: for exfile in dataDict[root]: for test in dataDict[root][exfile]: if test in testparse.buildkeys: continue defroot = testparse.getDefaultOutputFileRoot(test) fname=nameSpace(defroot,os.path.relpath(root,srcdir)) if field == 'name': invDict['name'].append(fname) continue if field not in dataDict[root][exfile][test]: continue values=dataDict[root][exfile][test][field] if not field == 'args' and not field == 'diff_args': for val in values.split(): if val in invDict[field]: invDict[field][val].append(fname) else: invDict[field][val] = [fname] else: # Args are funky. for varset in re.split('(^|\W)-(?=[a-zA-Z])',values): val=get_value(varset) if not val: continue if val in invDict[field]: invDict[field][val].append(fname) else: invDict[field][val] = [fname] # remove duplicate entries (multiple test/file) if not field == 'name': for val in invDict[field]: invDict[field][val]=list(set(invDict[field][val])) return invDict
def checkOutput(self, exfile, root, srcDict): """ Check and make sure the output files are in the output director """ debug = False rpath = self.srcrelpath(root) for test in srcDict: if test in self.buildkeys: continue if debug: print(rpath, exfile, test) if 'output_file' in srcDict[test]: output_file = srcDict[test]['output_file'] else: defroot = testparse.getDefaultOutputFileRoot(test) if 'TODO' in srcDict[test]: continue output_file = "output/" + defroot + ".out" fullout = os.path.join(root, output_file) if debug: print("---> ", fullout) if not os.path.exists(fullout): self.missing_files.append(fullout) return
def getSubstVars(self, testDict, rpath, testname): """ Create a dictionary with all of the variables that get substituted into the template commands found in example_template.py """ subst = {} # Handle defaults of testparse.acceptedkeys (e.g., ignores subtests) if 'nsize' not in testDict: testDict['nsize'] = '1' if 'timeoutfactor' not in testDict: testDict['timeoutfactor'] = "1" for ak in testparse.acceptedkeys: if ak == 'test': continue subst[ak] = (testDict[ak] if ak in testDict else '') # Now do other variables subst['execname'] = testDict['execname'] subst['error'] = '' if 'filter' in testDict: if testDict['filter'].startswith("Error:"): subst['error'] = "Error" subst['filter'] = testDict['filter'].lstrip("Error:") else: subst['filter'] = testDict['filter'] # Others subst['subargs'] = '' # Default. For variables override subst['srcdir'] = os.path.join(self.srcdir, rpath) subst['label_suffix'] = '' subst['comments'] = "\n#".join(subst['comments'].split("\n")) if subst['comments']: subst['comments'] = "#" + subst['comments'] subst['exec'] = "../" + subst['execname'] subst['testroot'] = self.testroot_dir subst['testname'] = testname dp = self.conf.get('DATAFILESPATH', '') subst[ 'datafilespath_line'] = 'DATAFILESPATH=${DATAFILESPATH:-"' + dp + '"}' # This is used to label some matrices subst['petsc_index_size'] = str(self.conf['PETSC_INDEX_SIZE']) subst['petsc_scalar_size'] = str(self.conf['PETSC_SCALAR_SIZE']) #Conf vars if self.petsc_arch.find('valgrind') >= 0: subst['mpiexec'] = 'petsc_mpiexec_valgrind ' + self.conf['MPIEXEC'] else: subst['mpiexec'] = self.conf['MPIEXEC'] subst['pkg_name'] = self.pkg_name subst['pkg_dir'] = self.pkg_dir subst['pkg_arch'] = self.petsc_arch subst['CONFIG_DIR'] = thisscriptdir subst['PETSC_BINDIR'] = os.path.join(self.petsc_dir, 'lib', 'petsc', 'bin') subst['diff'] = self.conf['DIFF'] subst['rm'] = self.conf['RM'] subst['grep'] = self.conf['GREP'] subst['petsc_lib_dir'] = self.conf['PETSC_LIB_DIR'] subst['wpetsc_dir'] = self.conf['wPETSC_DIR'] # Output file is special because of subtests override defroot = testparse.getDefaultOutputFileRoot(testname) if 'output_file' not in testDict: subst['output_file'] = "output/" + defroot + ".out" subst['redirect_file'] = defroot + ".tmp" subst['label'] = nameSpace(defroot, self.srcrelpath(subst['srcdir'])) # Add in the full path here. subst['output_file'] = os.path.join(subst['srcdir'], subst['output_file']) if not os.path.isfile( os.path.join(self.petsc_dir, subst['output_file'])): if not subst['TODO']: print("Warning: " + subst['output_file'] + " not found.") # Worry about alt files here -- see # src/snes/tutorials/output/ex22*.out altlist = [subst['output_file']] basefile, ext = os.path.splitext(subst['output_file']) for i in range(1, 9): altroot = basefile + "_alt" if i > 1: altroot = altroot + "_" + str(i) af = altroot + ".out" srcaf = os.path.join(subst['srcdir'], af) fullaf = os.path.join(self.petsc_dir, srcaf) if os.path.isfile(fullaf): altlist.append(srcaf) if len(altlist) > 1: subst['altfiles'] = altlist #if len(altlist)>1: print("Found alt files: ",altlist) subst['regexes'] = {} for subkey in subst: if subkey == 'regexes': continue if not isinstance(subst[subkey], str): continue patt = "@" + subkey.upper() + "@" subst['regexes'][subkey] = re.compile(patt) return subst