Example #1
0
def annotate(test_name,
             result,
             results_tracker,
             full_name=False,
             perf_dashboard_id=None):
    """Given a test result and tracker, update the waterfall with test results."""

    # Always print raw exit code of the subprocess. This is very helpful
    # for debugging, especially when one gets the "crashed or hung" message
    # with no output (exit code can have some clues, especially on Windows).
    print 'exit code (as seen by runtest.py): %d' % result

    get_text_result = process_log_utils.SUCCESS

    for failure in sorted(results_tracker.FailedTests()):
        if full_name:
            testabbr = re.sub(r'[^\w\.\-]', '_', failure)
        else:
            testabbr = re.sub(r'[^\w\.\-]', '_', failure.split('.')[-1])
        slave_utils.WriteLogLines(testabbr,
                                  results_tracker.FailureDescription(failure))
    for suppression_hash in sorted(results_tracker.SuppressionHashes()):
        slave_utils.WriteLogLines(
            suppression_hash, results_tracker.Suppression(suppression_hash))

    if results_tracker.ParsingErrors():
        # Generate a log file containing the list of errors.
        slave_utils.WriteLogLines('log parsing error(s)',
                                  results_tracker.ParsingErrors())

        results_tracker.ClearParsingErrors()

    if hasattr(results_tracker, 'evaluateCommand'):
        parser_result = results_tracker.evaluateCommand('command')
        if parser_result > result:
            result = parser_result

    if result == process_log_utils.SUCCESS:
        if (len(results_tracker.ParsingErrors())
                or len(results_tracker.FailedTests())
                or len(results_tracker.SuppressionHashes())):
            print '@@@STEP_WARNINGS@@@'
            get_text_result = process_log_utils.WARNINGS
    elif result == slave_utils.WARNING_EXIT_CODE:
        print '@@@STEP_WARNINGS@@@'
        get_text_result = process_log_utils.WARNINGS
    else:
        print '@@@STEP_FAILURE@@@'
        get_text_result = process_log_utils.FAILURE

    for desc in getText(get_text_result, results_tracker, test_name):
        print '@@@STEP_TEXT@%s@@@' % desc

    if hasattr(results_tracker, 'PerformanceLogs'):
        if not perf_dashboard_id:
            raise Exception('runtest.py error: perf step specified but'
                            'no test_id in factory_properties!')
        for logname, log in results_tracker.PerformanceLogs().iteritems():
            lines = [str(l).rstrip() for l in log]
            slave_utils.WriteLogLines(logname, lines, perf=perf_dashboard_id)
def emit_warning(title, log=None):
    print '@@@STEP_WARNINGS@@@'
    print title
    if log:
        slave_utils.WriteLogLines(title, log.split('\n'))