author ffxbld
Thu, 09 May 2013 15:11:43 -0700
changeset 3140 3e95f8313a4ca060a3ca10d65a2179e68226f181
parent 3107 eff46a18a2ed256dad582e40bca7e8b8d8efc2b0
permissions -rw-r--r--
Added tag THUNDERBIRD_17_0_6_RELEASE, THUNDERBIRD_17_0_6_BUILD1, THUNDERBIRD_17_0_6esr_RELEASE, THUNDERBIRD_17_0_6esr_BUILD1 for changeset b8b14096491c

import re
import os
import time
import copy
from import WithProperties
from buildbot.status.builder import SUCCESS, WARNINGS, FAILURE, SKIPPED, EXCEPTION, worst_status

from buildbotcustom.steps.base import ShellCommand

class MozillaUpdateConfig(ShellCommand):
    """Configure YAML file for"""
    name = "Update config"

    def __init__(self, branch, branchName, executablePath,
                 addOptions=None, useSymbols=False,
                 remoteTests=False, extName=None, remoteExtras=None,

        if addOptions is None:
            self.addOptions = []
            self.addOptions = addOptions[:]

        if remoteExtras is not None:
            self.remoteExtras = remoteExtras
            self.remoteExtras = {}

        self.remoteOptions = self.remoteExtras.get('options', [])

        self.branch = branch
        self.branchName = branchName
        self.exePath = executablePath
        self.useSymbols = useSymbols
        self.extName = extName
        self.remoteTests = remoteTests

        self.super_class = ShellCommand
        self.super_class.__init__(self, **kwargs)

        self.addFactoryArguments(branch=branch, addOptions=addOptions,
                                 branchName=branchName, executablePath=executablePath,
                                 remoteTests=remoteTests, useSymbols=useSymbols,

    def setBuild(self, build):
        self.super_class.setBuild(self, build)
        title = build.slavename

            self.addOptions += self.getProperty(
        # Property doesn't exist, that's fine
        except KeyError:

        if self.useSymbols:
            self.addOptions += ['--symbolsPath', '../symbols']

        if self.remoteTests:
            exePath = WithProperties("%(remoteProcessName)s")
            perfconfigurator = ""
            self.addOptions += ['--remoteDevice',
                                WithProperties('%(sut_ip)s'), ]
            self.addOptions += self.remoteOptions
            exePath = self.exePath
            perfconfigurator = ""

        self.setCommand(["python", perfconfigurator, "-v", "-e", exePath,
                         "-t", title, '--branchName', self.branchName] + self.addOptions)

    def evaluateCommand(self, cmd):
        superResult = self.super_class.evaluateCommand(self, cmd)
        if SUCCESS != superResult:
            return superResult
        stdioText = cmd.logs['stdio'].getText()
        if None !='ERROR', stdioText):
            return FAILURE
        if None !='USAGE:', stdioText):
            return FAILURE
        configFileMatch ='outputName\s*=\s*(\w*?.yml)', stdioText)
        if not configFileMatch:
            return FAILURE
        return SUCCESS

class MozillaRunPerfTests(ShellCommand):
    """Run the performance tests"""
    name = "Run performance tests"

    def __init__(self, **kwargs):
        self.super_class = ShellCommand
        self.super_class.__init__(self, **kwargs)

    def createSummary(self, log):
        summary = []
        for line in log.readlines():
            if "RETURN:" in line:
                summary.append(line.replace("RETURN:", "TinderboxPrint:"))
            if "FAIL:" in line:
                summary.append(line.replace("FAIL:", "talosError:"))
        self.addCompleteLog('summary', "\n".join(summary))

    def evaluateCommand(self, cmd):
        superResult = self.super_class.evaluateCommand(self, cmd)
        stdioText = cmd.logs['stdio'].getText()
        # Override the result for non-harness/infra failures, so they are shown as
        # orange (WARNINGS) rather than red (FAILURE) on TBPL
        if FAILURE == superResult and \
            (None !='PROCESS-CRASH', stdioText) or
             None !='TEST-UNEXPECTED-FAIL', stdioText)):
            return WARNINGS
        if SUCCESS != superResult:
            return superResult
        # In case there were error/fail lines even with a zero return value
        # TODO: We should fix up all failure modes in Talos to exit non-zero
        # so we don't need these
        if None !='ERROR', stdioText):
            return FAILURE
        if None !='FAIL:', stdioText):
            return WARNINGS
        return SUCCESS