Code Coverage blog post by Marco (#51)

This commit is contained in:
Pascal Chevrel 2018-03-23 12:19:42 +01:00 коммит произвёл GitHub
Родитель 8d6c626feb
Коммит f34cd0391f
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 125 добавлений и 20 удалений

Просмотреть файл

@ -43,24 +43,29 @@ github: {
}
authors:
janx:
display_name: Jan Keromnes
gravatar: 84ed8c95500cb33a9a53038bb9e8af0e
web: http://jan.tools/
twitter: jankeromnes
github: jankeromnes
pascal:
display_name: Pascal Chevrel
gravatar: 5293fe8fb106a442d842757758d07c56
web: https://chevrel.org/
twitter: pascalchevrel
github: pascalchevrel
calixte:
display_name: Calixte Denizet
gravatar: 1c26d49ffb62a4106644da39c7e6fb4c
web: https://mozillians.org/fr/u/cdenizet/
twitter: calixteman
github: calixteman
janx:
display_name: Jan Keromnes
gravatar: 84ed8c95500cb33a9a53038bb9e8af0e
web: http://jan.tools/
twitter: jankeromnes
github: jankeromnes
marco:
display_name: Marco Castelluccio
gravatar: 16d4d4a441724e006b342ac12507caef
web: https://marco-c.github.io/
github: marco-c
pascal:
display_name: Pascal Chevrel
gravatar: 5293fe8fb106a442d842757758d07c56
web: https://chevrel.org/
twitter: pascalchevrel
github: pascalchevrel
paginate: 12
excerpt_separator: "<!-- more -->"

Просмотреть файл

@ -67,7 +67,11 @@
<header id="masthead" class="section">
<div class="site-id">
<div class="site-title-wrap content">
{% if page.home%}
<h1 id="site-title"><span>{{ site.title }}</span></h1>
{% else %}
<a href="/"><h1 id="site-title"><span>{{ site.title }}</span></h1></a>
{% endif %}
<p id="site-description"><span>{{ site.description }}</span></p>
</div>
</div>

Просмотреть файл

@ -4,6 +4,7 @@ bodyclasses: "post-template-default single single-post single-format-standard co
---
{{ page.bodyclasses }}
{% assign author = site.authors[page.author] %}
<div class="content">
<article class="post type-post format-standard hentry">
@ -12,10 +13,15 @@ bodyclasses: "post-template-default single single-post single-format-standard co
<h1 class="entry-title">{{ page.title }}</h1>
<div class="entry-info">
{% if author.gravatar != null %}
<a href="{{ author.web }}" class="author-photo" alt="{{ author.display_name }}"><img src="https://www.gravatar.com/avatar/{{ author.gravatar }}?s=128"></a>
{% endif %}
<address class="vcard">
{% if author != null %}
<a href="{{ site.authors[post.author].web }}" rel="author">{{ author.display_name }}</a>
{% endif %}
{% endif %}
</address>
<time class="date">{{ page.date | date_to_string }}</time>
</div>

Просмотреть файл

@ -0,0 +1,40 @@
---
layout: post
title: "Zero coverage report"
date: 2018-03-23 07:00:00
categories: tooling codecoverage
author: marco
---
One of the nice things we can do with code coverage data is looking at which files are completely not covered by any test.
<aside>This article was initially published on Marco Casteluccio's <a href="https://marco-c.github.io/">blog</a>.</aside>
These files might be interesting for two reasons. Either they are:
<ol style="list-style-type:lower-alpha; list-style-position: inside;">
<li>dead code;</li>
<li>code that is not tested at all.</li>
</ol>
Dead code can obviously be removed, bringing a lot of advantages for developers and users alike:
* Improve maintainability (no need to update the code in case of refactorings in the case of dead code);
* Reduce build time for developers and CI;
* Reduce the attack surface;
* Decrease the size of the resulting binary which can have effects on performance, installation duration, etc.
Untested code, instead, can be really problematic. Changes to this code can take more time to be verified, require more QA resources, and so on. In summary, we cant trust them as we trust code that is properly tested.
A study from [Google Test Automation Conference 2016](https://www.youtube.com/watch?v=NKEptA3KP08) showed that an uncovered line (or method) is twice as likely to have a bug fix than a covered line (or method).
On top of that, testing a feature prevents unexpected behavior changes.
Using these reports, we have managed to [remove a good amount of code](https://bugzilla.mozilla.org/show_bug.cgi?id=1415819) from mozilla-central, so far around 60 files with thousands of lines of code. Wearm confident that theres even more code that we could remove or conditionally compile only if needed.
As any modern software, Firefox relies a lot on third party libraries. Currently, most (all?) the content of these libraries is built by default. For example,~400 files are untested in the gfx/skia/ directory).
Reports (updated weekly) can be seen at [https://marco-c.github.io/code-coverage-reports/](https://marco-c.github.io/code-coverage-reports/).
It allows filtering by language (C/C++, JavaScript), filtering out third-party code or header files, showing completely uncovered files only or all files which have uncovered functions (sorted by number of uncovered functions).
![uncovered code](/images/posts/codecoverage/uncovered_files.png "Uncovered Files"){: .center-image }
Currently there are 2730 uncovered files (2627 C++, 103 JavaScript), 557 if ignoring third party files. As our regular code coverage reports on [codecov.io](https://codecov.io/gh/marco-c/gecko-dev), these reports are restricted to Windows and Linux platforms.

Двоичные данные
images/posts/codecoverage/uncovered_files.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 150 KiB

Просмотреть файл

@ -161,19 +161,69 @@ Version: 1.0
#social-tabs-comments {
width: 980px;
}
}html { margin-top: 32px !important; }
* html body { margin-top: 32px !important; }
}
html {
margin-top: 32px !important;
}
* html body {
margin-top: 32px !important;
}
@media screen and ( max-width: 782px ) {
html { margin-top: 46px !important; }
* html body { margin-top: 46px !important; }
}
/* RM blog additons */
/* RM blog additions */
@media screen and (min-width: 480px) {
#site-description {
line-height: initial;
#site-description {
line-height: initial;
}
#masthead {
background-image: url('/themes/frontierline-rm/img/fox-tail.png');
}
#masthead {
background-image: url('/themes/frontierline-rm/img/fox-tail.png');
}
/* Author picture styling */
.entry-info .author-photo {
float: right;
box-shadow: 0 4px 6px rgba(0,0,0,.3);
border: 1px solid lightgray;
margin: -1em 0 0em 1em;
padding: 10px 10px 1em 10px;
text-align: center;
text-decoration: none;
color: black;
display: flex;
flex-direction: column;
transform: rotate(5deg);
font-weight: bold;
font-family: cursive;
font-style: italic;
border-radius: 2px;
}
.entry-info .author-photo::after {
content: attr(alt);
}
.entry-info .author-photo img {
border: 1px solid darkgray;
margin-bottom: 1.5em;
}
/* end of author picture styling */
/* Aside element in blog post */
.entry-content aside {
float: left;
width: 200px;
margin: 0.5em 1em 0 0;
padding: 0.5em;
color: #fff;
background: #000;
font-style: italic;
text-align: center;
}