예제 #1
0
    def run(self):
        path = self.ui.here
        try:
            repo = self.repository_factory.open(path)
        except RepositoryNotFound:
            if self.ui.options.force_init:
                repo = self.repository_factory.initialise(path)
            else:
                raise
        testcommand = self.command_factory(self.ui, repo)
        # Not a full implementation of TestCase, but we only need to iterate
        # back to it. Needs to be a callable - its a head fake for
        # testsuite.add.
        # XXX: Be nice if we could declare that the argument, which is a path,
        # is to be an input stream - and thus push this conditional down into
        # the UI object.
        if self.ui.arguments.get('streams'):
            opener = partial(open, mode='rb')
            streams = map(opener, self.ui.arguments['streams'])
        else:
            streams = self.ui.iter_streams('subunit')
        mktagger = lambda pos, result: testtools.StreamTagger(
            [result], add=['worker-%d' % pos])

        def make_tests():
            for pos, stream in enumerate(streams):
                # Calls StreamResult API.
                case = subunit.ByteStreamToStreamResult(
                    stream, non_subunit_name='stdout')
                decorate = partial(mktagger, pos)
                case = testtools.DecorateTestCaseResult(case, decorate)
                yield (case, str(pos))
예제 #2
0
    def run(self):
        path = self.ui.here
        try:
            repo = self.repository_factory.open(path)
        except RepositoryNotFound:
            if self.ui.options.force_init:
                repo = self.repository_factory.initialise(path)
            else:
                raise
        testcommand = self.command_factory(self.ui, repo)
        # Not a full implementation of TestCase, but we only need to iterate
        # back to it. Needs to be a callable - its a head fake for
        # testsuite.add.
        # XXX: Be nice if we could declare that the argument, which is a path,
        # is to be an input stream - and thus push this conditional down into
        # the UI object.
        if self.ui.arguments.get('streams'):
            opener = partial(open, mode='rb')
            streams = map(opener, self.ui.arguments['streams'])
        else:
            streams = self.ui.iter_streams('subunit')
        mktagger = lambda pos, result: testtools.StreamTagger(
            [result], add=['worker-%d' % pos])

        def make_tests():
            for pos, stream in enumerate(streams):
                if v2_avail:
                    # Calls StreamResult API.
                    case = subunit.ByteStreamToStreamResult(
                        stream, non_subunit_name='stdout')
                else:
                    # Calls TestResult API.
                    case = subunit.ProtocolTestCase(stream)

                    def wrap_result(result):
                        # Wrap in a router to mask out startTestRun/stopTestRun from the
                        # ExtendedToStreamDecorator.
                        result = testtools.StreamResultRouter(
                            result, do_start_stop_run=False)
                        # Wrap that in ExtendedToStreamDecorator to convert v1 calls to
                        # StreamResult.
                        return testtools.ExtendedToStreamDecorator(result)

                    # Now calls StreamResult API :).
                    case = testtools.DecorateTestCaseResult(
                        case, wrap_result, methodcaller('startTestRun'),
                        methodcaller('stopTestRun'))
                decorate = partial(mktagger, pos)
                case = testtools.DecorateTestCaseResult(case, decorate)
                yield (case, str(pos))
예제 #3
0
 def mktagger(pos, result):
     return testtools.StreamTagger([result], add=['worker-%d' % pos])