コード例 #1
0
ファイル: gmakegentest.py プロジェクト: petsc/petsc
  def genPetscTests(self,root,dirs,files,dataDict):
    """
     Go through and parse the source files in the directory to generate
     the examples based on the metadata contained in the source files
    """
    debug=False
    # Use examplesAnalyze to get what the makefles think are sources
    #self.examplesAnalyze(root,dirs,files,anlzDict)

    dataDict[root]={}

    for exfile in files:
      #TST: Until we replace files, still leaving the orginals as is
      #if not exfile.startswith("new_"+"ex"): continue
      #if not exfile.startswith("ex"): continue

      # Ignore emacs and other temporary files
      if exfile.startswith("."): continue
      if exfile.startswith("#"): continue
      if exfile.endswith("~"): continue
      # Only parse source files
      ext=os.path.splitext(exfile)[-1].lstrip('.')
      if ext not in LANGS: continue

      # Convenience
      fullex=os.path.join(root,exfile)
      if self.verbose: print('   --> '+fullex)
      dataDict[root].update(testparse.parseTestFile(fullex,0))
      if exfile in dataDict[root]:
        self.genScriptsAndInfo(exfile,root,dataDict[root][exfile])

    return
コード例 #2
0
ファイル: query_tests.py プロジェクト: miaodi/petsc
def walktree(top):
    """
    Walk a directory tree, starting from 'top'
    """
    verbose = False
    dataDict = {}
    alldatafiles = []
    for root, dirs, files in os.walk(top, topdown=False):
        if root == 'output': continue
        if '.dSYM' in root: continue
        if verbose: print(root)

        dataDict[root] = {}

        for exfile in files:
            # Ignore emacs files
            if exfile.startswith("#") or exfile.startswith(".#"): continue
            ext=os.path.splitext(exfile)[1]
            if ext[1:] not in ['c','cxx','cpp','cu','F90','F']: continue

            # Convenience
            fullex = os.path.join(root, exfile)
            if verbose: print('   --> '+fullex)
            dataDict[root].update(testparse.parseTestFile(fullex, 0))

    return dataDict
コード例 #3
0
    def genPetscTests(self, root, dirs, files, dataDict):
        """
     Go through and parse the source files in the directory to generate
     the examples based on the metadata contained in the source files
    """
        debug = False
        # Use examplesAnalyze to get what the makefles think are sources
        #self.examplesAnalyze(root,dirs,files,anlzDict)

        dataDict[root] = {}

        for exfile in files:
            #TST: Until we replace files, still leaving the orginals as is
            #if not exfile.startswith("new_"+"ex"): continue
            #if not exfile.startswith("ex"): continue

            # Ignore emacs and other temporary files
            if exfile.startswith("."): continue
            if exfile.startswith("#"): continue
            if exfile.endswith("~"): continue
            # Only parse source files
            ext = os.path.splitext(exfile)[-1].lstrip('.')
            if ext not in LANGS: continue

            # Convenience
            fullex = os.path.join(root, exfile)
            if self.verbose: print('   --> ' + fullex)
            dataDict[root].update(testparse.parseTestFile(fullex, 0))
            if exfile in dataDict[root]:
                self.genScriptsAndInfo(exfile, root, dataDict[root][exfile])

        return
コード例 #4
0
ファイル: gmakegentest.py プロジェクト: yangangchen/petsc
    def genPetscTests(self, root, dirs, files, dataDict):
        """
     Go through and parse the source files in the directory to generate
     the examples based on the metadata contained in the source files
    """
        debug = False
        # Use examplesAnalyze to get what the makefles think are sources
        #self.examplesAnalyze(root,dirs,files,anlzDict)

        dataDict[root] = {}

        for exfile in files:
            #TST: Until we replace files, still leaving the orginals as is
            #if not exfile.startswith("new_"+"ex"): continue
            if not exfile.startswith("ex"): continue

            # Convenience
            fullex = os.path.join(root, exfile)
            relpfile = self.relpath(self.petsc_dir, fullex)
            if debug: print relpfile
            dataDict[root].update(testparse.parseTestFile(fullex, 0))
            # Need to check and make sure tests are in the file
            # if verbosity>=1: print relpfile
            if exfile in dataDict[root]:
                self.genScriptsAndInfo(exfile, root, dataDict[root][exfile])

        return
コード例 #5
0
  def genPetscTests(self,root,dirs,files,dataDict):
    """
     Go through and parse the source files in the directory to generate
     the examples based on the metadata contained in the source files
    """
    debug=False
    # Use examplesAnalyze to get what the makefles think are sources
    #self.examplesAnalyze(root,dirs,files,anlzDict)

    dataDict[root]={}

    for exfile in files:
      #TST: Until we replace files, still leaving the orginals as is
      #if not exfile.startswith("new_"+"ex"): continue
      if not exfile.startswith("ex"): continue

      # Convenience
      fullex=os.path.join(root,exfile)
      relpfile=self.relpath(self.petsc_dir,fullex)
      if debug: print relpfile
      dataDict[root].update(testparse.parseTestFile(fullex))
      # Need to check and make sure tests are in the file
      # if verbosity>=1: print relpfile
      if dataDict[root].has_key(exfile):
        self.genScriptsAndInfo(exfile,root,dataDict[root][exfile])

    return
コード例 #6
0
ファイル: testharness_util.py プロジェクト: zhenguonie/petsc
def walktree(top, action, datafilespath=None):
    """
    Walk a directory tree, starting from 'top'
    """
    verbose = False
    d = {}
    alldatafiles = []
    for root, dirs, files in os.walk(top, topdown=False):
        if "examples" not in root: continue
        if root == 'output': continue
        if '.dSYM' in root: continue
        if verbose: print(root)

        for exfile in files:
            # Ignore emacs files
            if exfile.startswith("#") or exfile.startswith(".#"): continue
            ext=os.path.splitext(exfile)[1]
            if ext[1:] not in ['c','cxx','cpp','cu','F90','F']: continue

            # Convenience
            fullex = os.path.join(root, exfile)
            if verbose: print('   --> '+fullex)
            d[root] = testparse.parseTestFile(fullex, 0)
            if exfile in d[root]:
                for test in d[root][exfile]:
                    if 'args' in d[root][exfile][test]:
                        args = d[root][exfile][test]['args']
                        alldatafiles += get_datafiles(args)
                        if 'subtests' in d[root][exfile][test]:
                            for s in d[root][exfile][test]['subtests']:
                                if 'args' in d[root][exfile][test][s]:
                                    args = d[root][exfile][test][s]['args']
                                    alldatafiles += get_datafiles(args)

    # Make unique and sort
    alldatafiles = list(set(alldatafiles))
    alldatafiles.sort()

    if datafilespath:
        action = 'gen_dl_path'
    if action == 'print_datafiles':
        print('\n'.join(alldatafiles))
    if action == 'gen_dl_path':
        ftproot='http://ftp.mcs.anl.gov/pub/petsc/Datafiles/'
        for dfile in alldatafiles:
           fulldfile=os.path.join(datafilespath,dfile)
           if not os.path.exists(fulldfile):
              dl_dir=os.path.dirname(fulldfile)
              if not os.path.isdir(dl_dir):
                  try:
                     os.mkdir(dl_dir)
                  except:
                     os.mkdir(os.path.dirname(os.path.dirname(dl_dir)))
                     os.mkdir(os.path.dirname(dl_dir))
                     os.mkdir(dl_dir)
              dl_dfile=ftproot+dfile
              print('cd '+dl_dir+' && wget '+dl_dfile+'\n')

    return
コード例 #7
0
def walktree(top, action, datafilespath=None):
    """
    Walk a directory tree, starting from 'top'
    """
    verbose = False
    d = {}
    alldatafiles = []
    for root, dirs, files in os.walk(top, topdown=False):
        if "examples" not in root: continue
        if root == 'output': continue
        if '.dSYM' in root: continue
        if verbose: print(root)

        for exfile in files:
            # Ignore emacs files
            if exfile.startswith("#") or exfile.startswith(".#"): continue

            # Convenience
            fullex = os.path.join(root, exfile)
            if verbose: print('   --> '+fullex)
            d[root] = testparse.parseTestFile(fullex, 0)
            if exfile in d[root]:
                for test in d[root][exfile]:
                    if 'args' in d[root][exfile][test]:
                        args = d[root][exfile][test]['args']
                        alldatafiles += get_datafiles(args)
                        if 'subtests' in d[root][exfile][test]:
                            for s in d[root][exfile][test]['subtests']:
                                if 'args' in d[root][exfile][test][s]:
                                    args = d[root][exfile][test][s]['args']
                                    alldatafiles += get_datafiles(args)

    # Make unique and sort
    alldatafiles = list(set(alldatafiles))
    alldatafiles.sort()

    if datafilespath:
        action = 'gen_dl_path'
    if action == 'print_datafiles':
        print('\n'.join(alldatafiles))
    if action == 'gen_dl_path':
        ftproot='http://ftp.mcs.anl.gov/pub/petsc/Datafiles/'
        for dfile in alldatafiles:
           fulldfile=os.path.join(datafilespath,dfile)
           if not os.path.exists(fulldfile):
              dl_dir=os.path.dirname(fulldfile)
              if not os.path.isdir(dl_dir):
                  try:
                     os.mkdir(dl_dir)
                  except:
                     os.mkdir(os.path.dirname(os.path.dirname(dl_dir)))
                     os.mkdir(os.path.dirname(dl_dir))
                     os.mkdir(dl_dir)
              dl_dfile=ftproot+dfile
              print('cd '+dl_dir+' && wget '+dl_dfile+'\n')

    return