diff options
author | Craig Scott <craig.scott@crascit.com> | 2023-06-02 07:16:57 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-06-05 10:20:50 (GMT) |
commit | 99b2ccf80dc87ccf6832508cc3f8889a70c2785f (patch) | |
tree | 6ff990a8878c0e90ee9c5b88ce876f7893e5c882 /Tests | |
parent | 9a63aa8d57394fbddf913ce35c2d32bbf523f0e6 (diff) | |
download | CMake-99b2ccf80dc87ccf6832508cc3f8889a70c2785f.zip CMake-99b2ccf80dc87ccf6832508cc3f8889a70c2785f.tar.gz CMake-99b2ccf80dc87ccf6832508cc3f8889a70c2785f.tar.bz2 |
cmake_file_api: New project command
Projects can use the new command to request file API replies for the current
run. No query files are generated, the query is tracked internally. Replies are
created in the file system at generation time in the usual way.
Fixes: #24951
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/RunCMake/FileAPI/ProjectQueryBad-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/FileAPI/ProjectQueryBad-stderr.txt | 36 | ||||
-rw-r--r-- | Tests/RunCMake/FileAPI/ProjectQueryBad.cmake | 42 | ||||
-rw-r--r-- | Tests/RunCMake/FileAPI/ProjectQueryGood-check.cmake | 11 | ||||
-rw-r--r-- | Tests/RunCMake/FileAPI/ProjectQueryGood.cmake | 8 | ||||
-rw-r--r-- | Tests/RunCMake/FileAPI/RunCMakeTest.cmake | 2 |
6 files changed, 100 insertions, 0 deletions
diff --git a/Tests/RunCMake/FileAPI/ProjectQueryBad-result.txt b/Tests/RunCMake/FileAPI/ProjectQueryBad-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FileAPI/ProjectQueryBad-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FileAPI/ProjectQueryBad-stderr.txt b/Tests/RunCMake/FileAPI/ProjectQueryBad-stderr.txt new file mode 100644 index 0000000..84eff98 --- /dev/null +++ b/Tests/RunCMake/FileAPI/ProjectQueryBad-stderr.txt @@ -0,0 +1,36 @@ +Non-query check +CMake Error at ProjectQueryBad\.cmake:[0-9]+ \(cmake_file_api\): + cmake_file_api does not recognize sub-command NOT_A_QUERY +.* +Invalid API version checks +CMake Error at ProjectQueryBad\.cmake:[0-9]+ \(cmake_file_api\): + cmake_file_api QUERY subcommand given an unsupported API_VERSION "2" \(the + only currently supported version is 1\)\. +.* +CMake Error at ProjectQueryBad\.cmake:[0-9]+ \(cmake_file_api\): + cmake_file_api QUERY subcommand given a non-integer API_VERSION\. +.* +Invalid version numbers check +CMake Error at ProjectQueryBad\.cmake:[0-9]+ \(cmake_file_api\): + cmake_file_api QUERY subcommand was given invalid arguments: + + Given a malformed version "nope" for CODEMODEL\. + Given a malformed version "-2" for CACHE\. + Given a malformed version "\.8" for CMAKEFILES\. + Given a malformed version "0\.1" for TOOLCHAINS\. +.* +Requested versions too high check +CMake Error at ProjectQueryBad\.cmake:[0-9]+ \(cmake_file_api\): + cmake_file_api QUERY subcommand was given invalid arguments: + + None of the specified CODEMODEL versions is supported by this version of CMake\. + None of the specified CACHE versions is supported by this version of CMake\. + None of the specified CMAKEFILES versions is supported by this version of CMake\. + None of the specified TOOLCHAINS versions is supported by this version of CMake\. +.* +Requested versions too low check +CMake Error at ProjectQueryBad\.cmake:[0-9]+ \(cmake_file_api\): + cmake_file_api QUERY subcommand was given invalid arguments: + + None of the specified CODEMODEL versions is supported by this version of CMake\. + None of the specified CACHE versions is supported by this version of CMake\. diff --git a/Tests/RunCMake/FileAPI/ProjectQueryBad.cmake b/Tests/RunCMake/FileAPI/ProjectQueryBad.cmake new file mode 100644 index 0000000..3a06105 --- /dev/null +++ b/Tests/RunCMake/FileAPI/ProjectQueryBad.cmake @@ -0,0 +1,42 @@ +# All of these should fail. Execution does continue though, so we should see +# the error output from each one. There is no observable effect of the command +# during the configure phase, so it isn't critical to end processing on the +# first failure. Allowing execution to proceed may allow the project to see +# other potential errors before ultimately halting. That behavior is generally +# desirable, and the multiple failing calls here will confirm that we retain +# that behavior. + +message(NOTICE "Non-query check") +cmake_file_api(NOT_A_QUERY) + +message(NOTICE "Invalid API version checks") +cmake_file_api(QUERY API_VERSION 2) +cmake_file_api(QUERY API_VERSION nah) + +message(NOTICE "Invalid version numbers check") +cmake_file_api( + QUERY + API_VERSION 1 + CODEMODEL nope + CACHE -2 + CMAKEFILES .8 + TOOLCHAINS 2 0.1 +) + +message(NOTICE "Requested versions too high check") +cmake_file_api( + QUERY + API_VERSION 1 + CODEMODEL 3 + CACHE 3 + CMAKEFILES 2 + TOOLCHAINS 1.1 +) + +message(NOTICE "Requested versions too low check") +cmake_file_api( + QUERY + API_VERSION 1 + CODEMODEL 1 + CACHE 1 +) diff --git a/Tests/RunCMake/FileAPI/ProjectQueryGood-check.cmake b/Tests/RunCMake/FileAPI/ProjectQueryGood-check.cmake new file mode 100644 index 0000000..46d3f77 --- /dev/null +++ b/Tests/RunCMake/FileAPI/ProjectQueryGood-check.cmake @@ -0,0 +1,11 @@ +set(expect + reply + reply/cache-v2-[0-9a-f]+.json + reply/cmakeFiles-v1-[0-9a-f]+.json + reply/codemodel-v2-[0-9a-f]+.json + .*reply/index-[0-9.T-]+.json + .*reply/toolchains-v1-[0-9a-f]+.json +) + +# Only need to check for existence. Other tests check the reply contents. +check_api("^${expect}$") diff --git a/Tests/RunCMake/FileAPI/ProjectQueryGood.cmake b/Tests/RunCMake/FileAPI/ProjectQueryGood.cmake new file mode 100644 index 0000000..da0f3ce --- /dev/null +++ b/Tests/RunCMake/FileAPI/ProjectQueryGood.cmake @@ -0,0 +1,8 @@ +cmake_file_api( + QUERY + API_VERSION 1 + CODEMODEL 3 2.1 + CACHE 3.2 2 + CMAKEFILES 3 2 1.0 + TOOLCHAINS 3 2 1 +) diff --git a/Tests/RunCMake/FileAPI/RunCMakeTest.cmake b/Tests/RunCMake/FileAPI/RunCMakeTest.cmake index c768d18..81926af 100644 --- a/Tests/RunCMake/FileAPI/RunCMakeTest.cmake +++ b/Tests/RunCMake/FileAPI/RunCMakeTest.cmake @@ -52,6 +52,8 @@ run_cmake(ClientStateless) run_cmake(MixedStateless) run_cmake(DuplicateStateless) run_cmake(ClientStateful) +run_cmake(ProjectQueryGood) +run_cmake(ProjectQueryBad) function(run_object object) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${object}-build) |