Adding Support for a Testing Dashboard.rst 2.5 KB

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