Beispiel #1
0
    def artifactsForTestRunGrid(self):
        testRun = self.testRun

        grid = [["Artifact", "Size"]]

        if testRun.test.testDefinitionSummary.type == "Build":
            for artifact in testRun.test.testDefinitionSummary.artifacts:
                full_name = testRun.test.testDefinitionSummary.name + ("/" + artifact if artifact else "")

                build_key = self.renderer.artifactStorage.sanitizeName(full_name) + ".tar.gz"

                if self.renderer.artifactStorage.build_exists(testRun.test.hash, build_key):
                    grid.append([
                        HtmlGeneration.link(full_name + ".tar.gz", self.renderer.buildDownloadUrl(testRun.test.hash, build_key)),
                        HtmlGeneration.bytesToHumanSize(self.renderer.artifactStorage.build_size(testRun.test.hash, build_key))
                        ])

        for artifactName, sizeInBytes in self.renderer.artifactStorage.testResultKeysForWithSizes(testRun.test.hash, testRun._identity):
            name = self.renderer.artifactStorage.unsanitizeName(artifactName)
            
            if not name.startswith(ArtifactStorage.TEST_LOG_NAME_PREFIX):
                grid.append([
                    HtmlGeneration.link(
                        name,
                        self.renderer.testResultDownloadUrl(testRun._identity, artifactName)
                        ),
                    HtmlGeneration.bytesToHumanSize(sizeInBytes)
                    ])

        if not grid:
            return card("No Test Artifacts produced")

        return HtmlGeneration.grid(grid)
Beispiel #2
0
    def renderLink(self,
                   includeRepo=True,
                   includeBranch=True,
                   textOverride=None):
        res = ""
        if includeRepo:
            assert includeBranch
            res += self.contextFor(self.repo).renderLink()

        if includeBranch and not self.branch:
            name = self.commit.hash[:10]
        else:
            if includeBranch:
                if res:
                    res += "/"
                res += self.contextFor(
                    self.branch).renderLink(includeRepo=False)

            name = self.nameInBranch

            if not includeRepo and not includeBranch:
                name = "HEAD" + name
            elif not name:
                name = "/HEAD"
            else:
                if len(name) < 5:
                    name += "&nbsp;" * max(0, 5 - len(name))

        hover_text = cgi.escape(
            self.commit.data.commitMessage) if self.commit.data else None

        return (res if not textOverride else "") + HtmlGeneration.link(
            textOverride or name, self.urlString(), hover_text=hover_text)
Beispiel #3
0
    def renderLink(self, includeCommit=True, includeTest=True):
        res = ""

        if includeCommit:
            res = self.contextFor(self.commit).renderLink()
        
        if includeTest:
            if res:
                res = res + "/"

            res = res + HtmlGeneration.link(self.test.testDefinitionSummary.name, self.contextFor(self.test).urlString())

        if res:
            res = res + "/"

        return res + HtmlGeneration.link(self.testRun._identity[:8], self.urlString())
Beispiel #4
0
    def renderLink(self, includeCommit=True, nameOverride=None):
        if includeCommit:
            res = self.contextFor(self.commit).renderLink()
        else:
            res = ''

        return res + HtmlGeneration.link(nameOverride or self.testName, self.urlString())
Beispiel #5
0
    def renderLinkWithShaHash(self, noIcon=False):
        if not self.commit.data:
            return ''

        return (octicon("git-commit")
                if not noIcon else "") + HtmlGeneration.link(
                    "<code>" + self.commit.hash[:8] + "</code>",
                    self.urlString(),
                    hover_text=("commit " + self.commit.hash[:10] + " : " +
                                ("" if not self.commit.data else
                                 self.commit.data.commitMessage)))
Beispiel #6
0
 def branchesLink(self, reponame, text=None):
     return HtmlGeneration.link(text or reponame, self.branchesUrl(reponame))
Beispiel #7
0
 def testRunLink(self, testRun, text_override=None):
     return HtmlGeneration.link(text_override or str(testRun._identity)[:8], "/test?testId=" + testRun._identity)
Beispiel #8
0
 def sourceLinkForCommit(self, commit):
     url = self.src_ctrl.commit_url(commit.repo.name, commit.hash)
     if url:
         return HtmlGeneration.link(commit.hash[:7], url)
     else:
         return HtmlGeneration.lightGrey(commit.hash[:7])
Beispiel #9
0
 def renderLinkToSCM(self):
     url = self.renderer.src_ctrl.commit_url(self.commit.repo.name,
                                             self.commit.hash)
     return HtmlGeneration.link(octicon("diff"),
                                url,
                                hover_text="View diff")
Beispiel #10
0
 def renderLink(self):
     return HtmlGeneration.link(self.displayName, self.urlString())
Beispiel #11
0
 def renderLink(self):
     return HtmlGeneration.link("Deployments", self.urlString())
Beispiel #12
0
 def renderLink(self, includeRepo=True):
     return HtmlGeneration.link(self.appropriateLinkName(),
                                self.urlString())
Beispiel #13
0
 def renderLink(self):
     return HtmlGeneration.link("Images", self.urlString())
    def renderPageBody(self):
        if self.options.get("context", "") == "dropdown-menu":
            items = []
            for testRun in self.relevantTestRuns():
                for path, sz in self.renderer.artifactStorage.testResultKeysAndSizesForIndividualTest(
                        testRun.test.hash, testRun._identity,
                        self.individualTestName):
                    contents = os.path.basename(
                        path) + " (" + HtmlGeneration.bytesToHumanSize(
                            sz) + ")"
                    if sz:
                        items.append(
                            '<a class="dropdown-item" href="{link}" title="{title}">{contents}</a>'
                            .format(link=self.renderer.testResultDownloadUrl(
                                testRun._identity, path),
                                    title=os.path.basename(path),
                                    contents=contents))
                    else:
                        items.append(
                            '<span class="dropdown-item disabled text-muted">{contents}</span>'
                            .format(contents=contents))
            return "".join(items)
        else:
            grid = [["Test Run", "Failure", "File", "Size"]]

            for testRun in [
                    t for t in self.relevantTestRuns()
                    if not t.canceled and t.endTimestamp
            ]:
                try:
                    index = testRun.testNames.test_names.index(
                        self.individualTestName)
                    passFail = True if testRun.testFailures[index] else False
                except:
                    passFail = None

                if passFail is not None:
                    pathsAndSizes = self.renderer.artifactStorage.testResultKeysAndSizesForIndividualTest(
                        testRun.test.hash, testRun._identity,
                        self.individualTestName)

                    for path, sz in pathsAndSizes:
                        grid.append([
                            self.contextFor(testRun).renderLink(False, False),
                            "OK" if passFail is True else
                            "FAIL" if passFail is False else "",
                            HtmlGeneration.link(
                                os.path.basename(path),
                                self.renderer.testResultDownloadUrl(
                                    testRun._identity, path)),
                            HtmlGeneration.bytesToHumanSize(sz)
                        ])

                    if not pathsAndSizes:
                        grid.append([
                            self.contextFor(testRun).renderLink(False, False),
                            "FAIL" if passFail is True else
                            "OK" if passFail is False else "",
                            '<span class="text-muted">%s</span>' %
                            "No artifacts", ""
                        ])

            return HtmlGeneration.grid(grid, dataTables=True)
 def renderLink(self):
     return HtmlGeneration.link(self.individualTestName, self.urlString())