Changeset 5bf1f3e for tests/pybin/tools.py
- Timestamp:
- Mar 26, 2019, 10:36:58 AM (5 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/pybin/tools.py
reb60b04 r5bf1f3e 55 55 return match.group(1).startswith("ASCII text") 56 56 57 def is_exe(fname): 58 return os.path.isfile(fname) and os.access(fname, os.X_OK) 59 57 60 # Remove 1 or more files silently 58 61 def rm( files ): … … 79 82 # diff the output of the files 80 83 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") 96 97 97 98 # fetch return code and error from the diff command … … 115 116 116 117 def which(program): 117 import os118 def is_exe(fpath):119 return os.path.isfile(fpath) and os.access(fpath, os.X_OK)120 121 118 fpath, fname = os.path.split(program) 122 119 if fpath: … … 160 157 161 158 # helper function to check if a files contains only a specific string 162 def file ContainsOnly(file, text) :159 def file_contains_only(file, text) : 163 160 with open(file) as f: 164 161 ff = f.read().strip() 165 162 result = ff == text.strip() 166 163 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 179 165 180 166 # transform path to canonical form 181 def canonical Path(path):167 def canonical_path(path): 182 168 abspath = os.path.abspath(__main__.__file__) 183 169 dname = os.path.dirname(abspath) … … 185 171 186 172 # compare path even if form is different 187 def path Cmp(lhs, rhs):188 return canonical Path( lhs ) == canonicalPath( rhs )173 def path_cmp(lhs, rhs): 174 return canonical_path( lhs ) == canonical_path( rhs ) 189 175 190 176 # 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 177 def path_walk( op ): 198 178 dname = settings.SRCDIR 199 179 for dirname, _, names in os.walk(dname): … … 206 186 ################################################################################ 207 187 # count number of jobs to create 208 def job Count( options, tests ):188 def job_count( options, tests ): 209 189 # check if the user already passed in a number of jobs for multi-threading 210 190 if not options.jobs: … … 229 209 230 210 # setup a proper processor pool with correct signal handling 231 def setup Pool(jobs):211 def setup_pool(jobs): 232 212 original_sigint_handler = signal.signal(signal.SIGINT, signal.SIG_IGN) 233 213 pool = multiprocessing.Pool(jobs) … … 261 241 return False 262 242 raise argparse.ArgumentTypeError(msg) 263 return False264 243 265 244 def fancy_print(text): … … 273 252 274 253 275 def core Info(path):254 def core_info(path): 276 255 cmd = os.path.join(settings.SRCDIR, "pybin/print-core.gdb") 277 256 if not os.path.isfile(cmd):
Note: See TracChangeset
for help on using the changeset viewer.