def main(args=None, plugins=None):
from _pytest.main import EXIT_USAGEERROR<EOL>try:<EOL><INDENT>try:<EOL><INDENT>config = _prepareconfig(args, plugins)<EOL><DEDENT>except ConftestImportFailure as e:<EOL><INDENT>exc_info = ExceptionInfo(e.excinfo)<EOL>tw = py.io.TerminalWriter(sys.stderr)<EOL>tw.line(<EOL>"<STR_LIT>".format(e=e), red=True<EOL>)<EOL>exc_info.traceback = exc_info.traceback.filter(filter_traceback)<EOL>exc_repr = (<EOL>exc_info.getrepr(style="<STR_LIT>", chain=False)<EOL>if exc_info.traceback<EOL>else exc_info.exconly()<EOL>)<EOL>formatted_tb = safe_str(exc_repr)<EOL>for line in formatted_tb.splitlines():<EOL><INDENT>tw.line(line.rstrip(), red=True)<EOL><DEDENT>return <NUM_LIT:4><EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>return config.hook.pytest_cmdline_main(config=config)<EOL><DEDENT>finally:<EOL><INDENT>config._ensure_unconfigure()<EOL><DEDENT><DEDENT><DEDENT>except UsageError as e:<EOL><INDENT>tw = py.io.TerminalWriter(sys.stderr)<EOL>for msg in e.args:<EOL><INDENT>tw.line("<STR_LIT>".format(msg), red=True)<EOL><DEDENT>return EXIT_USAGEERROR<EOL><DEDENT>
return exit code, after performing an in-process test run.

    :arg args: list of command line arguments.

    :arg plugins: list of plugin objects to be auto-registered during
                  initialization.