def print_commands_on_failure(): message_color = 'red' mx.log(mx.colorize('\nThe sequence of mx commands that were executed until the failure follows:\n', color=message_color)) for command, command_args, kwargs in all_commands: message = command_in_gate_message(command, command_args, kwargs) mx.log(mx.colorize(message, color=message_color))
def mx_command_entered(command, *args, **kwargs): global _command_level if _command_level is 0: all_commands.append((command.command, args, kwargs)) mx.log( mx.colorize( 'Running: ' + command_in_gate_message(command.command, args, kwargs), color='blue')) _command_level = _command_level + 1
def __exit__(self, tp, value, tb): self.stdout_file.flush() self.stderr_file.flush() if self.exit_code == 0 and (tb is None): if self.current_stage == self.config.last_stage: self.bench_out('Successfully finished the last specified stage:' + ' ' + self.current_stage + ' for ' + self.final_image_name) else: mx.log('Successfully finished stage:' + ' ' + self.current_stage) self.separator_line() else: self.failed = True if self.exit_code is not None and self.exit_code != 0: mx.log(mx.colorize('Failed in stage ' + self.current_stage + ' for ' + self.final_image_name + ' with exit code ' + str(self.exit_code), 'red')) if self.stdout_path: mx.log(mx.colorize('--------- Standard output:', 'blue')) with open(self.stdout_path, 'r') as stdout: mx.log(stdout.read()) if self.stderr_path: mx.log(mx.colorize('--------- Standard error:', 'red')) with open(self.stderr_path, 'r') as stderr: mx.log(stderr.read()) if tb: mx.log(mx.colorize('Failed in stage ' + self.current_stage + ' with ', 'red')) print_tb(tb) self.separator_line() if len(self.stages_till_now) > 0: mx.log(mx.colorize('--------- To run the failed benchmark execute the following: ', 'green')) mx.log(mx.current_mx_command()) if len(self.stages_till_now[:-1]) > 0: mx.log(mx.colorize('--------- To only prepare the benchmark add the following to the end of the previous command: ', 'green')) mx.log('-Dnative-image.benchmark.stages=' + ','.join(self.stages_till_now[:-1])) mx.log(mx.colorize('--------- To only run the failed stage add the following to the end of the previous command: ', 'green')) mx.log('-Dnative-image.benchmark.stages=' + self.current_stage) mx.log(mx.colorize('--------- Additional arguments that can be used for debugging the benchmark go after the final --: ', 'green')) for param in self.config.params: mx.log('-Dnative-image.benchmark.' + param + '=') self.separator_line() if self.non_zero_is_fatal: mx.abort('Exiting the benchmark due to the failure.') self.stdout_file.close() self.stderr_file.close() self.reset_stage()
def separator_line(): mx.log(mx.colorize('-' * 120, 'green'))
def _interesting(msg=None): if msg: mx.logv( mx.colorize("mx check-interesting: yes ({})".format(msg), color="cyan")) sys.exit(1)
def _not_interesting(msg=None): if msg: mx.logv( mx.colorize("mx check-interesting: no ({})".format(msg), color="blue")) sys.exit(0)
def print_info(msg): i = mx.colorize(' INFO ', 'yellow') print('[' + i + '] ' + msg)
def print_warn(msg): w = mx.colorize('WARNING', 'magenta') print('[' + w + '] ' + msg)
def print_error(msg): err = mx.colorize(' ERROR ', 'red') print('[' + err + '] ' + msg)
def print_ok(msg): ok = mx.colorize(' OK ', 'green') print('[' + ok + '] ' + msg)