浏览代码

Tests: Add RunCMake_TEST_FILTER environment variable

This environment variable allows developers to locally run only a
subset of RunCMake subtests in a single RunCMakeTest.cmake script.
If the environment variable is not set, all of the tests in the
script are run.
Kyle Edwards 7 年之前
父节点
当前提交
b6eafd5781
共有 2 个文件被更改,包括 15 次插入0 次删除
  1. 11 0
      Tests/RunCMake/README.rst
  2. 4 0
      Tests/RunCMake/RunCMake.cmake

+ 11 - 0
Tests/RunCMake/README.rst

@@ -65,3 +65,14 @@ but do not actually build anything.  To add a test:
     Top of test binary tree
 
    and an failure must store a message in ``RunCMake_TEST_FAILED``.
+
+To speed up local testing, you can choose to run only a subset of
+``run_cmake()`` tests in a ``RunCMakeTest.cmake`` script by using the
+``RunCMake_TEST_FILTER`` environment variable. If this variable is set,
+it is treated as a regular expression, and any tests whose names don't
+match the regular expression are not run. For example::
+
+  $ RunCMake_TEST_FILTER="^example" ctest -R '^RunCMake\.Example$'
+
+This will only run subtests in ``RunCMake.Example`` that start with
+``example``.

+ 4 - 0
Tests/RunCMake/RunCMake.cmake

@@ -9,6 +9,10 @@ foreach(arg
 endforeach()
 
 function(run_cmake test)
+  if(DEFINED ENV{RunCMake_TEST_FILTER} AND NOT test MATCHES "$ENV{RunCMake_TEST_FILTER}")
+    return()
+  endif()
+
   set(top_src "${RunCMake_SOURCE_DIR}")
   set(top_bin "${RunCMake_BINARY_DIR}")
   if(EXISTS ${top_src}/${test}-result.txt)