Ejemplo n.º 1
0
    def renderIndividualTestResults(self):
        #show broken out tests over the last N commits
        rows = [self.testRun]

        def rowLinkFun(row):
            return self.contextFor(row).renderLink(includeCommit=False, includeTest=False)

        def testFun(row):
            return [row]

        def cellUrlFun(testGroup, row):
            return None

        def rowContextFun(row):
            return row

        renderer = IndividualTestGridRenderer.IndividualTestGridRenderer(
            rows,
            self, 
            testFun,
            cellUrlFun,
            rowContextFun
            )

        grid = [["Test Run", "Logs", "Elapsed (Min)", "Status", ""] + renderer.headers()]

        for testRun in rows:
            row = [rowLinkFun(testRun),self.renderer.testLogsButton(testRun._identity)]

            if testRun.endTimestamp > 0.0:
                elapsed = (testRun.endTimestamp - testRun.startedTimestamp) / 60.0
            else:
                elapsed = (time.time() - testRun.startedTimestamp) / 60.0

            row.append("%.2f" % elapsed)

            if testRun.endTimestamp > 0.0:
                row.append("passed" if testRun.success else "failed")
            else:
                row.append("running")

            row.append(" ")

            grid.append(row + renderer.gridRow(testRun))

        grid = HtmlGeneration.transposeGrid(grid)

        return HtmlGeneration.grid(grid, dataTables=True, header_rows=5)
Ejemplo n.º 2
0
    def renderTestResultsGrid(self):
        projectFilter = self.projectFilter
        configFilter = self.configFilter

        projects = set()
        configurations = set()

        for t in self.allTests():
            if self.shouldIncludeTest(t):
                projects.add(t.testDefinitionSummary.project)
                configurations.add(t.testDefinitionSummary.configuration)

        if not projectFilter and len(projects) == 1:
            projectFilter = list(projects)[0]

        if not configFilter and len(configurations) == 1:
            configFilter = list(configurations)[0]

        if not (projectFilter or configFilter):
            return self.renderProjectAndFilterCrossGrid()

        if configFilter and not projectFilter:
            return self.renderProjectAndFilterCrossGridOverCommits(
                configFilter)

        if not configurations or not projects:
            return card("No tests defined.")

        if configFilter:
            #show broken out tests over the last N commits
            rows = [self.commit]
            while len(rows) < self.commitsToRender(
            ) and rows[-1].data and rows[-1].data.parents:
                rows.append(rows[-1].data.parents[-1])

            def rowLinkFun(row):
                return self.contextFor(
                    ComboContexts.CommitAndFilter(
                        row, configFilter,
                        projectFilter)).withOptions(**self.options).renderLink(
                            includeRepo=False, includeBranch=False)

            def testFun(row):
                for t in self.testManager.allTestsForCommit(row):
                    if self.shouldIncludeTest(
                            t) and t.testDefinitionSummary.type == "Test":
                        yield t

            def cellUrlFun(testGroup, row):
                return self.contextFor(
                    ComboContexts.CommitAndFilter(
                        row, configFilter, projectFilter)).withOptions(
                            **self.options).withOptions(
                                testGroup=testGroup).urlString()

            def rowContextFun(row):
                return ComboContexts.CommitAndFilter(row, configFilter,
                                                     projectFilter)
        else:
            #show tests over configurations
            rows = sorted(configurations)

            def rowLinkFun(row):
                return self.contextFor(
                    ComboContexts.CommitAndFilter(
                        self.commit, row, projectFilter)).withOptions(
                            **self.options).renderNavbarLink(textOverride=row)

            def testFun(row):
                for t in self.testManager.allTestsForCommit(self.commit):
                    if self.shouldIncludeTest(
                            t
                    ) and t.testDefinitionSummary.type == "Test" and t.testDefinitionSummary.configuration == row:
                        yield t

            def cellUrlFun(testGroup, row):
                return self.contextFor(
                    ComboContexts.CommitAndFilter(
                        self.commit, row, projectFilter)).withOptions(
                            **self.options).withOptions(
                                testGroup=testGroup).urlString()

            def rowContextFun(row):
                return ComboContexts.CommitAndFilter(self.commit, row,
                                                     projectFilter)

        renderer = IndividualTestGridRenderer.IndividualTestGridRenderer(
            rows, self, testFun, cellUrlFun, rowContextFun)

        grid = [[""] + renderer.headers()]

        for row in rows:
            grid.append([rowLinkFun(row)] + renderer.gridRow(row))

        grid = HtmlGeneration.transposeGrid(grid)

        return HtmlGeneration.grid(grid, dataTables=True)