1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-23 00:48:55 +08:00

Tutorial: Update step 6 style

This commit is contained in:
Markus Ferrell
2022-10-06 12:05:42 -04:00
parent 7629a1182c
commit 6e58a01f4e
2 changed files with 66 additions and 30 deletions

View File

@@ -4,33 +4,40 @@ Step 6: Adding Support for a Testing Dashboard
Adding support for submitting our test results to a dashboard is simple. We Adding support for submitting our test results to a dashboard is simple. We
already defined a number of tests for our project in already defined a number of tests for our project in
:ref:`Testing Support <Tutorial Testing Support>`. Now we just have to run :ref:`Testing Support <Tutorial Testing Support>`. Now we just have to run
those tests and submit them to a dashboard. To include support for dashboards those tests and submit them to CDash.
we include the :module:`CTest` module in our top-level ``CMakeLists.txt``.
Replace:
.. literalinclude:: Step6/CMakeLists.txt Exercise 1 - Send Results to a Testing Dashboard
:caption: CMakeLists.txt ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
:name: CMakeLists.txt-enable_testing-remove
:language: cmake
:start-after: # enable testing
:end-before: # does the application run
With: Goal
----
.. literalinclude:: Step7/CMakeLists.txt Display our CTest results with CDash.
:caption: CMakeLists.txt
:name: CMakeLists.txt-include-CTest
:language: cmake
:start-after: # enable testing
:end-before: # does the application run
The :module:`CTest` module will automatically call ``enable_testing()``, so we Helpful Resources
can remove it from our CMake files. -----------------
* :manual:`ctest(1)`
* :command:`include`
* :module:`CTest`
Files to Edit
-------------
* ``CMakeLists.txt``
Getting Started
---------------
For this exercise, complete ``TODO 1`` in the top-level ``CMakeLists.txt`` by
including the :module:`CTest` module. This will enable testing with CTest as
well as dashboard submissions to CDash, so we can safely remove the call to
:command:`enable_testing`.
We will also need to acquire a ``CTestConfig.cmake`` file to be placed in the We will also need to acquire a ``CTestConfig.cmake`` file to be placed in the
top-level directory where we can specify information to CTest about the top-level directory. When run, the :manual:`ctest <ctest(1)>` executable will
project. It contains: read this file to gather information about the testing dashboard. It contains:
* The project name * The project name
@@ -41,9 +48,10 @@ project. It contains:
* The URL of the CDash instance where the submission's generated documents * The URL of the CDash instance where the submission's generated documents
will be sent will be sent
One has been provided for you in this directory. It would normally be For this tutorial, a public dashboard server is used and its corresponding
downloaded from the ``Settings`` page of the project on the CDash ``CTestConfig.cmake`` file is provided for you in this step's root directory.
instance that will host and display the test results. Once downloaded from In practice, this file would be downloaded from a project's ``Settings`` page
on the CDash instance intended to host the test results. Once downloaded from
CDash, the file should not be modified locally. CDash, the file should not be modified locally.
.. literalinclude:: Step7/CTestConfig.cmake .. literalinclude:: Step7/CTestConfig.cmake
@@ -51,11 +59,16 @@ CDash, the file should not be modified locally.
:name: CTestConfig.cmake :name: CTestConfig.cmake
:language: cmake :language: cmake
The :manual:`ctest <ctest(1)>` executable will read in this file when it runs.
To create a simple dashboard you can run the :manual:`cmake <cmake(1)>` Build and Run
executable or the :manual:`cmake-gui <cmake-gui(1)>` to configure the project, -------------
but do not build it yet. Instead, change directory to the binary tree, and then
run: Note that as part of the CDash submission some information about your
development system (e.g. site name or full pathnames) may displayed publicly.
To create a simple test dashboard, run the :manual:`cmake <cmake(1)>`
executable or the :manual:`cmake-gui <cmake-gui(1)>` to configure the project
but do not build it yet. Instead, navigate to the build directory and run:
.. code-block:: console .. code-block:: console
@@ -70,6 +83,28 @@ type must be specified:
Or, from an IDE, build the ``Experimental`` target. Or, from an IDE, build the ``Experimental`` target.
The :manual:`ctest <ctest(1)>` executable will build and test the project and The :manual:`ctest <ctest(1)>` executable will build the project, run any
submit the results to Kitware's public dashboard: tests, and submit the results to Kitware's public dashboard:
https://my.cdash.org/index.php?project=CMakeTutorial. https://my.cdash.org/index.php?project=CMakeTutorial.
Solution
--------
The only CMake code changed needed in this step was to enable dashboard
submissions to CDash by including the :module:`CTest` module in our top-level
``CMakeLists.txt``:
.. raw:: html
<details><summary>TODO 1: Click to show/hide answer</summary>
.. literalinclude:: Step7/CMakeLists.txt
:caption: TODO 1: CMakeLists.txt
:name: CMakeLists.txt-include-CTest
:language: cmake
:start-after: # enable testing
:end-before: # does the application run
.. raw:: html
</details>

View File

@@ -45,6 +45,7 @@ install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h"
DESTINATION include DESTINATION include
) )
# TODO 1: Replace enable_testing() with include(CTest)
# enable testing # enable testing
enable_testing() enable_testing()