Changes in tests/pybin/tools.py [8364209:136f86b]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/pybin/tools.py
r8364209 r136f86b 75 75 return proc.returncode, out.decode("utf-8") if out else None 76 76 except subprocess.TimeoutExpired: 77 proc.send_signal(signal.SIGABRT) 78 proc.communicate() 79 return 124, str(None) 77 if settings.timeout2gdb: 78 print("Process {} timeout".format(proc.pid)) 79 proc.communicate() 80 return 124, str(None) 81 else: 82 proc.send_signal(signal.SIGABRT) 83 proc.communicate() 84 return 124, str(None) 80 85 81 86 except Exception as ex: … … 175 180 176 181 def which(program): 177 fpath, fname = os.path.split(program) 178 if fpath: 179 if is_exe(program): 180 return program 181 else: 182 for path in os.environ["PATH"].split(os.pathsep): 183 exe_file = os.path.join(path, program) 184 if is_exe(exe_file): 185 return exe_file 186 187 return None 182 fpath, fname = os.path.split(program) 183 if fpath: 184 if is_exe(program): 185 return program 186 else: 187 for path in os.environ["PATH"].split(os.pathsep): 188 exe_file = os.path.join(path, program) 189 if is_exe(exe_file): 190 return exe_file 191 return None 188 192 189 193 @contextlib.contextmanager … … 323 327 raise argparse.ArgumentTypeError(msg) 324 328 329 # Convert a function that converts a string to one that converts comma separated string. 330 def comma_separated(elements): 331 return lambda string: [elements(part) for part in string.split(',')] 332 325 333 def fancy_print(text): 326 334 column = which('column') … … 365 373 366 374 class Timed: 367 368 369 370 371 372 373 375 def __enter__(self): 376 self.start = time.time() 377 return self 378 379 def __exit__(self, *args): 380 self.end = time.time() 381 self.duration = self.end - self.start 374 382 375 383 def timed(src, timeout): 376 384 expire = time.time() + timeout 377 385 i = iter(src) 378 while True: 379 yield i.next(max(expire - time.time(), 0)) 386 with contextlib.suppress(StopIteration): 387 while True: 388 yield i.next(max(expire - time.time(), 0))
Note:
See TracChangeset
for help on using the changeset viewer.