瀏覽代碼

CTest: Teach --show-only=json-v1 to filter out not-available tests

Avoid exposing the internal special value that we use to track tests not
available in the tested configuration.  This also prevents clients from
having to do the filtering themselves.
Brad King 6 年之前
父節點
當前提交
7370b02c36
共有 2 個文件被更改,包括 6 次插入0 次删除
  1. 5 0
      Source/CTest/cmCTestMultiProcessHandler.cxx
  2. 1 0
      Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake

+ 5 - 0
Source/CTest/cmCTestMultiProcessHandler.cxx

@@ -1039,6 +1039,11 @@ void cmCTestMultiProcessHandler::PrintOutputAsJson()
     testRun.SetTestProperties(&p);
     testRun.SetTestProperties(&p);
     testRun.ComputeArguments();
     testRun.ComputeArguments();
 
 
+    // Skip tests not available in this configuration.
+    if (p.Args.size() >= 2 && p.Args[1] == "NOT_AVAILABLE") {
+      continue;
+    }
+
     Json::Value testInfo = DumpCTestInfo(testRun, p, backtraceGraph);
     Json::Value testInfo = DumpCTestInfo(testRun, p, backtraceGraph);
     tests.append(testInfo);
     tests.append(testInfo);
   }
   }

+ 1 - 0
Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake

@@ -201,6 +201,7 @@ function(run_ShowOnly)
   file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
   file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
     add_test(ShowOnly \"${CMAKE_COMMAND}\" -E echo)
     add_test(ShowOnly \"${CMAKE_COMMAND}\" -E echo)
     set_tests_properties(ShowOnly PROPERTIES WILL_FAIL true _BACKTRACE_TRIPLES \"file1;1;add_test;file0;;\")
     set_tests_properties(ShowOnly PROPERTIES WILL_FAIL true _BACKTRACE_TRIPLES \"file1;1;add_test;file0;;\")
+    add_test(ShowOnlyNotAvailable NOT_AVAILABLE)
 ")
 ")
   run_cmake_command(show-only_json-v1 ${CMAKE_CTEST_COMMAND} --show-only=json-v1)
   run_cmake_command(show-only_json-v1 ${CMAKE_CTEST_COMMAND} --show-only=json-v1)
 endfunction()
 endfunction()