README.rst 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. This directory contains tests that run CMake to configure a project
  2. but do not actually build anything. To add a test:
  3. 1. Add a subdirectory named for the test, say ``<Test>/``.
  4. 2. In ``./CMakeLists.txt`` call ``add_RunCMake_test`` and pass the
  5. test directory name ``<Test>``.
  6. 3. Create script ``<Test>/RunCMakeTest.cmake`` in the directory containing::
  7. include(RunCMake)
  8. run_cmake(SubTest1)
  9. ...
  10. run_cmake(SubTestN)
  11. where ``SubTest1`` through ``SubTestN`` are sub-test names each
  12. corresponding to an independent CMake run and project configuration.
  13. One may also add calls of the form::
  14. run_cmake_command(SubTestI ${CMAKE_COMMAND} ...)
  15. to fully customize the test case command-line.
  16. 4. Create file ``<Test>/CMakeLists.txt`` in the directory containing::
  17. cmake_minimum_required(...)
  18. project(${RunCMake_TEST} NONE) # or languages needed
  19. include(${RunCMake_TEST}.cmake)
  20. where ``${RunCMake_TEST}`` is literal. A value for ``RunCMake_TEST``
  21. will be passed to CMake by the ``run_cmake`` macro when running each
  22. sub-test.
  23. 5. Create a ``<Test>/<SubTest>.cmake`` file for each sub-test named
  24. above containing the actual test code. Optionally create files
  25. containing expected test results:
  26. ``<SubTest>-result.txt``
  27. Process result expected if not "0"
  28. ``<SubTest>-stdout.txt``
  29. Regex matching expected stdout content
  30. ``<SubTest>-stderr.txt``
  31. Regex matching expected stderr content
  32. ``<SubTest>-check.cmake``
  33. Custom result check.
  34. Note that trailing newlines will be stripped from actual and expected
  35. test output before matching against the stdout and stderr expressions.
  36. The code in ``<SubTest>-check.cmake`` may use variables
  37. ``RunCMake_TEST_SOURCE_DIR``
  38. Top of test source tree
  39. ``RunCMake_TEST_BINARY_DIR``
  40. Top of test binary tree
  41. and an failure must store a message in ``RunCMake_TEST_FAILED``.