<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Test on FtBx.fr</title><link>https://ftbx.fr/tags/test/</link><description>Recent content in Test on FtBx.fr</description><image><title>FtBx.fr</title><url>https://ftbx.fr/images/placeholder-image.jpg</url><link>https://ftbx.fr/images/placeholder-image.jpg</link></image><generator>Hugo -- 0.146.6</generator><language>fr</language><copyright>2025 ftbx.fr - This work is licensed under CC BY-NC-SA 4.0</copyright><lastBuildDate>Mon, 08 Apr 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://ftbx.fr/tags/test/index.xml" rel="self" type="application/rss+xml"/><item><title>GitLab CI coverage regex : pourquoi ta regex ne matche jamais</title><link>https://ftbx.fr/posts/gitlab-ci-coverage-regex-pourquoi-ta-regex-ne-matche-jamais/</link><pubDate>Mon, 08 Apr 2024 00:00:00 +0000</pubDate><guid>https://ftbx.fr/posts/gitlab-ci-coverage-regex-pourquoi-ta-regex-ne-matche-jamais/</guid><description>&lt;p>GitLab peut extraire le pourcentage de couverture de tests depuis les
logs du job et l&amp;rsquo;afficher dans le badge du projet, les MR, et l&amp;rsquo;UI.
Il suffit de définir une regex dans &lt;code>coverage:&lt;/code>. Et c&amp;rsquo;est là que tout
le monde se plante.&lt;/p>
&lt;h3 id="la-regex-qui-foire-systématiquement">La regex qui foire systématiquement&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-yaml" data-lang="yaml">&lt;span class="line">&lt;span class="cl">&lt;span class="c"># ❌ Ne matchera JAMAIS&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="nt">job&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">script&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="l">pytest --cov&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="nt">coverage&lt;/span>&lt;span class="p">:&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;/TOTAL.*\s+(\d+%)$/&amp;#39;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Pourquoi ? &lt;code>$&lt;/code> veut dire &amp;ldquo;fin de ligne&amp;rdquo;. Mais les logs GitLab
sont collectés dans un buffer multi-lignes. La vraie fin de ligne
dans ce buffer, c&amp;rsquo;est la dernière ligne du log entier, pas la
ligne &lt;code>TOTAL&lt;/code>.&lt;/p></description></item></channel></rss>