def run(filename, debug, verbose, flags, env): args = ((['-mg'] if debug else []) + [os.path.basename(filename)] + flags + ([] if verbose else ['-level', '5'])) if verbose: print('Running', ' '.join(args)) proc = regent.regent( args, stdout=None if verbose else subprocess.PIPE, stderr=None if verbose else subprocess.STDOUT, env=env, cwd=os.path.dirname(os.path.abspath(filename))) try: output, _ = proc.communicate() retcode = proc.wait() except (KeyboardInterrupt, TestTimeoutException): if verbose: print('terminating child process...') proc.terminate() maxtime = 15 while True: retcode = proc.poll() if retcode is not None: break if maxtime > 0: time.sleep(0.1) maxtime = maxtime - 0.1 else: print('Child process failed to terminate - sending SIGKILL') proc.kill() break raise if retcode != 0: raise TestFailure(' '.join(args), output.decode('utf-8') if output is not None else None) return ' '.join(args)
def run(filename, debug, verbose, flags): args = ((['-mg'] if debug else []) + [os.path.basename(filename)] + flags + ([] if verbose else ['-level', '5'])) proc = regent.regent(args, stdout=None if verbose else subprocess.PIPE, stderr=None if verbose else subprocess.STDOUT, cwd=os.path.dirname(os.path.abspath(filename))) output, _ = proc.communicate() retcode = proc.wait() if retcode != 0: raise TestFailure(' '.join(args), output.decode('utf-8'))
def run(filename, verbose, flags): args = [os.path.basename(filename)] + flags + ([] if verbose else ["-level", "5"]) proc = regent.regent( args, stdout=None if verbose else subprocess.PIPE, stderr=None if verbose else subprocess.STDOUT, cwd=os.path.dirname(os.path.abspath(filename)), ) output, _ = proc.communicate() retcode = proc.wait() if retcode != 0: raise TestFailure(" ".join(args), str(output))
def run(filename, debug, verbose, flags): args = ((['-mg'] if debug else []) + [os.path.basename(filename)] + flags + ([] if verbose else ['-level', '5'])) proc = regent.regent( args, stdout = None if verbose else subprocess.PIPE, stderr = None if verbose else subprocess.STDOUT, cwd = os.path.dirname(os.path.abspath(filename))) output, _ = proc.communicate() retcode = proc.wait() if retcode != 0: raise TestFailure(' '.join(args), output.decode('utf-8'))
def run(filename, debug, verbose, timelimit, flags, env): args = ((['-mg'] if debug else []) + [os.path.basename(filename)] + flags + ([] if verbose else ['-level', 'runtime=5,threads=5'])) if verbose: print('Running', ' '.join(args)) def set_timeout(): # set hard limit above soft limit so we might get SIGXCPU return code resource.setrlimit(resource.RLIMIT_CPU, (timelimit, timelimit + 1)) proc = regent.regent(args, stdout=None if verbose else subprocess.PIPE, stderr=None if verbose else subprocess.STDOUT, env=env, cwd=os.path.dirname(os.path.abspath(filename)), preexec_fn=set_timeout) try: output, _ = proc.communicate() retcode = proc.wait() except KeyboardInterrupt: if verbose: print('terminating child process...') proc.terminate() maxtime = 15 while True: retcode = proc.poll() if retcode is not None: break if maxtime > 0: time.sleep(0.1) maxtime = maxtime - 0.1 else: print('Child process failed to terminate - sending SIGKILL') proc.kill() break raise if retcode != 0: raise TestFailure( ' '.join(args), retcode, output.decode('utf-8') if output is not None else None) return ' '.join(args)