summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-01-21 12:50:54 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-01-21 12:51:08 (GMT)
commit7e5f9b192e9c3ed7130e1e52b7f9d3243f51e2ab (patch)
treeef3e3526aa8f8c1ab1c433f55870375e3ee7a01b
parent15fe5c4c9d90aa03e146fe8b9585e82c4f3b5ffe (diff)
parentcae9d2a61afea3948c8dfaf1f7dbc39ebaa71055 (diff)
downloadCMake-7e5f9b192e9c3ed7130e1e52b7f9d3243f51e2ab.zip
CMake-7e5f9b192e9c3ed7130e1e52b7f9d3243f51e2ab.tar.gz
CMake-7e5f9b192e9c3ed7130e1e52b7f9d3243f51e2ab.tar.bz2
Merge topic 'ctest-json-polish'
cae9d2a61a CTest: Teach --show-only= to reject unknown values 7370b02c36 CTest: Teach --show-only=json-v1 to filter out not-available tests 62fec84ad7 Tests: Fix RunCMake.CTestCommandLine case when no python is found 75a7a23746 Tests: Rename RunCMake.CTestCommandLine show-only test cases fecbc87608 Tests: Fix RunCMake.CTestCommandLine to actually check json-v1 Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2812
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx5
-rw-r--r--Source/cmCTest.cxx3
-rw-r--r--Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake22
-rw-r--r--Tests/RunCMake/CTestCommandLine/show-only_bad-result.txt1
-rw-r--r--Tests/RunCMake/CTestCommandLine/show-only_bad-stderr.txt1
-rw-r--r--Tests/RunCMake/CTestCommandLine/show-only_human-stdout.txt1
-rw-r--r--Tests/RunCMake/CTestCommandLine/show-only_json-v1-check.cmake1
-rw-r--r--Tests/RunCMake/CTestCommandLine/show-only_json-v1_check.py (renamed from Tests/RunCMake/CTestCommandLine/ShowAsJson1-check.py)6
-rw-r--r--Tests/RunCMake/CTestCommandLine/show_only_json_check.py (renamed from Tests/RunCMake/CTestCommandLine/ShowAsJson_check.py)0
9 files changed, 29 insertions, 11 deletions
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index 8867323..320647a 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -1039,6 +1039,11 @@ void cmCTestMultiProcessHandler::PrintOutputAsJson()
testRun.SetTestProperties(&p);
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);
tests.append(testInfo);
}
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index ded2525..4959288 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -1944,6 +1944,9 @@ bool cmCTest::HandleCommandLineArguments(size_t& i,
this->Quiet = true;
this->OutputAsJson = true;
this->OutputAsJsonVersion = 1;
+ } else if (format != "human") {
+ errormsg = "'--show-only=' given unknown value '" + format + "'";
+ return false;
}
}
diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
index cae14b1..d524f41 100644
--- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
@@ -174,12 +174,15 @@ function(run_TestStdin)
endfunction()
run_TestStdin()
-function(ShowAsJson_check_python v)
+function(show_only_json_check_python v)
+ if(RunCMake_TEST_FAILED OR NOT PYTHON_EXECUTABLE)
+ return()
+ endif()
set(json_file "${RunCMake_TEST_BINARY_DIR}/ctest.json")
file(WRITE "${json_file}" "${actual_stdout}")
set(actual_stdout "" PARENT_SCOPE)
execute_process(
- COMMAND ${PYTHON_EXECUTABLE} "${RunCMake_SOURCE_DIR}/ShowAsJson${v}-check.py" "${json_file}"
+ COMMAND ${PYTHON_EXECUTABLE} "${RunCMake_SOURCE_DIR}/show-only_json-v${v}_check.py" "${json_file}"
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_VARIABLE output
@@ -190,15 +193,18 @@ function(ShowAsJson_check_python v)
endif()
endfunction()
-function(run_ShowAsJson)
- set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ShowAsJson)
+function(run_ShowOnly)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ShowOnly)
set(RunCMake_TEST_NO_CLEAN 1)
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
- add_test(ShowAsJson \"${CMAKE_COMMAND}\" -E echo)
- set_tests_properties(ShowAsJson PROPERTIES WILL_FAIL true _BACKTRACE_TRIPLES \"file1;1;add_test;file0;;\")
+ add_test(ShowOnly \"${CMAKE_COMMAND}\" -E echo)
+ set_tests_properties(ShowOnly PROPERTIES WILL_FAIL true _BACKTRACE_TRIPLES \"file1;1;add_test;file0;;\")
+ add_test(ShowOnlyNotAvailable NOT_AVAILABLE)
")
- run_cmake_command(ShowAsJsonVersionOne ${CMAKE_CTEST_COMMAND} --show-only=json-v1)
+ 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)
endfunction()
-run_ShowAsJson()
+run_ShowOnly()
diff --git a/Tests/RunCMake/CTestCommandLine/show-only_bad-result.txt b/Tests/RunCMake/CTestCommandLine/show-only_bad-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/show-only_bad-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CTestCommandLine/show-only_bad-stderr.txt b/Tests/RunCMake/CTestCommandLine/show-only_bad-stderr.txt
new file mode 100644
index 0000000..cc55ab3
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/show-only_bad-stderr.txt
@@ -0,0 +1 @@
+^CMake Error: '--show-only=' given unknown value 'bad'$
diff --git a/Tests/RunCMake/CTestCommandLine/show-only_human-stdout.txt b/Tests/RunCMake/CTestCommandLine/show-only_human-stdout.txt
new file mode 100644
index 0000000..1332149
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/show-only_human-stdout.txt
@@ -0,0 +1 @@
+Test #1: ShowOnly
diff --git a/Tests/RunCMake/CTestCommandLine/show-only_json-v1-check.cmake b/Tests/RunCMake/CTestCommandLine/show-only_json-v1-check.cmake
new file mode 100644
index 0000000..f9234f8
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/show-only_json-v1-check.cmake
@@ -0,0 +1 @@
+show_only_json_check_python(1)
diff --git a/Tests/RunCMake/CTestCommandLine/ShowAsJson1-check.py b/Tests/RunCMake/CTestCommandLine/show-only_json-v1_check.py
index d794e7d..4dff90c 100644
--- a/Tests/RunCMake/CTestCommandLine/ShowAsJson1-check.py
+++ b/Tests/RunCMake/CTestCommandLine/show-only_json-v1_check.py
@@ -1,4 +1,4 @@
-from ShowAsJson_check import *
+from show_only_json_check import *
def check_kind(k):
assert is_string(k)
@@ -77,7 +77,7 @@ def check_workingdir_property(p):
assert is_string(p["name"])
assert is_string(p["value"])
assert p["name"] == "WORKING_DIRECTORY"
- assert p["value"].endswith("Tests/RunCMake/CTestCommandLine/ShowAsJson")
+ assert p["value"].endswith("Tests/RunCMake/CTestCommandLine/ShowOnly")
def check_properties(p):
assert is_list(p)
@@ -95,7 +95,7 @@ def check_tests(t):
assert test["backtrace"] == 1
check_command(test["command"])
assert is_string(test["name"])
- assert test["name"] == "ShowAsJson"
+ assert test["name"] == "ShowOnly"
check_properties(test["properties"])
assert is_dict(ctest_json)
diff --git a/Tests/RunCMake/CTestCommandLine/ShowAsJson_check.py b/Tests/RunCMake/CTestCommandLine/show_only_json_check.py
index 493c9e5..493c9e5 100644
--- a/Tests/RunCMake/CTestCommandLine/ShowAsJson_check.py
+++ b/Tests/RunCMake/CTestCommandLine/show_only_json_check.py