Skip to content

Commit

Permalink
fix HTML tests
Browse files Browse the repository at this point in the history
The HTML tests are naturally rather fragile, since lots of CSS is copied
into every file. However, they are quite valuable as they exercise
important code paths. For example, this would have found issues gcovr#163
or gcovr#168. By enabling these tests, we can avoid such problems in the
future.

Summary of changes:

**`scripts/gcovr`:**
removed some trailing whitespace in the HTML template.

**`gcovr/tests/test_gcovr.py`:**
normalize HTML files so that they can be compared. In particular, we
remove the exact version string, and the report creation date.

**`gcovr/tests/*/reference/coverage.html`:**
update the HTML files to match the current structure. This is mostly
removing trailing whitespace, and tracking changes to the CSS. If there
was some discrepancy in the content, the TXT and XML references were
assumed to be up to date and fresh values taken from there.

**`gcovr/tests/linked/reference/coverage.html`:**
update as with the other tests. However, this exposed significant
changes to the path name handling. Commit 1cc987a changed
`commonprefix()` to `commonpath()` to figure out better path names. This
function is used only by the HTML test, which therefore reports physical
paths. The HTML reference has been updated to use physical paths. E.g.
since the test case is constructed on the fly from the “nested” test,
the source root dir is `../nested/subdir`. Note that the XML and TXT
reports still use symlinks in paths, but that is another problem.
  • Loading branch information
latk committed Jan 9, 2018
1 parent 32245a6 commit 73e4743
Show file tree
Hide file tree
Showing 18 changed files with 691 additions and 227 deletions.
82 changes: 69 additions & 13 deletions gcovr/tests/bad++char/reference/coverage.html
Expand Up @@ -2,7 +2,7 @@
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Head</title>
<style media="screen" type="text/css">

Expand All @@ -28,7 +28,7 @@
color: navy;
text-decoration: underline;
}

/*** TD formats ***/
td
{
Expand All @@ -41,7 +41,7 @@
font-size: 20pt;
font-weight: bold;
}

/* TD Header Information */
td.headerName
{
Expand Down Expand Up @@ -79,7 +79,7 @@
padding-right: 10px;
padding-top: 2px;
}

/* Color of horizontal ruler */
td.hr
{
Expand All @@ -94,7 +94,7 @@
font-family: sans-serif;
}

/* Coverage Table */
/* Coverage Table */

td.coverTableHead
{
Expand All @@ -111,7 +111,7 @@
{
text-align: left;
padding-left: 10px;
padding-right: 20px;
padding-right: 20px;
color: black;
background-color: LightBlue;
font-family: monospace;
Expand All @@ -138,7 +138,7 @@
white-space: nowrap;
font-weight: bold;
}

/* Link Details */
a.detail:link
{
Expand All @@ -155,7 +155,7 @@
color: #FFFFFF;
font-size:80%;
}

.graphcont{
color:#000;
font-weight:700;
Expand Down Expand Up @@ -185,7 +185,63 @@
.graph .bar span{
position:absolute;
left:1em
}
}

td.coveredLine,
span.coveredLine
{
background-color: LightGreen!important;
}

td.uncoveredLine,
span.uncoveredLine
{
background-color: LightPink!important;
}

.linebranch, .linecount
{
border-right: 1px gray solid;
background-color: lightgray;
}

span.takenBranch
{
color: Green!important;
cursor: help;
}

span.notTakenBranch
{
color: Red!important;
cursor: help;
}

.src
{
padding-left: 12px;
}

.srcHeader,
span.takenBranch,
span.notTakenBranch
{
font-family: monospace;
font-weight: bold;
}

pre
{
height : 15px;
margin-top: 0;
margin-bottom: 0;
}

.lineno
{
background-color: #EFE383;
border-right: 1px solid #BBB15F;
}

</style>
</head>
Expand All @@ -210,7 +266,7 @@
</tr>
<tr>
<td class="headerName">Date:</td>
<td class="headerValue">2013-07-02</td>
<td class="headerValue">0000-00-00</td>
<td></td>
<td class="headerName">Lines:</td>
<td class="headerTableEntry">7</td>
Expand Down Expand Up @@ -238,7 +294,7 @@
</table>

<center>
<table width="80%" cellpadding=1 cellspacing=1 boder=0>
<table width="80%" cellpadding=1 cellspacing=1 border=0>
<tr>
<td width="44%"><br></td>
<td width="8%"></td>
Expand All @@ -255,7 +311,7 @@


<tr>
<td class="coverFile" >main.cpp</td>
<td class="coverFile" ><a href="coverage.main.cpp.html">main.cpp</a></td>
<td class="coverBar" align="center" >
<table border=0 cellspacing=0 cellpadding=1><tr><td class="coverBarOutline">
<div class="graph"><strong class="bar" style="width:87.5%; background-color:yellow"></strong></div>
Expand All @@ -281,7 +337,7 @@

<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="hr"><td></tr>
<tr><td class="footer">Generated by: <a href="http://gcovr.com">GCOVR (Version 2.5-prerelease (r2871))</a></td></tr>
<tr><td class="footer">Generated by: <a href="http://gcovr.com">GCOVR (Version 3.x)</a></td></tr>
</table>
<br>

Expand Down
44 changes: 29 additions & 15 deletions gcovr/tests/cmake_oos/reference/coverage.html
Expand Up @@ -28,7 +28,7 @@
color: navy;
text-decoration: underline;
}

/*** TD formats ***/
td
{
Expand All @@ -41,7 +41,7 @@
font-size: 20pt;
font-weight: bold;
}

/* TD Header Information */
td.headerName
{
Expand Down Expand Up @@ -79,7 +79,7 @@
padding-right: 10px;
padding-top: 2px;
}

/* Color of horizontal ruler */
td.hr
{
Expand All @@ -94,7 +94,7 @@
font-family: sans-serif;
}

/* Coverage Table */
/* Coverage Table */

td.coverTableHead
{
Expand All @@ -111,7 +111,7 @@
{
text-align: left;
padding-left: 10px;
padding-right: 20px;
padding-right: 20px;
color: black;
background-color: LightBlue;
font-family: monospace;
Expand All @@ -138,7 +138,7 @@
white-space: nowrap;
font-weight: bold;
}

/* Link Details */
a.detail:link
{
Expand All @@ -155,7 +155,7 @@
color: #FFFFFF;
font-size:80%;
}

.graphcont{
color:#000;
font-weight:700;
Expand Down Expand Up @@ -185,7 +185,7 @@
.graph .bar span{
position:absolute;
left:1em
}
}

td.coveredLine,
span.coveredLine
Expand All @@ -199,24 +199,38 @@
background-color: LightPink!important;
}

.linecount
.linebranch, .linecount
{
border-right: 1px gray solid;
background-color: lightgray;
}

.src
span.takenBranch
{
color: Green!important;
cursor: help;
}

span.notTakenBranch
{
color: Red!important;
cursor: help;
}

.src
{
padding-left: 12px;
}

.srcHeader
.srcHeader,
span.takenBranch,
span.notTakenBranch
{
font-family: monospace;
font-family: monospace;
font-weight: bold;
}

pre
pre
{
height : 15px;
margin-top: 0;
Expand Down Expand Up @@ -252,7 +266,7 @@
</tr>
<tr>
<td class="headerName">Date:</td>
<td class="headerValue">2014-07-03</td>
<td class="headerValue">0000-00-00</td>
<td></td>
<td class="headerName">Lines:</td>
<td class="headerTableEntry">7</td>
Expand Down Expand Up @@ -323,7 +337,7 @@

<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="hr"><td></tr>
<tr><td class="footer">Generated by: <a href="http://gcovr.com">GCOVR (Version 3.2-prerelease)</a></td></tr>
<tr><td class="footer">Generated by: <a href="http://gcovr.com">GCOVR (Version 3.x)</a></td></tr>
</table>
<br>

Expand Down

0 comments on commit 73e4743

Please sign in to comment.