CTEST_COVERAGE_COMMAND.rst 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. CTEST_COVERAGE_COMMAND
  2. ----------------------
  3. Specify the CTest ``CoverageCommand`` setting
  4. in a :manual:`ctest(1)` dashboard client script.
  5. Cobertura
  6. '''''''''
  7. Using `Cobertura`_ as the coverage generation within your multi-module
  8. Java project can generate a series of XML files.
  9. The Cobertura Coverage parser expects to read the coverage data from a
  10. single XML file which contains the coverage data for all modules.
  11. Cobertura has a program with the ability to merge given cobertura.ser files
  12. and then another program to generate a combined XML file from the previous
  13. merged file. For command line testing, this can be done by hand prior to
  14. CTest looking for the coverage files. For script builds,
  15. set the ``CTEST_COVERAGE_COMMAND`` variable to point to a file which will
  16. perform these same steps, such as a .sh or .bat file.
  17. .. code-block:: cmake
  18. set(CTEST_COVERAGE_COMMAND .../run-coverage-and-consolidate.sh)
  19. where the ``run-coverage-and-consolidate.sh`` script is perhaps created by
  20. the :command:`configure_file` command and might contain the following code:
  21. .. code-block:: bash
  22. #!/usr/bin/env bash
  23. CoberturaFiles="$(find "/path/to/source" -name "cobertura.ser")"
  24. SourceDirs="$(find "/path/to/source" -name "java" -type d)"
  25. cobertura-merge --datafile coberturamerge.ser $CoberturaFiles
  26. cobertura-report --datafile coberturamerge.ser --destination . \
  27. --format xml $SourceDirs
  28. The script uses ``find`` to capture the paths to all of the cobertura.ser files
  29. found below the project's source directory. It keeps the list of files and
  30. supplies it as an argument to the ``cobertura-merge`` program. The ``--datafile``
  31. argument signifies where the result of the merge will be kept.
  32. The combined ``coberturamerge.ser`` file is then used to generate the XML report
  33. using the ``cobertura-report`` program. The call to the cobertura-report program
  34. requires some named arguments.
  35. ``--datafila``
  36. path to the merged .ser file
  37. ``--destination``
  38. path to put the output files(s)
  39. ``--format``
  40. file format to write output in: xml or html
  41. The rest of the supplied arguments consist of the full paths to the
  42. /src/main/java directories of each module within the souce tree. These
  43. directories are needed and should not be forgotten.
  44. .. _`Cobertura`: http://cobertura.github.io/cobertura/