mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-28 19:58:34 -06:00
Merge topic 'ctest-json-polish'
cae9d2a61aCTest: Teach --show-only= to reject unknown values7370b02c36CTest: Teach --show-only=json-v1 to filter out not-available tests62fec84ad7Tests: Fix RunCMake.CTestCommandLine case when no python is found75a7a23746Tests: Rename RunCMake.CTestCommandLine show-only test casesfecbc87608Tests: Fix RunCMake.CTestCommandLine to actually check json-v1 Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2812
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
1
Tests/RunCMake/CTestCommandLine/show-only_bad-result.txt
Normal file
1
Tests/RunCMake/CTestCommandLine/show-only_bad-result.txt
Normal file
@@ -0,0 +1 @@
|
||||
1
|
||||
1
Tests/RunCMake/CTestCommandLine/show-only_bad-stderr.txt
Normal file
1
Tests/RunCMake/CTestCommandLine/show-only_bad-stderr.txt
Normal file
@@ -0,0 +1 @@
|
||||
^CMake Error: '--show-only=' given unknown value 'bad'$
|
||||
@@ -0,0 +1 @@
|
||||
Test #1: ShowOnly
|
||||
@@ -0,0 +1 @@
|
||||
show_only_json_check_python(1)
|
||||
@@ -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)
|
||||
Reference in New Issue
Block a user