blob: 9e9b742bdfa3cf6984d211e350fd3f722025e98a [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CTEST_COVERAGE_COMMAND &mdash; CMake 3.8.2 Documentation</title>
<link rel="stylesheet" href="../_static/cmake.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '3.8.2',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="shortcut icon" href="../_static/cmake-favicon.ico"/>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="CTEST_COVERAGE_EXTRA_FLAGS" href="CTEST_COVERAGE_EXTRA_FLAGS.html" />
<link rel="prev" title="CTEST_CONFIGURE_COMMAND" href="CTEST_CONFIGURE_COMMAND.html" />
</head>
<body role="document">
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="CTEST_COVERAGE_EXTRA_FLAGS.html" title="CTEST_COVERAGE_EXTRA_FLAGS"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="CTEST_CONFIGURE_COMMAND.html" title="CTEST_CONFIGURE_COMMAND"
accesskey="P">previous</a> |</li>
<li>
<img src="../_static/cmake-logo-16.png" alt=""
style="vertical-align: middle; margin-top: -2px" />
</li>
<li>
<a href="https://cmake.org/">CMake</a> &#187;
</li>
<li>
<a href="../index.html">3.8.2 Documentation</a> &#187;
</li>
<li class="nav-item nav-item-1"><a href="../manual/cmake-variables.7.html" accesskey="U">cmake-variables(7)</a> &#187;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="ctest-coverage-command">
<span id="variable:CTEST_COVERAGE_COMMAND"></span><h1>CTEST_COVERAGE_COMMAND<a class="headerlink" href="#ctest-coverage-command" title="Permalink to this headline"></a></h1>
<p>Specify the CTest <code class="docutils literal"><span class="pre">CoverageCommand</span></code> setting
in a <span class="target" id="index-0-manual:ctest(1)"></span><a class="reference internal" href="../manual/ctest.1.html#manual:ctest(1)" title="ctest(1)"><code class="xref cmake cmake-manual docutils literal"><span class="pre">ctest(1)</span></code></a> dashboard client script.</p>
<div class="section" id="cobertura">
<h2>Cobertura<a class="headerlink" href="#cobertura" title="Permalink to this headline"></a></h2>
<p>Using <a class="reference external" href="http://cobertura.github.io/cobertura/">Cobertura</a> as the coverage generation within your multi-module
Java project can generate a series of XML files.</p>
<p>The Cobertura Coverage parser expects to read the coverage data from a
single XML file which contains the coverage data for all modules.
Cobertura has a program with the ability to merge given <code class="docutils literal"><span class="pre">cobertura.ser</span></code> files
and then another program to generate a combined XML file from the previous
merged file. For command line testing, this can be done by hand prior to
CTest looking for the coverage files. For script builds,
set the <code class="docutils literal"><span class="pre">CTEST_COVERAGE_COMMAND</span></code> variable to point to a file which will
perform these same steps, such as a <code class="docutils literal"><span class="pre">.sh</span></code> or <code class="docutils literal"><span class="pre">.bat</span></code> file.</p>
<div class="highlight-cmake"><div class="highlight"><pre><span></span><span class="nb">set</span><span class="p">(</span><span class="s">CTEST_COVERAGE_COMMAND</span> <span class="s">.../run-coverage-and-consolidate.sh</span><span class="p">)</span>
</pre></div>
</div>
<p>where the <code class="docutils literal"><span class="pre">run-coverage-and-consolidate.sh</span></code> script is perhaps created by
the <span class="target" id="index-0-command:configure_file"></span><a class="reference internal" href="../command/configure_file.html#command:configure_file" title="configure_file"><code class="xref cmake cmake-command docutils literal"><span class="pre">configure_file()</span></code></a> command and might contain the following code:</p>
<div class="highlight-bash"><div class="highlight"><pre><span></span><span class="ch">#!/usr/bin/env bash</span>
<span class="nv">CoberturaFiles</span><span class="o">=</span><span class="s2">&quot;</span><span class="k">$(</span>find <span class="s2">&quot;/path/to/source&quot;</span> -name <span class="s2">&quot;cobertura.ser&quot;</span><span class="k">)</span><span class="s2">&quot;</span>
<span class="nv">SourceDirs</span><span class="o">=</span><span class="s2">&quot;</span><span class="k">$(</span>find <span class="s2">&quot;/path/to/source&quot;</span> -name <span class="s2">&quot;java&quot;</span> -type d<span class="k">)</span><span class="s2">&quot;</span>
cobertura-merge --datafile coberturamerge.ser <span class="nv">$CoberturaFiles</span>
cobertura-report --datafile coberturamerge.ser --destination . <span class="se">\</span>
--format xml <span class="nv">$SourceDirs</span>
</pre></div>
</div>
<p>The script uses <code class="docutils literal"><span class="pre">find</span></code> to capture the paths to all of the <code class="docutils literal"><span class="pre">cobertura.ser</span></code>
files found below the project&#8217;s source directory. It keeps the list of files
and supplies it as an argument to the <code class="docutils literal"><span class="pre">cobertura-merge</span></code> program. The
<code class="docutils literal"><span class="pre">--datafile</span></code> argument signifies where the result of the merge will be kept.</p>
<p>The combined <code class="docutils literal"><span class="pre">coberturamerge.ser</span></code> file is then used to generate the XML report
using the <code class="docutils literal"><span class="pre">cobertura-report</span></code> program. The call to the cobertura-report
program requires some named arguments.</p>
<dl class="docutils">
<dt><code class="docutils literal"><span class="pre">--datafila</span></code></dt>
<dd>path to the merged <code class="docutils literal"><span class="pre">.ser</span></code> file</dd>
<dt><code class="docutils literal"><span class="pre">--destination</span></code></dt>
<dd>path to put the output files(s)</dd>
<dt><code class="docutils literal"><span class="pre">--format</span></code></dt>
<dd>file format to write output in: xml or html</dd>
</dl>
<p>The rest of the supplied arguments consist of the full paths to the
<code class="docutils literal"><span class="pre">/src/main/java</span></code> directories of each module within the source tree. These
directories are needed and should not be forgotten.</p>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">CTEST_COVERAGE_COMMAND</a><ul>
<li><a class="reference internal" href="#cobertura">Cobertura</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="CTEST_CONFIGURE_COMMAND.html"
title="previous chapter">CTEST_CONFIGURE_COMMAND</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="CTEST_COVERAGE_EXTRA_FLAGS.html"
title="next chapter">CTEST_COVERAGE_EXTRA_FLAGS</a></p>
<div role="note" aria-label="source link">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/variable/CTEST_COVERAGE_COMMAND.rst.txt"
rel="nofollow">Show Source</a></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<div><input type="text" name="q" /></div>
<div><input type="submit" value="Go" /></div>
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="CTEST_COVERAGE_EXTRA_FLAGS.html" title="CTEST_COVERAGE_EXTRA_FLAGS"
>next</a> |</li>
<li class="right" >
<a href="CTEST_CONFIGURE_COMMAND.html" title="CTEST_CONFIGURE_COMMAND"
>previous</a> |</li>
<li>
<img src="../_static/cmake-logo-16.png" alt=""
style="vertical-align: middle; margin-top: -2px" />
</li>
<li>
<a href="https://cmake.org/">CMake</a> &#187;
</li>
<li>
<a href="../index.html">3.8.2 Documentation</a> &#187;
</li>
<li class="nav-item nav-item-1"><a href="../manual/cmake-variables.7.html" >cmake-variables(7)</a> &#187;</li>
</ul>
</div>
<div class="footer" role="contentinfo">
&#169; Copyright 2000-2017 Kitware, Inc. and Contributors.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.5.2.
</div>
</body>
</html>