Adding Support for a Testing Dashboard.rst 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 "Nightly" start time
  30. * The time when a 24 hour "day" starts for this project.
  31. * The URL of the CDash instance where the submission's generated documents
  32. will be sent
  33. For this tutorial, a public dashboard server is used and its corresponding
  34. ``CTestConfig.cmake`` file is provided for you in this step's root directory.
  35. In practice, this file would be downloaded from a project's ``Settings`` page
  36. on the CDash instance intended to host the test results. Once downloaded from
  37. CDash, the file should not be modified locally.
  38. .. literalinclude:: Step7/CTestConfig.cmake
  39. :caption: CTestConfig.cmake
  40. :name: CTestConfig.cmake
  41. :language: cmake
  42. Build and Run
  43. -------------
  44. Note that as part of the CDash submission some information about your
  45. development system (e.g. site name or full pathnames) may displayed publicly.
  46. To create a simple test dashboard, run the :manual:`cmake <cmake(1)>`
  47. executable or the :manual:`cmake-gui <cmake-gui(1)>` to configure the project
  48. but do not build it yet. Instead, navigate to the build directory and run:
  49. .. code-block:: console
  50. ctest [-VV] -D Experimental
  51. Remember, for multi-config generators (e.g. Visual Studio), the configuration
  52. type must be specified:
  53. .. code-block:: console
  54. ctest [-VV] -C Debug -D Experimental
  55. Or, from an IDE, build the ``Experimental`` target.
  56. The :manual:`ctest <ctest(1)>` executable will build the project, run any
  57. tests, and submit the results to Kitware's public dashboard:
  58. https://my.cdash.org/index.php?project=CMakeTutorial.
  59. Solution
  60. --------
  61. The only CMake code changed needed in this step was to enable dashboard
  62. submissions to CDash by including the :module:`CTest` module in our top-level
  63. ``CMakeLists.txt``:
  64. .. raw:: html
  65. <details><summary>TODO 1: Click to show/hide answer</summary>
  66. .. literalinclude:: Step7/CMakeLists.txt
  67. :caption: TODO 1: CMakeLists.txt
  68. :name: CMakeLists.txt-include-CTest
  69. :language: cmake
  70. :start-after: # enable testing
  71. :end-before: # does the application run
  72. .. raw:: html
  73. </details>