Ignore:
Timestamp:
Mar 26, 2019, 10:36:58 AM (5 years ago)
Author:
tdelisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
1bb2488
Parents:
eb60b04
Message:

Code review of test.py and pybin

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tests/pybin/tools.py

    reb60b04 r5bf1f3e  
    5555        return match.group(1).startswith("ASCII text")
    5656
     57def is_exe(fname):
     58        return os.path.isfile(fname) and os.access(fname, os.X_OK)
     59
    5760# Remove 1 or more files silently
    5861def rm( files ):
     
    7982        # diff the output of the files
    8083        diff_cmd = ("diff --text "
    81 #                               "--ignore-all-space "
    82 #                               "--ignore-blank-lines "
    83                                 "--old-group-format='\t\tmissing lines :\n"
    84                                 "%%<' \\\n"
    85                                 "--new-group-format='\t\tnew lines :\n"
    86                                 "%%>' \\\n"
    87                                 "--unchanged-group-format='%%=' \\"
    88                                 "--changed-group-format='\t\texpected :\n"
    89                                 "%%<"
    90                                 "\t\tgot :\n"
    91                                 "%%>\n' \\\n"
    92                                 "--new-line-format='\t\t%%dn\t%%L' \\\n"
    93                                 "--old-line-format='\t\t%%dn\t%%L' \\\n"
    94                                 "--unchanged-line-format='' \\\n"
    95                                 "%s %s")
     84                        "--old-group-format='\t\tmissing lines :\n"
     85                        "%%<' \\\n"
     86                        "--new-group-format='\t\tnew lines :\n"
     87                        "%%>' \\\n"
     88                        "--unchanged-group-format='%%=' \\"
     89                        "--changed-group-format='\t\texpected :\n"
     90                        "%%<"
     91                        "\t\tgot :\n"
     92                        "%%>\n' \\\n"
     93                        "--new-line-format='\t\t%%dn\t%%L' \\\n"
     94                        "--old-line-format='\t\t%%dn\t%%L' \\\n"
     95                        "--unchanged-line-format='' \\\n"
     96                        "%s %s")
    9697
    9798        # fetch return code and error from the diff command
     
    115116
    116117def which(program):
    117     import os
    118     def is_exe(fpath):
    119         return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
    120 
    121118    fpath, fname = os.path.split(program)
    122119    if fpath:
     
    160157
    161158# helper function to check if a files contains only a specific string
    162 def fileContainsOnly(file, text) :
     159def file_contains_only(file, text) :
    163160        with open(file) as f:
    164161                ff = f.read().strip()
    165162                result = ff == text.strip()
    166163
    167                 return result;
    168 
    169 # check whether or not a file is executable
    170 def fileIsExecutable(file) :
    171         try :
    172                 fileinfo = os.stat(file)
    173                 return bool(fileinfo.st_mode & stat.S_IXUSR)
    174         except Exception as inst:
    175                 print(type(inst))    # the exception instance
    176                 print(inst.args)     # arguments stored in .args
    177                 print(inst)
    178                 return False
     164                return result
    179165
    180166# transform path to canonical form
    181 def canonicalPath(path):
     167def canonical_path(path):
    182168        abspath = os.path.abspath(__main__.__file__)
    183169        dname = os.path.dirname(abspath)
     
    185171
    186172# compare path even if form is different
    187 def pathCmp(lhs, rhs):
    188         return canonicalPath( lhs ) == canonicalPath( rhs )
     173def path_cmp(lhs, rhs):
     174        return canonical_path( lhs ) == canonical_path( rhs )
    189175
    190176# walk all files in a path
    191 def pathWalk( op ):
    192         def step(_, dirname, names):
    193                 for name in names:
    194                         path = os.path.join(dirname, name)
    195                         op( path )
    196 
    197         # Start the walk
     177def path_walk( op ):
    198178        dname = settings.SRCDIR
    199179        for dirname, _, names in os.walk(dname):
     
    206186################################################################################
    207187# count number of jobs to create
    208 def jobCount( options, tests ):
     188def job_count( options, tests ):
    209189        # check if the user already passed in a number of jobs for multi-threading
    210190        if not options.jobs:
     
    229209
    230210# setup a proper processor pool with correct signal handling
    231 def setupPool(jobs):
     211def setup_pool(jobs):
    232212        original_sigint_handler = signal.signal(signal.SIGINT, signal.SIG_IGN)
    233213        pool = multiprocessing.Pool(jobs)
     
    261241                return False
    262242        raise argparse.ArgumentTypeError(msg)
    263         return False
    264243
    265244def fancy_print(text):
     
    273252
    274253
    275 def coreInfo(path):
     254def core_info(path):
    276255        cmd   = os.path.join(settings.SRCDIR, "pybin/print-core.gdb")
    277256        if not os.path.isfile(cmd):
Note: See TracChangeset for help on using the changeset viewer.