def get_result(self): if self.clean.returncode != 0: Printer.out( "{} Could not clean directory '{c[dir]}': {c[error]}", self.get_status_line(self.clean), c=self.clean) return if self.pypy.returncode != 0: Printer.out("{} Run error, case: {p[name]}", self.get_status_line(self.pypy), p=self.pypy) self.print_log_file(self.pypy.log, self.n_lines) return elif self.batch: self.print_log_file(self.pypy.log, self.n_lines) if self.comp.returncode not in (0, None): Printer.out("{} Compare error, case: {p[name]}, Details: ", self.get_status_line(self.comp), p=self.pypy) self.print_log_file(self.pypy.log, self.n_lines) Printer.open(2) for c in self.comp.tests: rc = c.returncode if rc == 0: Printer.out('[{:^6}]: {}', 'OK', c.name) else: Printer.out('[{:^6}]: {}', 'FAILED', c.name) Printer.close(2) return elif self.batch: self.print_log_file(self.comp.log, self.n_lines)
def get_result(self): if self.clean.returncode != 0: Printer.out("{} Could not clean directory '{c[dir]}': {c[error]}", self.get_status_line(self.clean), c=self.clean) return if self.pypy.returncode != 0: Printer.out("{} Run error, case: {p[name]}", self.get_status_line(self.pypy), p=self.pypy) self.print_log_file(self.pypy.log, self.n_lines) return elif self.batch: self.print_log_file(self.pypy.log, self.n_lines) if self.comp.returncode not in (0, None): Printer.out("{} Compare error, case: {p[name]}, Details: ", self.get_status_line(self.comp), p=self.pypy) self.print_log_file(self.pypy.log, self.n_lines) Printer.open(2) for c in self.comp.tests: rc = c.returncode if rc == 0: Printer.out('[{:^6}]: {}', 'OK', c.name) else: Printer.out('[{:^6}]: {}', 'FAILED', c.name) Printer.close(2) return elif self.batch: self.print_log_file(self.comp.log, self.n_lines)
def on_complete(self, pypy=None): if self.pypy.returncode > 0: if self.message: Printer.separator() Printer.open() Printer.out(self.message) else: Printer.open() # if file pointer exist try to read errors and outputs output = self.pypy.executor.output.read() if output: if self.pypy.full_output: Printer.out('Output (last {} lines, rest in {}): ', self.tail, Paths.abspath(self.pypy.full_output)) else: Printer.out('Output (last {} lines): ', self.tail) Printer.err(format_n_lines(output, -self.tail, indent=Printer.indent * ' ')) Printer.close()
def run_local_mode(debug=False): global arg_options, arg_others, arg_rest proc, time_limit, memory_limit = get_args() total = len(proc) if total == 1: pypy = run_local_mode_one(proc[0], time_limit, memory_limit) GlobalResult.returncode = pypy.returncode else: # optionally we use counter progress = ProgressCounter('Running {:02d} of {total:02d}') for p in proc: Printer.separator() progress.next(locals()) Printer.separator() Printer.open() pypy = run_local_mode_one(p, time_limit, memory_limit) Printer.close() GlobalResult.returncode = max(GlobalResult.returncode, pypy.returncode) return GlobalResult.returncode if not debug else pypy
def run_local_mode_one(proc, time_limit, memory_limit): if proc == 0: command = arg_rest[1:] else: command = [arg_rest[0], '-np', proc] + arg_rest[1:] n_lines = 0 if arg_options.batch else 10 pypy = PyPy(BinExecutor(command)) # set limits pypy.limit_monitor.time_limit = time_limit pypy.limit_monitor.memory_limit = memory_limit pypy.progress = not arg_options.batch pypy.info_monitor.deactivate() pypy.error_monitor.deactivate() # catch output to variable # in batch mode we will keep the files # otherwise we will keep logs only on error log_file = Paths.temp_file('exec-parallel-{date}-{time}-{rnd}.log') pypy.executor.output = OutputMode.variable_output() pypy.full_output = log_file # start and wait for exit pypy.start() pypy.join() # add result to global json result GlobalResult.add(pypy) # in batch mode or on error if not pypy.with_success() or arg_options.batch: content = pypy.executor.output.read() IO.write(log_file, content) Printer.close() Printer.out(format_n_lines(content, indent=' ', n_lines=-n_lines)) Printer.open() return pypy
def finish_pbs_job(job, batch): """ :type job: scripts.pbs.job.Job """ # try to get more detailed job status job.is_active = False job_output = IO.read(job.case.fs.json_output) if job_output: job_json = JsonParser(json.loads(job_output), batch) if job_json.returncode == 0: job.status = JobState.EXIT_OK Printer.out('OK: Job {}({}) ended', job, job.full_name) Printer.open() # in batch mode print all logs if batch: Printer.open() for test in job_json.tests: test.get_result() Printer.close() Printer.close() else: job.status = JobState.EXIT_ERROR Printer.out('ERROR: Job {}({}) ended', job, job.full_name) # in batch mode print all logs Printer.open() for test in job_json.tests: test.get_result() Printer.close() else: # no output file was generated assuming it went wrong job.status = JobState.EXIT_ERROR Printer.out('ERROR: Job {} ended (no output file found). Case: {}', job, job.full_name) Printer.out(' pbs output: ') Printer.out(format_n_lines(IO.read(job.case.fs.pbs_output), 0)) return 0 if job.status == JobState.EXIT_OK else 1
def run_local_mode(configs, debug=False): """ :type debug: bool :type configs: scripts.config.yaml_config.ConfigPool """ global arg_options, arg_others, arg_rest runner = ParallelThreads(arg_options.parallel) runner.stop_on_error = not arg_options.keep_going for yaml_file, yaml_config in configs.files.items(): for case in yaml_config.get_one(yaml_file): # create main process which first clean output dir # and then execute test following with comparisons multi_process = create_process_from_case(case) runner.add(multi_process) # run! runner.start() while runner.is_running(): time.sleep(1) Printer.separator() Printer.out('Summary: ') Printer.open() for thread in runner.threads: multithread = thread """ :type: RuntestMultiThread """ returncode = multithread.returncode GlobalResult.add(multithread) if multithread.clean.with_error(): Printer.out("[{:^6}]:{:3} | Could not clean directory '{}': {}", 'ERROR', multithread.clean.returncode, multithread.clean.dir, multithread.clean.error) continue if not multithread.pypy.with_success(): Printer.out("[{:^6}]:{:3} | Run error, case: {}", multithread.pypy.returncode_map.get(str(multithread.pypy.returncode), 'ERROR'), multithread.pypy.returncode, multithread.pypy.case.to_string()) continue if multithread.comp.with_error(): Printer.out("[{:^6}]:{:3} | Compare error, case: {}, Details: ", 'FAILED', multithread.comp.returncode, multithread.pypy.case.to_string()) Printer.open(2) for t in multithread.comp.threads: if t: Printer.out('[{:^6}]: {}', 'OK', t.name) else: Printer.out('[{:^6}]: {}', 'FAILED', t.name) Printer.close(2) continue Printer.out("[{:^6}]:{:3} | Test passed: {}", 'PASSED', multithread.pypy.returncode, multithread.pypy.case.to_string()) Printer.close() # exit with runner's exit code GlobalResult.returncode = runner.returncode return runner if debug else runner.returncode