示例#1
0
class SubunitLogObserver(logobserver.LogLineObserver, TestResult):

    """Observe a log that may contain subunit output.

    This class extends TestResult to receive the callbacks from the subunit
    parser in the most direct fashion.
    """

    def __init__(self):
        super().__init__()
        try:
            from subunit import TestProtocolServer, PROGRESS_CUR, PROGRESS_SET
            from subunit import PROGRESS_PUSH, PROGRESS_POP
        except ImportError:
            raise ImportError("subunit is not importable, but is required for "
                              "SubunitLogObserver support.")
        self.PROGRESS_CUR = PROGRESS_CUR
        self.PROGRESS_SET = PROGRESS_SET
        self.PROGRESS_PUSH = PROGRESS_PUSH
        self.PROGRESS_POP = PROGRESS_POP
        self.warningio = io.BytesIO()
        self.protocol = TestProtocolServer(self, self.warningio)
        self.skips = []
        self.seen_tags = set()  # don't yet know what tags does in subunit

    def outLineReceived(self, line):
        # Impedance mismatch: subunit wants lines, observers get lines-no\n
        # Note that observers get already decoded lines whereas protocol wants bytes
        self.protocol.lineReceived(line.encode('utf-8') + b'\n')

    def errLineReceived(self, line):
        # Same note as in outLineReceived applies
        self.protocol.lineReceived(line.encode('utf-8') + b'\n')

    def stopTest(self, test):
        super().stopTest(test)
        self.step.setProgress('tests', self.testsRun)

    def addSkip(self, test, detail):
        if hasattr(TestResult, 'addSkip'):
            super().addSkip(test, detail)
        else:
            self.skips.append((test, detail))

    def addError(self, test, err):
        super().addError(test, err)
        self.issue(test, err)

    def addFailure(self, test, err):
        super().addFailure(test, err)
        self.issue(test, err)

    def issue(self, test, err):
        """An issue - failing, erroring etc test."""
        self.step.setProgress('tests failed', len(self.failures) +
                              len(self.errors))

    def tags(self, new_tags, gone_tags):
        """Accumulate the seen tags."""
        self.seen_tags.update(new_tags)
示例#2
0
class SubunitLogObserver(logobserver.LogLineObserver, TestResult):

    """Observe a log that may contain subunit output.

    This class extends TestResult to receive the callbacks from the subunit
    parser in the most direct fashion.
    """

    def __init__(self):
        super().__init__()
        try:
            from subunit import TestProtocolServer, PROGRESS_CUR, PROGRESS_SET
            from subunit import PROGRESS_PUSH, PROGRESS_POP
        except ImportError:
            raise ImportError("subunit is not importable, but is required for "
                              "SubunitLogObserver support.")
        self.PROGRESS_CUR = PROGRESS_CUR
        self.PROGRESS_SET = PROGRESS_SET
        self.PROGRESS_PUSH = PROGRESS_PUSH
        self.PROGRESS_POP = PROGRESS_POP
        self.warningio = NativeStringIO()
        self.protocol = TestProtocolServer(self, self.warningio)
        self.skips = []
        self.seen_tags = set()  # don't yet know what tags does in subunit

    def outLineReceived(self, line):
        """Process a received stdout line."""
        # Impedance mismatch: subunit wants lines, observers get lines-no\n
        self.protocol.lineReceived(line + '\n')

    def errLineReceived(self, line):
        """same for stderr line."""
        self.protocol.lineReceived(line + '\n')

    def stopTest(self, test):
        super().stopTest(test)
        self.step.setProgress('tests', self.testsRun)

    def addSkip(self, test, detail):
        if hasattr(TestResult, 'addSkip'):
            super().addSkip(test, detail)
        else:
            self.skips.append((test, detail))

    def addError(self, test, err):
        super().addError(test, err)
        self.issue(test, err)

    def addFailure(self, test, err):
        super().addFailure(test, err)
        self.issue(test, err)

    def issue(self, test, err):
        """An issue - failing, erroring etc test."""
        self.step.setProgress('tests failed', len(self.failures) +
                              len(self.errors))

    def tags(self, new_tags, gone_tags):
        """Accumulate the seen tags."""
        self.seen_tags.update(new_tags)
示例#3
0
 def __init__(self):
     buildstep.LogLineObserver.__init__(self)
     TestResult.__init__(self)
     try:
         from subunit import TestProtocolServer
     except ImportError:
         raise ImportError("subunit is not importable, but is required for "
                           "SubunitLogObserver support.")
     self.protocol = TestProtocolServer(self, DiscardStream())
示例#4
0
class SubunitLogObserver(buildstep.LogLineObserver, TestResult):
    """Observe a log that may contain subunit output.

    This class extends TestResult to receive the callbacks from the subunit
    parser in the most direct fashion.
    """

    def __init__(self):
        buildstep.LogLineObserver.__init__(self)
        TestResult.__init__(self)
        try:
            from subunit import TestProtocolServer
        except ImportError:
            raise ImportError("subunit is not importable, but is required for "
                "SubunitLogObserver support.")
        self.warningio = StringIO()
        self.protocol = TestProtocolServer(self, self.warningio)
        self.skips = []
        self.seen_tags = set() #don't yet know what tags does in subunit

    def outLineReceived(self, line):
        """Process a received stdout line."""
        # Impedance mismatch: subunit wants lines, observers get lines-no\n
        self.protocol.lineReceived(line + '\n')

    def errLineReceived(self, line):
        """same for stderr line."""
        self.protocol.lineReceived(line + '\n')

    def startTest(self, test):
        TestResult.startTest(self, test)
        self.step.setProgress('tests', self.testsRun)

    def addSkip(self, test, detail):
        if hasattr(TestResult,'addSkip'):
            TestResult.addSkip(self, test, detail)
        else:
            self.skips.append((test, detail))

    def addError(self, test, err):
        TestResult.addError(self, test, err)
        self.issue()

    def addFailure(self, test, err):
        TestResult.addFailure(self, test, err)
        self.issue()

    def issue(self):
        """An issue - failing, erroring etc test."""
        self.step.setProgress('tests failed', len(self.failures) + 
            len(self.errors))

    def tags(self, new_tags, gone_tags):
        """Accumulate the seen tags."""
        self.seen_tags.update(new_tags)
示例#5
0
 def __init__(self):
     buildstep.LogLineObserver.__init__(self)
     TestResult.__init__(self)
     try:
         from subunit import TestProtocolServer
     except ImportError:
         raise ImportError("subunit is not importable, but is required for "
             "SubunitLogObserver support.")
     self.warningio = StringIO()
     self.protocol = TestProtocolServer(self, self.warningio)
     self.skips = []
     self.seen_tags = set() #don't yet know what tags does in subunit
示例#6
0
 def __init__(self):
     super().__init__()
     try:
         from subunit import TestProtocolServer, PROGRESS_CUR, PROGRESS_SET
         from subunit import PROGRESS_PUSH, PROGRESS_POP
     except ImportError as e:
         raise ImportError("subunit is not importable, but is required for "
                           "SubunitLogObserver support.") from e
     self.PROGRESS_CUR = PROGRESS_CUR
     self.PROGRESS_SET = PROGRESS_SET
     self.PROGRESS_PUSH = PROGRESS_PUSH
     self.PROGRESS_POP = PROGRESS_POP
     self.warningio = io.BytesIO()
     self.protocol = TestProtocolServer(self, self.warningio)
     self.skips = []
     self.seen_tags = set()  # don't yet know what tags does in subunit
示例#7
0
 def __init__(self):
     logobserver.LogLineObserver.__init__(self)
     TestResult.__init__(self)
     try:
         from subunit import TestProtocolServer, PROGRESS_CUR, PROGRESS_SET
         from subunit import PROGRESS_PUSH, PROGRESS_POP
     except ImportError:
         raise ImportError("subunit is not importable, but is required for "
                           "SubunitLogObserver support.")
     self.PROGRESS_CUR = PROGRESS_CUR
     self.PROGRESS_SET = PROGRESS_SET
     self.PROGRESS_PUSH = PROGRESS_PUSH
     self.PROGRESS_POP = PROGRESS_POP
     self.warningio = NativeStringIO()
     self.protocol = TestProtocolServer(self, self.warningio)
     self.skips = []
     self.seen_tags = set()  # don't yet know what tags does in subunit
示例#8
0
 def __init__(self):
     buildstep.LogLineObserver.__init__(self)
     TestResult.__init__(self)
     try:
         from subunit import TestProtocolServer
     except ImportError:
         raise ImportError("subunit is not importable, but is required for "
             "SubunitLogObserver support.")
     self.protocol = TestProtocolServer(self, DiscardStream())
示例#9
0
class SubunitPluginTester(PluginTester, unittest.TestCase):
    activate = '--with-subunit'
    plugins = [sunit.Subunit()]
    def getFedSubunitServer(self):
        #subunit.TestProtocolServer would pass the output from 
        #the makeSuite test. the result of the parsing is in 
        #self.testResult (
        self.serverIO = StringIO()
        self.testResult = ServerTestResult()
        self.server = TestProtocolServer(self.testResult,self.serverIO)
        #print self.output,
        lastline = ""
        print self.output
        for line in self.output:
            self.server.lineReceived(line)
            if line.startswith("test:") and line==lastline:
                raise Exception('subunit output should not contain two consecutive identical lines starting with "tests:"')
            lastline = line

        return self.server
示例#10
0
 def __init__(self):
     buildstep.LogLineObserver.__init__(self)
     TestResult.__init__(self)
     try:
         from subunit import TestProtocolServer
     except ImportError:
         raise ImportError("subunit is not importable, but is required for " "SubunitLogObserver support.")
     self.warningio = StringIO()
     self.protocol = TestProtocolServer(self, self.warningio)
     self.skips = []
     self.seen_tags = set()  # don't yet know what tags does in subunit
示例#11
0
class SubunitLogObserver(buildstep.LogLineObserver, TestResult):
    """Observe a log that may contain subunit output.

    This class extends TestResult to receive the callbacks from the subunit
    parser in the most direct fashion.
    """
    def __init__(self):
        buildstep.LogLineObserver.__init__(self)
        TestResult.__init__(self)
        try:
            from subunit import TestProtocolServer
        except ImportError:
            raise ImportError("subunit is not importable, but is required for "
                              "SubunitLogObserver support.")
        self.protocol = TestProtocolServer(self, DiscardStream())

    def outLineReceived(self, line):
        """Process a received line."""
        # Impedance mismatch: subunit wants lines, observers get lines-no\n
        self.protocol.lineReceived(line + '\n')

    def startTest(self, test):
        TestResult.startTest(self, test)
        self.step.setProgress('tests', self.testsRun)

    def addError(self, test, err):
        TestResult.addError(self, test, err)
        self.issue()

    def addFailure(self, test, err):
        TestResult.addFailure(self, test, err)
        self.issue()

    def issue(self):
        """An issue - failing, erroring etc test."""
        self.step.setProgress('tests failed',
                              len(self.failures) + len(self.errors))
示例#12
0
class SubunitLogObserver(buildstep.LogLineObserver, TestResult):
    """Observe a log that may contain subunit output.

    This class extends TestResult to receive the callbacks from the subunit
    parser in the most direct fashion.
    """

    def __init__(self):
        buildstep.LogLineObserver.__init__(self)
        TestResult.__init__(self)
        try:
            from subunit import TestProtocolServer
        except ImportError:
            raise ImportError("subunit is not importable, but is required for "
                "SubunitLogObserver support.")
        self.protocol = TestProtocolServer(self, DiscardStream())

    def outLineReceived(self, line):
        """Process a received line."""
        # Impedance mismatch: subunit wants lines, observers get lines-no\n
        self.protocol.lineReceived(line + '\n')

    def startTest(self, test):
        TestResult.startTest(self, test)
        self.step.setProgress('tests', self.testsRun)

    def addError(self, test, err):
        TestResult.addError(self, test, err)
        self.issue()

    def addFailure(self, test, err):
        TestResult.addFailure(self, test, err)
        self.issue()

    def issue(self):
        """An issue - failing, erroring etc test."""
        self.step.setProgress('tests failed', len(self.failures) + len(self.errors))
示例#13
0
 def __init__(self):
     super().__init__()
     try:
         from subunit import TestProtocolServer, PROGRESS_CUR, PROGRESS_SET
         from subunit import PROGRESS_PUSH, PROGRESS_POP
     except ImportError:
         raise ImportError("subunit is not importable, but is required for "
                           "SubunitLogObserver support.")
     self.PROGRESS_CUR = PROGRESS_CUR
     self.PROGRESS_SET = PROGRESS_SET
     self.PROGRESS_PUSH = PROGRESS_PUSH
     self.PROGRESS_POP = PROGRESS_POP
     self.warningio = NativeStringIO()
     self.protocol = TestProtocolServer(self, self.warningio)
     self.skips = []
     self.seen_tags = set()  # don't yet know what tags does in subunit
示例#14
0
class SubunitLogObserver(buildstep.LogLineObserver, TestResult):
    """Observe a log that may contain subunit output.

    This class extends TestResult to receive the callbacks from the subunit
    parser in the most direct fashion.
    """
    def __init__(self):
        buildstep.LogLineObserver.__init__(self)
        TestResult.__init__(self)
        try:
            from subunit import TestProtocolServer, PROGRESS_CUR, PROGRESS_SET
            from subunit import PROGRESS_PUSH, PROGRESS_POP
        except ImportError:
            raise ImportError("subunit is not importable, but is required for "
                              "SubunitLogObserver support.")
        self.PROGRESS_CUR = PROGRESS_CUR
        self.PROGRESS_SET = PROGRESS_SET
        self.PROGRESS_PUSH = PROGRESS_PUSH
        self.PROGRESS_POP = PROGRESS_POP
        self.warningio = StringIO()
        self.protocol = TestProtocolServer(self, self.warningio)
        self.skips = []
        self.seen_tags = set()  #don't yet know what tags does in subunit

    def outLineReceived(self, line):
        """Process a received stdout line."""
        # Impedance mismatch: subunit wants lines, observers get lines-no\n
        self.protocol.lineReceived(line + '\n')

    def errLineReceived(self, line):
        """same for stderr line."""
        self.protocol.lineReceived(line + '\n')

    def stopTest(self, test):
        TestResult.stopTest(self, test)
        self.step.setProgress('tests', self.testsRun)

    def addSuccess(self, test):
        TestResult.addSuccess(self, test)
        self.addAResult(test, SUCCESS, 'SUCCESS')

    def addSkip(self, test, detail):
        if hasattr(TestResult, 'addSkip'):
            TestResult.addSkip(self, test, detail)
        else:
            self.skips.append((test, detail))
        self.addAResult(test, SKIPPED, 'SKIPPED', detail)

    def addError(self, test, err):
        TestResult.addError(self, test, err)
        self.issue(test, err)

    def addFailure(self, test, err):
        TestResult.addFailure(self, test, err)
        self.issue(test, err)

    def addAResult(self, test, result, text, log=""):
        tr = aTestResult(tuple(test.id().split('.')), result, text, log)
        self.step.build.build_status.addTestResult(tr)

    def issue(self, test, err):
        """An issue - failing, erroring etc test."""
        self.addAResult(test, FAILURE, 'FAILURE', err)
        self.step.setProgress('tests failed',
                              len(self.failures) + len(self.errors))

    expectedTests = 0
    contextLevel = 0

    def progress(self, offset, whence):
        if not self.contextLevel:
            if whence == self.PROGRESS_CUR:
                self.expectedTests += offset
            elif whence == self.PROGRESS_SET:
                self.expectedTests = offset
            self.step.progress.setExpectations({'tests': self.expectedTests})
        #TODO: properly support PUSH/POP
        if whence == self.PROGRESS_PUSH:
            self.contextLevel += 1
        elif whence == self.PROGRESS_POP:
            self.contextLevel -= 1

    def tags(self, new_tags, gone_tags):
        """Accumulate the seen tags."""
        self.seen_tags.update(new_tags)
示例#15
0
class SubunitLogObserver(logobserver.LogLineObserver, TestResult):

    """Observe a log that may contain subunit output.

    This class extends TestResult to receive the callbacks from the subunit
    parser in the most direct fashion.
    """

    def __init__(self):
        logobserver.LogLineObserver.__init__(self)
        TestResult.__init__(self)
        try:
            from subunit import TestProtocolServer, PROGRESS_CUR, PROGRESS_SET
            from subunit import PROGRESS_PUSH, PROGRESS_POP
        except ImportError:
            raise ImportError("subunit is not importable, but is required for "
                              "SubunitLogObserver support.")
        self.PROGRESS_CUR = PROGRESS_CUR
        self.PROGRESS_SET = PROGRESS_SET
        self.PROGRESS_PUSH = PROGRESS_PUSH
        self.PROGRESS_POP = PROGRESS_POP
        self.warningio = StringIO()
        self.protocol = TestProtocolServer(self, self.warningio)
        self.skips = []
        self.seen_tags = set()  # don't yet know what tags does in subunit

    def outLineReceived(self, line):
        """Process a received stdout line."""
        # Impedance mismatch: subunit wants lines, observers get lines-no\n
        self.protocol.lineReceived(line + '\n')

    def errLineReceived(self, line):
        """same for stderr line."""
        self.protocol.lineReceived(line + '\n')

    def stopTest(self, test):
        TestResult.stopTest(self, test)
        self.step.setProgress('tests', self.testsRun)

    def addSuccess(self, test):
        TestResult.addSuccess(self, test)
        self.addAResult(test, SUCCESS, 'SUCCESS')

    def addSkip(self, test, detail):
        if hasattr(TestResult, 'addSkip'):
            TestResult.addSkip(self, test, detail)
        else:
            self.skips.append((test, detail))
        self.addAResult(test, SKIPPED, 'SKIPPED', detail)

    def addError(self, test, err):
        TestResult.addError(self, test, err)
        self.issue(test, err)

    def addFailure(self, test, err):
        TestResult.addFailure(self, test, err)
        self.issue(test, err)

    def addAResult(self, test, result, text, log=""):
        tr = aTestResult(tuple(test.id().split('.')), result, text, log)
        self.step.build.build_status.addTestResult(tr)

    def issue(self, test, err):
        """An issue - failing, erroring etc test."""
        self.addAResult(test, FAILURE, 'FAILURE', err)
        self.step.setProgress('tests failed', len(self.failures) +
                              len(self.errors))

    expectedTests = 0
    contextLevel = 0

    def progress(self, offset, whence):
        if not self.contextLevel:
            if whence == self.PROGRESS_CUR:
                self.expectedTests += offset
            elif whence == self.PROGRESS_SET:
                self.expectedTests = offset
            self.step.progress.setExpectations({'tests': self.expectedTests})
        # TODO: properly support PUSH/POP
        if whence == self.PROGRESS_PUSH:
            self.contextLevel += 1
        elif whence == self.PROGRESS_POP:
            self.contextLevel -= 1

    def tags(self, new_tags, gone_tags):
        """Accumulate the seen tags."""
        self.seen_tags.update(new_tags)