def show_help_ini(config): reporter.separator("-", "per-testenv attributes", reporter.Verbosity.INFO) for env_attr in config._testenv_attr: reporter.line( "{:<15} {:<8} default: {}".format(env_attr.name, "<{}>".format(env_attr.type), env_attr.default), bold=True, ) reporter.line(env_attr.help) reporter.line("")
def _summary(self): is_parallel_child = PARALLEL_ENV_VAR_KEY_PRIVATE in os.environ if not is_parallel_child: reporter.separator("_", "summary", reporter.Verbosity.QUIET) exit_code = 0 for venv in self.venv_dict.values(): report = reporter.good status = getattr(venv, "status", "undefined") if isinstance(status, tox.exception.InterpreterNotFound): msg = " {}: {}".format(venv.envconfig.envname, str(status)) if self.config.option.skip_missing_interpreters == "true": report = reporter.skip else: exit_code = 1 report = reporter.error elif status == "platform mismatch": msg = " {}: {} ({!r} does not match {!r})".format( venv.envconfig.envname, str(status), sys.platform, venv.envconfig.platform, ) report = reporter.skip elif status and status == "ignored failed command": msg = " {}: {}".format(venv.envconfig.envname, str(status)) elif status and status != "skipped tests": msg = " {}: {}".format(venv.envconfig.envname, str(status)) report = reporter.error exit_code = 1 else: if not status: status = "commands succeeded" msg = " {}: {}".format(venv.envconfig.envname, status) if not is_parallel_child: report(msg) if not exit_code and not is_parallel_child: reporter.good(" congratulations :)") path = self.config.option.resultjson if path: if not is_parallel_child: self._add_parallel_summaries() path = py.path.local(path) data = self.resultlog.dumps_json() reporter.line("write json report at: {}".format(path)) path.write(data) return exit_code
def popen( self, args, cwd=None, env=None, redirect=True, returnout=False, ignore_ret=False, capture_err=True, callback=None, report_fail=True, ): """this drives an interaction with a subprocess""" cwd = py.path.local() if cwd is None else cwd cmd_args = [str(x) for x in self._rewrite_args(cwd, args)] cmd_args_shell = " ".join(pipes.quote(i) for i in cmd_args) stream_getter = self._get_standard_streams( capture_err, cmd_args_shell, redirect, returnout, cwd, ) exit_code, output = None, None with stream_getter as (fin, out_path, stderr, stdout): try: process = self.via_popen( cmd_args, stdout=stdout, stderr=stderr, cwd=str(cwd), env=os.environ.copy() if env is None else env, universal_newlines=True, shell=False, creationflags=( subprocess.CREATE_NEW_PROCESS_GROUP if sys.platform == "win32" else 0 # needed for Windows signal send ability (CTRL+C) ), ) except OSError as exception: exit_code = exception.errno else: if callback is not None: callback(process) reporter.log_popen(cwd, out_path, cmd_args_shell, process.pid) output = self.evaluate_cmd(fin, process, redirect) exit_code = process.returncode finally: if out_path is not None and out_path.exists(): lines = out_path.read_text("UTF-8").split("\n") # first three lines are the action, cwd, and cmd - remove it output = "\n".join(lines[3:]) try: if exit_code and not ignore_ret: if report_fail: msg = "invocation failed (exit code {:d})".format( exit_code) if out_path is not None: msg += ", logfile: {}".format(out_path) if not out_path.exists(): msg += " warning log file missing" reporter.error(msg) if out_path is not None and out_path.exists(): reporter.separator("=", "log start", Verbosity.QUIET) reporter.quiet(output) reporter.separator("=", "log end", Verbosity.QUIET) raise InvocationError(cmd_args_shell, exit_code, output) finally: self.command_log.add_command(cmd_args, output, exit_code) return output