Adding Support for a Testing Dashboard.rst 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 create a ``CTestConfig.cmake`` file in the top-level
  23. directory where we can specify the name of the project and where to submit the
  24. dashboard.
  25. .. literalinclude:: Step9/CTestConfig.cmake
  26. :caption: CTestConfig.cmake
  27. :name: CTestConfig.cmake
  28. :language: cmake
  29. The :manual:`ctest <ctest(1)>` executable will read in this file when it runs.
  30. To create a simple dashboard you can run the :manual:`cmake <cmake(1)>`
  31. executable or the :manual:`cmake-gui <cmake-gui(1)>` to configure the project,
  32. but do not build it yet. Instead, change directory to the binary tree, and then
  33. run:
  34. .. code-block:: console
  35. ctest [-VV] -D Experimental
  36. Remember, for multi-config generators (e.g. Visual Studio), the configuration
  37. type must be specified:
  38. .. code-block:: console
  39. ctest [-VV] -C Debug -D Experimental
  40. Or, from an IDE, build the ``Experimental`` target.
  41. The :manual:`ctest <ctest(1)>` executable will build and test the project and
  42. submit the results to Kitware's public dashboard:
  43. https://my.cdash.org/index.php?project=CMakeTutorial.