Example #1
0
    def consumePath(self, path):
        if path and path[0] == "configurations":
            groupPath, remainder = self.popToDash(path[1:])

            if not path:
                return None, path

            configurationName = "/".join(groupPath)

            return self.contextFor(
                ComboContexts.BranchAndFilter(self.branch, configurationName,
                                              self.projectFilter)), remainder

        if path and path[0] == "projects":
            groupPath, remainder = self.popToDash(path[1:])

            if not path:
                return None, path

            projectName = "/".join(groupPath)

            return self.contextFor(
                ComboContexts.BranchAndFilter(self.branch,
                                              self.configurationFilter,
                                              projectName)), remainder

        return None, path
Example #2
0
    def renderProjectAndFilterCrossGrid(self):
        projects = set()
        configurations = set()

        for t in self.allTests():
            if t.testDefinitionSummary.type == "Test" and self.shouldIncludeTest(
                    t):
                projects.add(t.testDefinitionSummary.project)
                configurations.add(t.testDefinitionSummary.configuration)

        renderer = TestGridRenderer.TestGridRenderer(
            sorted(projects), lambda p: [
                t for t in self.allTests() if t.testDefinitionSummary.project
                == p and self.shouldIncludeTest(t)
            ], lambda group: self.contextFor(
                ComboContexts.CommitAndFilter(self.commit, group, "")
            ).renderNavbarLink(textOverride=group),
            lambda group, row: self.contextFor(
                ComboContexts.CommitAndFilter(self.commit, group, row)).
            urlString(), lambda test: test.testDefinitionSummary.configuration)

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

        for p in sorted(projects):
            gridrow = renderer.gridRow(p)

            grid.append([
                self.contextFor(
                    ComboContexts.CommitAndFilter(
                        self.commit, "", p)).renderLink(textOverride=p)
            ] + gridrow)

        return HtmlGeneration.grid(grid)
Example #3
0
    def getSomeObjects(self):
        objects = ["repos", "machines", "deployments"]

        for r in self.database.Repo.lookupAll(isActive=True):
            objects.append(r)
            for b in self.database.Branch.lookupAll(repo=r):
                objects.append(b)

                objects.append(ComboContexts.BranchAndFilter(b, "linux", ""))
                objects.append(
                    ComboContexts.BranchAndFilter(
                        b, "", "test_with_individual_failures_1"))

                for c in self.testManager.commitsToDisplayForBranch(b, 100):
                    objects.append(c)

                    objects.append(
                        ComboContexts.CommitAndFilter(
                            c, "linux", "test_with_individual_failures_1"))
                    objects.append(
                        ComboContexts.CommitAndFilter(
                            c, "", "test_with_individual_failures_1"))

                    for t in self.testManager.allTestsForCommit(c):
                        objects.append(t)

                        for r in self.database.TestRun.lookupAll(test=t):
                            objects.append(r)

        return objects
Example #4
0
    def getGridRenderer(self, commits):
        projectFilter = self.projectFilter
        configFilter = self.configurationFilter

        def shouldIncludeTest(test):
            if test.testDefinitionSummary.disabled:
                return False
            if self.projectFilter and test.testDefinitionSummary.project != self.projectFilter:
                return False
            if self.configurationFilter and test.testDefinitionSummary.configuration != self.configurationFilter:
                return False
            return True

        projects = set()
        configurations = set()

        for c in commits:
            for t in self.testManager.allTestsForCommit(c):
                if 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:
            return TestGridRenderer.TestGridRenderer(
                commits, lambda c: [
                    t for t in self.testManager.allTestsForCommit(c)
                    if shouldIncludeTest(t)
                ] if c.data else [], lambda group: self.contextFor(
                    ComboContexts.BranchAndFilter(self.branch, configFilter,
                                                  group)).renderNavbarLink(),
                lambda group, row: self.contextFor(
                    ComboContexts.CommitAndFilter(row, configFilter, group)
                ).urlString(), lambda test: test.testDefinitionSummary.project)

        if not configFilter:
            return TestGridRenderer.TestGridRenderer(
                commits, lambda c: [
                    t for t in self.testManager.allTestsForCommit(c)
                    if shouldIncludeTest(t)
                ] if c.data else [], lambda group: self.contextFor(
                    ComboContexts.BranchAndFilter(
                        self.branch, group, projectFilter)).renderNavbarLink(),
                lambda group, row: self.contextFor(
                    ComboContexts.CommitAndFilter(row, group, projectFilter)
                ).urlString(),
                lambda test: test.testDefinitionSummary.configuration)

        return TestGridRenderer.TestGridRenderer(
            commits, lambda c: [
                t for t in self.testManager.allTestsForCommit(c)
                if shouldIncludeTest(t)
            ] if c.data else [], lambda group: "", lambda group, row: "",
            lambda test: "")
Example #5
0
 def makeRenderer(commit):
     return TestGridRenderer.TestGridRenderer(
         sorted(projects), lambda p: [
             t for t in self.allTests() if self.shouldIncludeTest(
                 t) and t.testDefinitionSummary.project == p and t.
             testDefinitionSummary.configuration == configFilter
         ], lambda group: self.contextFor(
             ComboContexts.CommitAndFilter(commit, configFilter,
                                           group)).renderLink(
                                               textOverride=group,
                                               includeRepo=False,
                                               includeBranch=False),
         lambda group, row: self.contextFor(
             ComboContexts.CommitAndFilter(commit, group, row)
         ).urlString(), lambda test: "")
Example #6
0
 def primaryObject(self):
     if not self.configurationFilter and not self.projectFilter:
         return self.branch
     else:
         return ComboContexts.BranchAndFilter(self.branch,
                                              self.configurationFilter,
                                              self.projectFilter)
Example #7
0
 def primaryObject(self):
     if not (self.configFilter or self.projectFilter):
         return self.commit
     else:
         return ComboContexts.CommitAndFilter(self.commit,
                                              self.configFilter,
                                              self.projectFilter)
Example #8
0
    def consumePath(self, path):
        while path and path[0] == "-":
            path = path[1:]

        if path and path[0] == "individualTest":
            return self.contextFor(
                ComboContexts.IndividualTest(self.primaryObject(),
                                             "/".join(path[1:]))), []

        if path and path[0] == "configurations":
            groupPath, remainder = self.popToDash(path[1:])

            if not path:
                return None, path

            configurationName = "/".join(groupPath)

            return self.contextFor(
                ComboContexts.CommitAndFilter(self.commit, configurationName,
                                              self.projectFilter)), remainder

        if path and path[0] == "projects":
            groupPath, remainder = self.popToDash(path[1:])

            if not path:
                return None, path

            projectName = "/".join(groupPath)

            return self.contextFor(
                ComboContexts.CommitAndFilter(self.commit, self.configFilter,
                                              projectName)), remainder

        if path and path[0] == "tests":
            testpath, remainder = self.popToDash(path[1:])

            testname = "/".join(testpath)

            if testname in self.commit.data.tests:
                test = self.commit.data.tests[testname]
            else:
                return None, path

            return self.renderer.contextFor(test, self.options), remainder

        return None, path
Example #9
0
    def consumePath(self, path):
        while path and path[0] == "-":
            path = path[1:]

        if path and path[0] == "individualTest":
            return self.contextFor(ComboContexts.IndividualTest(self.testRun, "/".join(path[1:]))), []

        return None, path
Example #10
0
 def parentContext(self):
     return self.contextFor(
         ComboContexts.CommitAndFilter(
             commit=self.commit, 
             configurationName=self.test.testDefinitionSummary.configuration,
             projectName=self.test.testDefinitionSummary.project,
             )
         )
Example #11
0
    def parentContext(self):
        if self.projectFilter and self.configFilter:
            return self.contextFor(
                ComboContexts.CommitAndFilter(
                    self.commit, "",
                    self.projectFilter)).withOptions(**self.options)

        if self.configFilter or self.projectFilter:
            return self.contextFor(
                ComboContexts.CommitAndFilter(self.commit, "",
                                              "")).withOptions(**self.options)

        branch, name = self.testManager.bestCommitBranchAndName(self.commit)

        if branch:
            return self.contextFor(branch)

        return self.contextFor(self.commit.repo)
Example #12
0
    def consumePath(self, path):
        while path and path[0] == "-":
            path = path[1:]

        if path and path[0] == "individualTest":
            return self.contextFor(ComboContexts.IndividualTest(self.test, "/".join(path[1:]))), []

        if path and path[0] == "test":
            items, remainder = self.popToDash(path[1:])

            return self.renderer.contextFor(ComboContexts.IndividualTest(self.test, "/".join(items)), self.options), remainder

        if path:
            testRun = self.database.TestRun(path[0])
            if testRun.exists():
                return self.renderer.contextFor(testRun, self.options), path[1:]

        return None, path
Example #13
0
    def parentContext(self):
        if self.configurationFilter and self.projectFilter:
            return self.contextFor(
                ComboContexts.BranchAndFilter(
                    self.branch, None,
                    self.projectFilter)).withOptions(**self.options)

        if self.configurationFilter or self.projectFilter:
            return self.contextFor(self.branch)
        return self.contextFor(self.branch.repo)
Example #14
0
    def renderProjectAndFilterCrossGridOverCommits(self, configFilter):
        projects = set()

        for t in self.allTests():
            if t.testDefinitionSummary.type == "Test" and self.shouldIncludeTest(
                    t):
                projects.add(t.testDefinitionSummary.project)

        commits = [self.commit]
        while len(commits) < self.commitsToRender(
        ) and commits[-1].data and commits[-1].data.parents:
            commits.append(commits[-1].data.parents[-1])

        grid = []
        renderers = []
        for c in commits:

            def makeRenderer(commit):
                return TestGridRenderer.TestGridRenderer(
                    sorted(projects), lambda p: [
                        t for t in self.allTests() if self.shouldIncludeTest(
                            t) and t.testDefinitionSummary.project == p and t.
                        testDefinitionSummary.configuration == configFilter
                    ], lambda group: self.contextFor(
                        ComboContexts.CommitAndFilter(commit, configFilter,
                                                      group)).renderLink(
                                                          textOverride=group,
                                                          includeRepo=False,
                                                          includeBranch=False),
                    lambda group, row: self.contextFor(
                        ComboContexts.CommitAndFilter(commit, group, row)
                    ).urlString(), lambda test: "")

            renderers.append(makeRenderer(c))

        grid = [[""] + [renderer.headers()[0] for renderer in renderers]]

        for project in sorted(projects):
            gridrow = [renderer.gridRow(project)[0] for renderer in renderers]

            grid.append([
                self.contextFor(
                    ComboContexts.CommitAndFilter(self.commit, configFilter,
                                                  project)).renderLink(
                                                      textOverride=project)
            ] + gridrow)

        return HtmlGeneration.grid(grid)
Example #15
0
    def childContexts(self, currentChild):
        if isinstance(currentChild.primaryObject(),
                      ComboContexts.CommitAndFilter):
            if currentChild.configFilter and currentChild.projectFilter:
                return [
                    self.contextFor(
                        ComboContexts.CommitAndFilter(
                            commit=self.commit,
                            configurationName=g,
                            projectName=self.projectFilter))
                    for g in sorted(
                        set([
                            t.testDefinitionSummary.configuration
                            for t in self.testManager.allTestsForCommit(
                                self.commit) if t.testDefinitionSummary.project
                            == self.projectFilter
                        ]))
                ]
            if currentChild.configFilter:
                return [
                    self.contextFor(
                        ComboContexts.CommitAndFilter(commit=self.commit,
                                                      configurationName=g,
                                                      projectName=""))
                    for g in sorted(
                        set([
                            t.testDefinitionSummary.configuration for t in
                            self.testManager.allTestsForCommit(self.commit)
                        ]))
                ]
            else:
                return [
                    self.contextFor(
                        ComboContexts.CommitAndFilter(commit=self.commit,
                                                      configurationName="",
                                                      projectName=g))
                    for g in sorted(
                        set([
                            t.testDefinitionSummary.project for t in
                            self.testManager.allTestsForCommit(self.commit)
                        ]))
                ]
        if isinstance(currentChild.primaryObject(), self.database.Test):
            if currentChild.primaryObject(
            ).testDefinitionSummary.type == 'Build':
                return [
                    self.contextFor(t)
                    for t in sorted(self.allTests(),
                                    key=lambda t: t.testDefinitionSummary.name)
                    if t.testDefinitionSummary.type == "Build"
                ]
            if currentChild.primaryObject(
            ).testDefinitionSummary.type == 'Test':
                return [
                    self.contextFor(t)
                    for t in sorted(self.allTests(),
                                    key=lambda t: t.testDefinitionSummary.name)
                    if t.testDefinitionSummary.type == "Test"
                ]

        return []
 def primaryObject(self):
     return ComboContexts.IndividualTest(
         context=self.context, individualTestName=self.individualTestName)
Example #17
0
 def rowContextFun(row):
     return ComboContexts.CommitAndFilter(self.commit, row,
                                          projectFilter)
Example #18
0
 def cellUrlFun(testGroup, row):
     return self.contextFor(
         ComboContexts.CommitAndFilter(
             self.commit, row, projectFilter)).withOptions(
                 **self.options).withOptions(
                     testGroup=testGroup).urlString()
Example #19
0
 def rowLinkFun(row):
     return self.contextFor(
         ComboContexts.CommitAndFilter(
             self.commit, row, projectFilter)).withOptions(
                 **self.options).renderNavbarLink(textOverride=row)
Example #20
0
 def rowContextFun(row):
     return ComboContexts.CommitAndFilter(row, configFilter,
                                          projectFilter)
Example #21
0
 def rowLinkFun(row):
     return self.contextFor(
         ComboContexts.CommitAndFilter(
             row, configFilter,
             projectFilter)).withOptions(**self.options).renderLink(
                 includeRepo=False, includeBranch=False)
Example #22
0
 def getContextForCommit(self, commit):
     if self.configurationFilter or self.projectFilter:
         return self.contextFor(
             ComboContexts.CommitAndFilter(commit, self.configurationFilter,
                                           self.projectFilter))
     return self.contextFor(commit)
Example #23
0
    def childContexts(self, currentChild):
        if isinstance(currentChild.primaryObject(), self.database.Commit):
            commit = currentChild.primaryObject()

            children = []

            commitsInBetween = set()
            commitsToCheck = set()
            commitsToCheck.add(self.branch.head)

            while commitsToCheck:
                c = commitsToCheck.pop()

                if c and c not in commitsInBetween:
                    commitsInBetween.add(c)
                    if c.data:
                        for p in c.data.parents:
                            commitsToCheck.add(p)

            #show 10 commits above and below
            return [
                self.contextFor(x) for x in list(
                    reversed(
                        self.testManager.getNCommits(commit, 10, "above",
                                                     commitsInBetween))) +
                [commit] + self.testManager.getNCommits(commit, 10, "below")
            ]

        if isinstance(currentChild.primaryObject(),
                      ComboContexts.BranchAndFilter):
            if currentChild.configurationFilter:
                return [
                    self.contextFor(
                        ComboContexts.BranchAndFilter(
                            branch=self.branch,
                            configurationName=g,
                            projectName=self.projectFilter))
                    for g in sorted(
                        set([
                            t.testDefinitionSummary.configuration for commit in
                            self.testManager.commitsToDisplayForBranch(
                                self.branch, self.maxCommitCount())
                            for t in self.testManager.allTestsForCommit(commit)
                            if t.testDefinitionSummary.project ==
                            self.projectFilter
                        ]))
                ]
            else:
                return [
                    self.contextFor(
                        ComboContexts.BranchAndFilter(branch=self.branch,
                                                      configurationName="",
                                                      projectName=g))
                    for g in sorted(
                        set([
                            t.testDefinitionSummary.project for commit in
                            self.testManager.commitsToDisplayForBranch(
                                self.branch, self.maxCommitCount())
                            for t in self.testManager.allTestsForCommit(commit)
                        ]))
                ]

        else:
            return []