[llvm-cov] - Included footer "Generated by llvm-cov -- llvm version <version number>" in the coverage report.

The llvm-cov version information will be useful to the user when comparing the code coverage across different versions of llvm-cov. This patch provides the llvm-cov version information in the generated coverage report.

Differential Revision: https://reviews.llvm.org/D24457

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281321 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Ying Yi 2016-09-13 11:28:31 +00:00
parent d0c0b622fc
commit 503f4620ba
4 changed files with 29 additions and 10 deletions

View File

@ -12,24 +12,27 @@ int main(int argc, char ** argv) {
}
// Test console output.
// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -instr-profile %t.profdata -filename-equivalence %s | FileCheck -check-prefixes=TEXT,TEXT-FILE,TEXT-HEADER %s
// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -instr-profile %t.profdata -project-title "Test Suite" -filename-equivalence %s | FileCheck -check-prefixes=TEXT-TITLE,TEXT,TEXT-FILE,TEXT-HEADER %s
// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -instr-profile %t.profdata -project-title "Test Suite" -name=main -filename-equivalence %s | FileCheck -check-prefixes=TEXT-FUNCTION,TEXT-HEADER %s
// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -instr-profile %t.profdata -filename-equivalence %s | FileCheck -check-prefixes=TEXT,TEXT-FILE,TEXT-HEADER,TEXT-FOOTER %s
// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -instr-profile %t.profdata -project-title "Test Suite" -filename-equivalence %s | FileCheck -check-prefixes=TEXT-TITLE,TEXT,TEXT-FILE,TEXT-HEADER,TEXT-FOOTER %s
// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -instr-profile %t.profdata -project-title "Test Suite" -name=main -filename-equivalence %s | FileCheck -check-prefixes=TEXT-FUNCTION,TEXT-HEADER,TEXT-FOOTER %s
// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -instr-profile=%t.profdata -o %t.dir -filename-equivalence %s
// RUN: FileCheck -check-prefixes=TEXT-FOOTER -input-file=%t.dir/index.txt %s
// TEXT-TITLE: Test Suite
// TEXT: Coverage Report
// TEXT: Created:
// TEXT-FILE: showProjectSummary.cpp:
// TEXT-FILE: showProjectSummary.covmapping:
// TEXT-FUNCTION: main:
// TEXT-FOOTER: Generated by llvm-cov
// Test html output.
// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -format=html -o %t.dir -instr-profile %t.profdata -filename-equivalence %s
// RUN: FileCheck -check-prefixes=HTML,HTML-FILE,HTML-HEADER -input-file %t.dir/coverage/tmp/showProjectSummary.cpp.html %s
// RUN: FileCheck -check-prefixes=HTML,HTML-FILE,HTML-HEADER,HTML-FOOTER -input-file %t.dir/coverage/tmp/showProjectSummary.cpp.html %s
// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -format=html -o %t.dir -instr-profile %t.profdata -project-title "Test Suite" -filename-equivalence %s
// RUN: FileCheck -check-prefixes=HTML-TITLE,HTML,HTML-FILE,HTML-HEADER -input-file %t.dir/coverage/tmp/showProjectSummary.cpp.html %s
// RUN: FileCheck -check-prefixes=HTML-TITLE,HTML -input-file %t.dir/index.html %s
// RUN: FileCheck -check-prefixes=HTML-TITLE,HTML,HTML-FILE,HTML-HEADER,HTML-FOOTER -input-file %t.dir/coverage/tmp/showProjectSummary.cpp.html %s
// RUN: FileCheck -check-prefixes=HTML-TITLE,HTML,HTML-FOOTER -input-file %t.dir/index.html %s
// RUN: llvm-cov show %S/Inputs/showProjectSummary.covmapping -format=html -o %t.dir -instr-profile %t.profdata -project-title "Test Suite" -filename-equivalence -name=main %s
// RUN: FileCheck -check-prefixes=HTML-FUNCTION,HTML-HEADER -input-file %t.dir/functions.html %s
// RUN: FileCheck -check-prefixes=HTML-FUNCTION,HTML-HEADER,HTML-FOOTER -input-file %t.dir/functions.html %s
// HTML-TITLE: <h1>Test Suite</h1>
// HTML: <h2>Coverage Report</h2>
// HTML: <h4>Created:{{.*}}</h4>
@ -38,3 +41,4 @@ int main(int argc, char ** argv) {
// HTML-HEADER: <td><pre>Line No.</pre></td>
// HTML-HEADER: <td><pre>Count</pre></td>
// HTML-HEADER: <td><pre>Source (<a href='#L8'>jump to first uncovered line</a>)</pre></td>
// HTML-FOOTER: <h5>Generated by llvm-cov{{.*}}</h5>

View File

@ -56,6 +56,13 @@ struct CoverageViewOptions {
/// \brief Check if the created time of the profile data file is available.
bool hasCreatedTime() const { return !CreatedTimeStr.empty(); }
/// \brief Get the LLVM version string.
std::string getLLVMVersionString() const {
std::string VersionString = "Generated by llvm-cov -- llvm version ";
VersionString += LLVM_VERSION_STRING;
return VersionString;
}
};
}

View File

@ -381,7 +381,8 @@ Error CoveragePrinterHTML::createIndexFile(
for (unsigned I = 0, E = FileReports.size(); I < E; ++I)
emitFileSummary(OSRef, SourceFiles[I], FileReports[I]);
emitFileSummary(OSRef, "Totals", Totals, /*IsTotals=*/true);
OSRef << EndTable << EndCenteredDiv;
OSRef << EndTable << EndCenteredDiv
<< tag("h5", escape(Opts.getLLVMVersionString(), Opts));
emitEpilog(OSRef);
return Error::success();
@ -392,7 +393,8 @@ void SourceCoverageViewHTML::renderViewHeader(raw_ostream &OS) {
}
void SourceCoverageViewHTML::renderViewFooter(raw_ostream &OS) {
OS << EndTable << EndCenteredDiv;
OS << EndTable << EndCenteredDiv
<< tag("h5", escape(getOptions().getLLVMVersionString(), getOptions()));
}
void SourceCoverageViewHTML::renderSourceName(raw_ostream &OS, bool WholeFile) {

View File

@ -40,6 +40,9 @@ Error CoveragePrinterText::createIndexFile(
CoverageReport Report(Opts, Coverage);
Report.renderFileReports(OSRef);
Opts.colored_ostream(OSRef, raw_ostream::CYAN) << "\n"
<< Opts.getLLVMVersionString();
return Error::success();
}
@ -64,7 +67,10 @@ unsigned getDividerWidth(const CoverageViewOptions &Opts) {
void SourceCoverageViewText::renderViewHeader(raw_ostream &) {}
void SourceCoverageViewText::renderViewFooter(raw_ostream &) {}
void SourceCoverageViewText::renderViewFooter(raw_ostream &OS) {
getOptions().colored_ostream(OS, raw_ostream::CYAN)
<< "\n" << getOptions().getLLVMVersionString();
}
void SourceCoverageViewText::renderSourceName(raw_ostream &OS, bool WholeFile) {
std::string ViewInfo = WholeFile ? getVerboseSourceName() : getSourceName();