Răsfoiți Sursa

CTest: Teach --show-only= to reject unknown values

Brad King 6 ani în urmă
părinte
comite
cae9d2a61a

+ 3 - 0
Source/cmCTest.cxx

@@ -1944,6 +1944,9 @@ bool cmCTest::HandleCommandLineArguments(size_t& i,
       this->Quiet = true;
       this->Quiet = true;
       this->OutputAsJson = true;
       this->OutputAsJson = true;
       this->OutputAsJsonVersion = 1;
       this->OutputAsJsonVersion = 1;
+    } else if (format != "human") {
+      errormsg = "'--show-only=' given unknown value '" + format + "'";
+      return false;
     }
     }
   }
   }
 
 

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

@@ -203,6 +203,8 @@ function(run_ShowOnly)
     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)
     add_test(ShowOnlyNotAvailable NOT_AVAILABLE)
 ")
 ")
+  run_cmake_command(show-only_human ${CMAKE_CTEST_COMMAND} --show-only=human)
+  run_cmake_command(show-only_bad ${CMAKE_CTEST_COMMAND} --show-only=bad)
   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()
 run_ShowOnly()
 run_ShowOnly()

+ 1 - 0
Tests/RunCMake/CTestCommandLine/show-only_bad-result.txt

@@ -0,0 +1 @@
+1

+ 1 - 0
Tests/RunCMake/CTestCommandLine/show-only_bad-stderr.txt

@@ -0,0 +1 @@
+^CMake Error: '--show-only=' given unknown value 'bad'$

+ 1 - 0
Tests/RunCMake/CTestCommandLine/show-only_human-stdout.txt

@@ -0,0 +1 @@
+Test #1: ShowOnly