EXSWHTEC-223 - Update Coverage tool (#339)

- Apply clang-format on Coverage tool and add blue color for deprecated Modules
- Change color from blue to gray for deprecated modules
- Adjust the color of green
Tá an tiomantas seo le fáil i:
milos-mozetic
2023-07-11 10:40:40 +02:00
tiomanta ag GitHub
tuismitheoir bf50c2d2d8
tiomantas 0c7fa43b5e
D'athraigh 12 comhad le 1335 breiseanna agus 261 scriosta
+82 -49
Féach ar an gComhad
@@ -22,11 +22,20 @@ THE SOFTWARE.
#include "hipAPI.h"
FileOccurrence::FileOccurrence(std::string file_name, int line_number):
file_name{file_name}, line_number{line_number} {}
FileOccurrence::FileOccurrence(std::string file_name, int line_number)
: file_name{file_name}, line_number{line_number} {}
TestCaseOccurrence::TestCaseOccurrence(std::string test_case_name, std::string file_name, int line_number):
FileOccurrence{file_name, line_number}, test_case_name{test_case_name} {}
TestCaseOccurrence::TestCaseOccurrence(std::string test_case_name, std::string file_name,
int line_number)
: FileOccurrence{file_name, line_number}, test_case_name{test_case_name} {}
bool operator==(const TestCaseOccurrence& l_test, const TestCaseOccurrence& r_test) {
return l_test.test_case_name == r_test.test_case_name;
}
bool operator<(const TestCaseOccurrence& l_test, const TestCaseOccurrence& r_test) {
return l_test.test_case_name < r_test.test_case_name;
}
bool operator==(const HipAPI& l_hip_api, const HipAPI& r_hip_api) {
return l_hip_api.api_name == r_hip_api.api_name;
@@ -36,54 +45,53 @@ bool operator<(const HipAPI& l_hip_api, const HipAPI& r_hip_api) {
return l_hip_api.api_name < r_hip_api.api_name;
}
HipAPI::HipAPI(std::string api_name, bool deprecated_flag, std::string api_group_name):
api_name{api_name}, deprecated{deprecated_flag}, api_group_name{api_group_name} {}
std::string HipAPI::getName() const {
return api_name;
HipAPI::HipAPI(std::string api_name, bool deprecated_flag, std::string api_group_name,
std::string file_restriction)
: api_name{api_name},
deprecated{deprecated_flag},
api_group_name{api_group_name},
file_restriction{file_restriction} {
test_cases.clear();
}
std::string HipAPI::getGroupName() const {
return api_group_name;
}
std::string HipAPI::getName() const { return api_name; }
int HipAPI::getNumberOfCalls() const {
return file_occurrences.size();
}
std::string HipAPI::getGroupName() const { return api_group_name; }
int HipAPI::getNumberOfTestCases() const {
return test_cases.size();
}
int HipAPI::getNumberOfCalls() const { return file_occurrences.size(); }
std::vector<TestCaseOccurrence> HipAPI::getTestCases() const { return test_cases; }
void HipAPI::addFileOccurrence(FileOccurrence file_occurrence) {
file_occurrences.push_back(file_occurrence);
}
void HipAPI::addTestCase(TestCaseOccurrence test_case) {
test_cases.push_back(test_case);
if (std::find(test_cases.begin(), test_cases.end(), test_case) == test_cases.end()) {
test_cases.push_back(test_case);
}
}
bool HipAPI::isDeprecated() const
{
return deprecated;
}
bool HipAPI::isDeprecated() const { return deprecated; }
std::string HipAPI::getBasicStatsXML() const
{
std::string HipAPI::getBasicStatsXML() const {
std::stringstream xml_node;
xml_node << "\t\t<HIP-API>\n";
if (!deprecated) {
xml_node << "\t\t\t<NAME>" << api_name << "</NAME>\n";
} else {
xml_node << "\t\t\t<NAME>" << "[DEPRECATED] " << api_name << "</NAME>\n";
xml_node << "\t\t\t<NAME>"
<< "[DEPRECATED] " << api_name << "</NAME>\n";
}
if (!file_occurrences.empty()) {
xml_node << "\t\t\t<NUMBER-OF-API-CALLS>" << file_occurrences.size() << "</NUMBER-OF-API-CALLS>\n";
xml_node << "\t\t\t<NUMBER-OF-API-CALLS>" << file_occurrences.size()
<< "</NUMBER-OF-API-CALLS>\n";
xml_node << "\t\t\t<FILE-OCCURRENCES>\n";
for (auto const& file_occurrence: file_occurrences) {
xml_node << "\t\t\t\t<FILE-OCCURRENCE>" << file_occurrence.file_name << ":" << file_occurrence.line_number << "</FILE-OCCURRENCE>\n";
for (auto const& file_occurrence : file_occurrences) {
xml_node << "\t\t\t\t<FILE-OCCURRENCE>" << file_occurrence.file_name << ":"
<< file_occurrence.line_number << "</FILE-OCCURRENCE>\n";
}
xml_node << "\t\t\t</FILE-OCCURRENCES>\n";
}
@@ -102,13 +110,20 @@ std::string HipAPI::createHTMLReport() const {
std::string six_tabs{"\n\t\t\t\t\t\t"};
html_report << "<html lang=\"en\">";
html_report << "<head>" << one_tab << "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
html_report << one_tab << "<title>" << api_name << " Coverage report</title>" << one_tab << "<link rel=\"stylesheet\" type=\"text/css\" href=\"../resources/coverage.css\">" << one_tab<< "</head>";
html_report << one_tab << "<body>" << one_tab << "<table width=\"100%\" border=0 cellspacing=0 cellpadding=0>";
html_report << "<head>" << one_tab
<< "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">";
html_report << one_tab << "<title>" << api_name << " Coverage report</title>" << one_tab
<< "<link rel=\"stylesheet\" type=\"text/css\" href=\"../resources/coverage.css\">"
<< one_tab << "</head>";
html_report << one_tab << "<body>" << one_tab
<< "<table width=\"100%\" border=0 cellspacing=0 cellpadding=0>";
html_report << two_tabs << "<tr><td class=\"title\">" << api_name << " Coverage report</td></tr>";
html_report << two_tabs << "<tr><td class=\"ruler\"><img src=\"../resources/glass.png\" width=3 height=3></td></tr>\n";
html_report << two_tabs << "<tr>" << three_tabs << "<td width=\"100%\">" << four_tabs << "<table cellpading=1 border=0 width=\"100%\"";
html_report << two_tabs
<< "<tr><td class=\"ruler\"><img src=\"../resources/glass.png\" width=3 "
"height=3></td></tr>\n";
html_report << two_tabs << "<tr>" << three_tabs << "<td width=\"100%\">" << four_tabs
<< "<table cellpading=1 border=0 width=\"100%\"";
html_report << five_tabs << "<tr>";
html_report << six_tabs << "<td width=\"70%\"</td>";
html_report << six_tabs << "<td width=\"10%\"></td>";
@@ -124,7 +139,8 @@ std::string HipAPI::createHTMLReport() const {
html_report << five_tabs << "<tr>";
html_report << six_tabs << "<td class=\"headerItem\">Calls within test source files:</td>";
html_report << six_tabs << "<td class=\"headerCovTableEntry\">" << file_occurrences.size() << "</td>";
html_report << six_tabs << "<td class=\"headerCovTableEntry\">" << file_occurrences.size()
<< "</td>";
html_report << six_tabs << "<td></td>";
html_report << six_tabs << "<td></td>";
html_report << five_tabs << "</tr>";
@@ -135,13 +151,16 @@ std::string HipAPI::createHTMLReport() const {
html_report << six_tabs << "<td></td>";
html_report << six_tabs << "<td></td>";
html_report << five_tabs << "</tr>";
html_report << five_tabs << "<tr><td><img src=\"../resources/glass.png\" width=3 height=3></td></tr>";
html_report << five_tabs
<< "<tr><td><img src=\"../resources/glass.png\" width=3 height=3></td></tr>";
html_report << four_tabs << "</table>";
html_report << three_tabs << "</td>";
html_report << two_tabs << "</tr>";
html_report << two_tabs << "<tr><td class=\"ruler\"><img src=\"../resources/glass.png\" width=3 height=3></td></tr>\n";
html_report << two_tabs
<< "<tr><td class=\"ruler\"><img src=\"../resources/glass.png\" width=3 "
"height=3></td></tr>\n";
html_report << one_tab << "</table>";
html_report << one_tab << "<center>";
@@ -160,23 +179,29 @@ std::string HipAPI::createHTMLReport() const {
html_report << three_tabs << "<td class=\"tableHead\">Line number</td>";
html_report << two_tabs << "</tr>";
for (auto const& test_case: test_cases) {
for (auto const& test_case : test_cases) {
html_report << two_tabs << "<tr>";
html_report << three_tabs << "<td class=\"coverFile\">" << test_case.test_case_name << "</td>";
html_report << three_tabs << "<td class=\"coverFile\">" << test_case.test_case_name
<< "</td>";
html_report << three_tabs << "<td class=\"coverFile\">" << test_case.file_name << "</td>";
html_report << three_tabs << "<td class=\"headerCovTableEntry\">" << test_case.line_number << "</td>";
html_report << three_tabs << "<td class=\"headerCovTableEntry\">" << test_case.line_number
<< "</td>";
html_report << two_tabs << "</tr>";
}
} else {
html_report << two_tabs << "<tr>";
html_report << three_tabs << "<td class=\"headerItem\" style=\"text-align:center\"><br>There are no test cases detected within doxygen comments.</td>";
html_report << three_tabs
<< "<td class=\"headerItem\" style=\"text-align:center\"><br>There are no test "
"cases detected within doxygen comments.</td>";
html_report << two_tabs << "</tr>";
}
html_report << one_tab << "</table>";
html_report << one_tab << "<br>";
html_report << one_tab << "<table width=\"100%\" border=0 cellspacing=0 cellpadding=0>";
html_report << two_tabs << "<tr><td class=\"ruler\"><img src=\"../resources/glass.png\" width=3 height=3></td></tr>";
html_report
<< two_tabs
<< "<tr><td class=\"ruler\"><img src=\"../resources/glass.png\" width=3 height=3></td></tr>";
html_report << one_tab << "</table>";
// Add info about API occurrences in the test files.
@@ -192,15 +217,19 @@ std::string HipAPI::createHTMLReport() const {
html_report << three_tabs << "<td class=\"tableHead\">Line number</td>";
html_report << two_tabs << "</tr>";
for (auto const& file_occurrence: file_occurrences) {
for (auto const& file_occurrence : file_occurrences) {
html_report << two_tabs << "<tr>";
html_report << three_tabs << "<td class=\"coverFile\">" << file_occurrence.file_name << "</td>";
html_report << three_tabs << "<td class=\"headerCovTableEntry\">" << file_occurrence.line_number << "</td>";
html_report << three_tabs << "<td class=\"coverFile\">" << file_occurrence.file_name
<< "</td>";
html_report << three_tabs << "<td class=\"headerCovTableEntry\">"
<< file_occurrence.line_number << "</td>";
html_report << two_tabs << "</tr>";
}
} else {
html_report << two_tabs << "<tr>";
html_report << three_tabs << "<td class=\"headerItem\" style=\"text-align:center\"><br>There are no occurrences within test source files.</td>";
html_report << three_tabs
<< "<td class=\"headerItem\" style=\"text-align:center\"><br>There are no "
"occurrences within test source files.</td>";
html_report << two_tabs << "</tr>";
}
html_report << one_tab << "</table>";
@@ -208,7 +237,9 @@ std::string HipAPI::createHTMLReport() const {
html_report << one_tab << "<br>";
html_report << one_tab << "<table width=\"100%\" border=0 cellspacing=0 cellpadding=0>";
html_report << two_tabs << "<tr><td class=\"ruler\"><img src=\"../resources/glass.png\" width=3 height=3></td></tr>";
html_report
<< two_tabs
<< "<tr><td class=\"ruler\"><img src=\"../resources/glass.png\" width=3 height=3></td></tr>";
time_t now{time(nullptr)};
std::string date{asctime(gmtime(&now))};
@@ -220,3 +251,5 @@ std::string HipAPI::createHTMLReport() const {
return html_report.str();
}
std::string HipAPI::getFileRestriction() const { return file_restriction; }