Adding Support for a Testing Dashboard.rst 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. Step 8: 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 a dashboard. To include support for dashboards
  7. we include the :module:`CTest` module in our top-level ``CMakeLists.txt``.
  8. Replace:
  9. .. code-block:: cmake
  10. :caption: CMakeLists.txt
  11. :name: CMakeLists.txt-enable_testing-remove
  12. # enable testing
  13. enable_testing()
  14. With:
  15. .. code-block:: cmake
  16. :caption: CMakeLists.txt
  17. :name: CMakeLists.txt-include-CTest
  18. # enable dashboard scripting
  19. include(CTest)
  20. The :module:`CTest` module will automatically call ``enable_testing()``, so we
  21. can remove it from our CMake files.
  22. We will also need to acquire a ``CTestConfig.cmake`` file to be placed in the
  23. top-level directory where we can specify information to CTest about the
  24. project. It contains:
  25. * The project name
  26. * The project "Nightly" start time
  27. * The time when a 24 hour "day" starts for this project.
  28. * The URL of the CDash instance where the submission's generated documents
  29. will be sent
  30. One has been provided for you in this directory. It would normally be
  31. downloaded from the ``Settings`` page of the project on the CDash
  32. instance that will host and display the test results. Once downloaded from
  33. CDash, the file should not be modified locally.
  34. .. literalinclude:: Step9/CTestConfig.cmake
  35. :caption: CTestConfig.cmake
  36. :name: CTestConfig.cmake
  37. :language: cmake
  38. The :manual:`ctest <ctest(1)>` executable will read in this file when it runs.
  39. To create a simple dashboard you can run the :manual:`cmake <cmake(1)>`
  40. executable or the :manual:`cmake-gui <cmake-gui(1)>` to configure the project,
  41. but do not build it yet. Instead, change directory to the binary tree, and then
  42. run:
  43. .. code-block:: console
  44. ctest [-VV] -D Experimental
  45. Remember, for multi-config generators (e.g. Visual Studio), the configuration
  46. type must be specified:
  47. .. code-block:: console
  48. ctest [-VV] -C Debug -D Experimental
  49. Or, from an IDE, build the ``Experimental`` target.
  50. The :manual:`ctest <ctest(1)>` executable will build and test the project and
  51. submit the results to Kitware's public dashboard:
  52. https://my.cdash.org/index.php?project=CMakeTutorial.