コード例 #1
0
def run(*datasources, **options):
    """Executes given Robot data sources with given options.

    Data sources are paths to files and directories, similarly as when running
    pybot/jybot from command line. Options are given as keywords arguments and
    their names are same as long command line options without hyphens.

    Examples:
    run('/path/to/tests.html')
    run('/path/to/tests.html', '/path/to/tests2.html', log='mylog.html')

    Equivalent command line usage:
    pybot /path/to/tests.html
    pybot --log mylog.html /path/to/tests.html /path/to/tests2.html
    """
    STOP_SIGNAL_MONITOR.start()
    settings = RobotSettings(options)
    LOGGER.register_console_logger(settings['MonitorWidth'],
                                   settings['MonitorColors'])
    init_global_variables(settings)
    suite = TestSuite(datasources, settings)
    output = Output(settings)
    suite.run(output)
    LOGGER.info("Tests execution ended. Statistics:\n%s"
                % suite.get_stat_message())
    output.close(suite)
    if settings.is_rebot_needed():
        output, settings = settings.get_rebot_datasource_and_settings()
        ResultWriter(settings).write_robot_results(output)
    LOGGER.close()
    return suite
コード例 #2
0
ファイル: __init__.py プロジェクト: gdw2/robot-framework
def _exit(rc, message=None, details=None):
    """Exits with given rc or rc from given output. Reports possible error.

    Exit code is the number of failed critical tests or error number.
      0       - Tests executed and all critical tests passed
      1-250   - Tests executed but returned number of critical tests failed
                (250 means 250 or more failures)
      251     - Help or version info was printed
      252     - Invalid test data or command line arguments
      253     - Execution stopped by user
      255     - Internal and unexpected error occurred in the framework itself
    """
    if rc == INFO_PRINTED:
        print utils.encode_output(message)
    else:
        if rc == DATA_ERROR:
            message += '\n\nTry --help for usage information.'
        LOGGER.error(message)
        if details:
            LOGGER.info(details)
    sys.exit(rc)
コード例 #3
0
ファイル: __init__.py プロジェクト: superbaby11/autoOMC
def _exit(rc, message=None, details=None):
    """Exits with given rc or rc from given output. Reports possible error.

    Exit code is the number of failed critical tests or error number.
      0       - Tests executed and all critical tests passed
      1-250   - Tests executed but returned number of critical tests failed
                (250 means 250 or more failures)
      251     - Help or version info was printed
      252     - Invalid test data or command line arguments
      253     - Execution stopped by user
      255     - Internal and unexpected error occurred in the framework itself
    """
    if rc == INFO_PRINTED:
        print message
    else:
        if rc == DATA_ERROR:
            message += '\n\nTry --help for usage information.'
        LOGGER.error(message)
        if details:
            LOGGER.info(details)
    sys.exit(rc)
コード例 #4
0
ファイル: __init__.py プロジェクト: gdw2/robot-framework
def run(*datasources, **options):
    """Executes given Robot data sources with given options.

    Data sources are paths to files and directories, similarly as when running
    pybot/jybot from command line. Options are given as keywords arguments and
    their names are same as long command line options without hyphens.

    Examples:
    run('/path/to/tests.html')
    run('/path/to/tests.html', '/path/to/tests2.html', log='mylog.html')

    Equivalent command line usage:
    pybot /path/to/tests.html
    pybot --log mylog.html /path/to/tests.html /path/to/tests2.html
    """
    STOP_SIGNAL_MONITOR.start()
    settings = RobotSettings(options)
    LOGGER.register_console_logger(settings['MonitorWidth'],
                                   settings['MonitorColors'])
    output = Output(settings)
    init_global_variables(settings)
    suite = TestSuite(datasources, settings)
    suite.run(output)
    LOGGER.info("Tests execution ended. Statistics:\n%s" %
                suite.get_stat_message())
    testoutput = RobotTestOutput(suite, settings)
    output.close(suite)
    if settings.is_rebot_needed():
        datasources, settings = settings.get_rebot_datasources_and_settings()
        if settings['SplitOutputs'] > 0:
            testoutput = SplitIndexTestOutput(suite, datasources[0], settings)
        else:
            testoutput = RebotTestOutput(datasources, settings)
        testoutput.serialize(settings)
    LOGGER.close()
    return suite
コード例 #5
0
ファイル: __init__.py プロジェクト: gdw2/robot-framework
def rebot_from_cli(args, usage):
    LOGGER.info(get_full_version('Rebot'))
    _run_or_rebot_from_cli(run_rebot, args, usage)
コード例 #6
0
ファイル: __init__.py プロジェクト: gdw2/robot-framework
def run_from_cli(args, usage):
    LOGGER.info(get_full_version('Robot Framework'))
    _run_or_rebot_from_cli(run, args, usage, pythonpath='pythonpath')
コード例 #7
0
ファイル: __init__.py プロジェクト: gdw2/robot-framework

def _run_or_rebot_from_cli(method, cliargs, usage, **argparser_config):
    LOGGER.register_file_logger()
    ap = utils.ArgumentParser(usage, get_full_version())
    try:
        options, datasources = \
            ap.parse_args(cliargs, argfile='argumentfile', unescape='escape',
                          help='help', version='version', check_args=True,
                          **argparser_config)
    except Information, msg:
        _exit(INFO_PRINTED, utils.unic(msg))
    except DataError, err:
        _exit(DATA_ERROR, utils.unic(err))

    LOGGER.info('Data sources: %s' % utils.seq2str(datasources))
    try:
        suite = method(*datasources, **options)
    except DataError, err:
        _exit(DATA_ERROR, unicode(err))
    except (KeyboardInterrupt, SystemExit):
        _exit(STOPPED_BY_USER, 'Execution stopped by user.')
    except:
        error, details = utils.get_error_details()
        _exit(FRAMEWORK_ERROR, 'Unexpected error: %s' % error, details)
    else:
        _exit(_failed_critical_test_count(suite))


def _failed_critical_test_count(suite):
    rc = suite.critical_stats.failed
コード例 #8
0
def rebot_from_cli(args, usage):
    LOGGER.info(get_full_version('Rebot'))
    return _run_or_rebot_from_cli(run_rebot, args, usage)
コード例 #9
0
def run_from_cli(args, usage):
    LOGGER.info(get_full_version('Robot Framework'))
    return _run_or_rebot_from_cli(run, args, usage, pythonpath='pythonpath')
コード例 #10
0
def rebot_from_cli(args, usage):
    LOGGER.info(get_full_version('Rebot'))
    return _run_or_rebot_from_cli(run_rebot, args, usage)

def _run_or_rebot_from_cli(method, cliargs, usage, **argparser_config):
    LOGGER.register_file_logger()
    try:
        options, datasources = _parse_arguments(cliargs, usage,
                                                **argparser_config)
    except Information, msg:
        print utils.encode_output(unicode(msg))
        return INFO_PRINTED
    except DataError, err:
        _report_error(unicode(err), help=True)
        return DATA_ERROR
    LOGGER.info('Data sources: %s' % utils.seq2str(datasources))
    return _execute(method, datasources, options)

def _parse_arguments(cliargs, usage, **argparser_config):
    ap = utils.ArgumentParser(usage, get_full_version())
    return ap.parse_args(cliargs, argfile='argumentfile', unescape='escape',
                         help='help', version='version', check_args=True,
                         **argparser_config)

def _execute(method, datasources, options):
    try:
        suite = method(*datasources, **options)
    except DataError, err:
        _report_error(unicode(err), help=True)
        return DATA_ERROR
    except (KeyboardInterrupt, SystemExit):