Adding Support for a Testing Dashboard.rst 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. Step 6: Adding Support for a Testing Dashboard
  2. ==============================================
  3. Adding support for submitting our test results to a dashboard is simple. We
  4. already defined a number of tests for our project in
  5. :ref:`Testing Support <Tutorial Testing Support>`. Now we just have to run
  6. those tests and submit them to CDash.
  7. Exercise 1 - Send Results to a Testing Dashboard
  8. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  9. Goal
  10. ----
  11. Display our CTest results with CDash.
  12. Helpful Resources
  13. -----------------
  14. * :manual:`ctest(1)`
  15. * :command:`include`
  16. * :module:`CTest`
  17. Files to Edit
  18. -------------
  19. * ``CMakeLists.txt``
  20. Getting Started
  21. ---------------
  22. For this exercise, complete ``TODO 1`` in the top-level ``CMakeLists.txt`` by
  23. including the :module:`CTest` module. This will enable testing with CTest as
  24. well as dashboard submissions to CDash, so we can safely remove the call to
  25. :command:`enable_testing`.
  26. We will also need to acquire a ``CTestConfig.cmake`` file to be placed in the
  27. top-level directory. When run, the :manual:`ctest <ctest(1)>` executable will
  28. read this file to gather information about the testing dashboard. It contains:
  29. * The project name
  30. * The project "Nightly" start time
  31. * The time when a 24 hour "day" starts for this project.
  32. * The URL of the CDash instance where the submission's generated documents
  33. will be sent
  34. For this tutorial, a public dashboard server is used and its corresponding
  35. ``CTestConfig.cmake`` file is provided for you in this step's root directory.
  36. In practice, this file would be downloaded from a project's ``Settings`` page
  37. on the CDash instance intended to host the test results. Once downloaded from
  38. CDash, the file should not be modified locally.
  39. .. literalinclude:: Step7/CTestConfig.cmake
  40. :caption: CTestConfig.cmake
  41. :name: CTestConfig.cmake
  42. :language: cmake
  43. Build and Run
  44. -------------
  45. Note that as part of the CDash submission some information about your
  46. development system (e.g. site name or full pathnames) may displayed publicly.
  47. To create a simple test dashboard, run the :manual:`cmake <cmake(1)>`
  48. executable or the :manual:`cmake-gui <cmake-gui(1)>` to configure the project
  49. but do not build it yet. Instead, navigate to the build directory and run:
  50. .. code-block:: console
  51. ctest [-VV] -D Experimental
  52. Remember, for multi-config generators (e.g. Visual Studio), the configuration
  53. type must be specified:
  54. .. code-block:: console
  55. ctest [-VV] -C Debug -D Experimental
  56. Or, from an IDE, build the ``Experimental`` target.
  57. The :manual:`ctest <ctest(1)>` executable will build the project, run any
  58. tests, and submit the results to Kitware's public dashboard:
  59. https://my.cdash.org/index.php?project=CMakeTutorial.
  60. Solution
  61. --------
  62. The only CMake code changed needed in this step was to enable dashboard
  63. submissions to CDash by including the :module:`CTest` module in our top-level
  64. ``CMakeLists.txt``:
  65. .. raw:: html
  66. <details><summary>TODO 1: Click to show/hide answer</summary>
  67. .. literalinclude:: Step7/CMakeLists.txt
  68. :caption: TODO 1: CMakeLists.txt
  69. :name: CMakeLists.txt-include-CTest
  70. :language: cmake
  71. :start-after: # enable testing
  72. :end-before: # does the application run
  73. .. raw:: html
  74. </details>