Commit 4d630e58 authored by Robert Maynard's avatar Robert Maynard

Tests: Convert over a random selection of tests to use build.cmake

parent f3e09f31
......@@ -2929,15 +2929,15 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
"Process file.*UTCovTest.pas.*Total LOC:.*20.*Percentage Coverage: 95.*"
ENVIRONMENT COVFILE=)
function(add_config_tests cfg)
set(base "${CMake_BINARY_DIR}/Tests/CTestConfig")
function(add_config_tests cfg dir inputFile)
set(base "${CMake_BINARY_DIR}/Tests/${dir}")
# Test -S script with a -C config arg to ctest:
configure_file(
"${CMake_SOURCE_DIR}/Tests/CTestConfig/script.cmake.in"
"${CMake_SOURCE_DIR}/Tests/${dir}/script.cmake.in"
"${base}/${cfg}-script.cmake"
@ONLY ESCAPE_QUOTES)
add_test(CTestConfig.Script.${cfg} ${CMAKE_CTEST_COMMAND}
add_test(CTestConfig.Script.${cfg}.${inputFile} ${CMAKE_CTEST_COMMAND}
-C ${cfg}
-S "${base}/${cfg}-script.cmake" -VV
--output-log "${base}/${cfg}-script.log"
......@@ -2947,18 +2947,22 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
# (Actual commands inside a cmake -P script because we need to be able to set
# the working directory reliably...)
configure_file(
"${CMake_SOURCE_DIR}/Tests/CTestConfig/dashboard.cmake.in"
"${CMake_SOURCE_DIR}/Tests/${dir}/dashboard.cmake.in"
"${base}/${cfg}-dashboard.cmake"
@ONLY ESCAPE_QUOTES)
add_test(CTestConfig.Dashboard.${cfg} ${CMAKE_CMAKE_COMMAND}
add_test(CTestConfig.Dashboard.${cfg}.${inputFile} ${CMAKE_CMAKE_COMMAND}
-P "${base}/${cfg}-dashboard.cmake" -VV
)
endfunction()
add_config_tests(Debug)
add_config_tests(MinSizeRel)
add_config_tests(Release)
add_config_tests(RelWithDebInfo)
add_config_tests(Debug CTestConfig CMakeLists.txt)
add_config_tests(Debug CTestConfig2 build.cmake)
add_config_tests(MinSizeRel CTestConfig CMakeLists.txt)
add_config_tests(MinSizeRel CTestConfig2 build.cmake)
add_config_tests(Release CTestConfig CMakeLists.txt)
add_config_tests(Release CTestConfig2 build.cmake)
add_config_tests(RelWithDebInfo CTestConfig CMakeLists.txt)
add_config_tests(RelWithDebInfo CTestConfig2 build.cmake)
# Test -S script with some -D variable definition args to ctest:
add_test(CTestConfig.ScriptWithArgs ${CMAKE_CTEST_COMMAND}
......
#include <stdio.h>
int main(int argc, const char* argv[])
{
int i = 0;
for (; i < argc; ++i) {
fprintf(stdout, "%s\n", argv[i]);
}
#ifdef CMAKE_BUILD_TYPE
fprintf(stdout, "CMAKE_BUILD_TYPE is %s\n", CMAKE_BUILD_TYPE);
#endif
#ifdef CMAKE_INTDIR
fprintf(stdout, "CMAKE_INTDIR is %s\n", CMAKE_INTDIR);
#endif
return 0;
}
set(CTEST_RUN_CURRENT_SCRIPT 0)
macro(check_arg name expected_value)
message("${name}='${${name}}'")
if(NOT "${${name}}" STREQUAL "${expected_value}")
message(FATAL_ERROR "unexpected ${name} value '${${name}}', expected '${expected_value}'")
endif()
endmacro()
check_arg(arg1 "this")
check_arg(arg2 "that")
check_arg(arg3 "the other")
check_arg(arg4 "this is the fourth")
check_arg(arg5 "the_fifth")
check_arg(arg6 "value-with-type")
check_arg(arg7 "")
cmake_minimum_required(VERSION 3.9)
project(CTestConfig)
include(CTest)
# We expect this configure to occur through a 'ctest -D Experimental' or a
# 'ctest -S script.cmake' call.
#
# In either case, we expect CMAKE_BUILD_TYPE to be defined for single-configuration
# build trees and not defined for multi-configuration build trees. The value of
# CMAKE_CONFIGURATION_TYPES should not be relied upon to determine whether we
# are using a multi-config generator or not, the GENERATOR_IS_MULTI_CONFIG
# global property is the canonical way to do that as of CMake 3.9.
#
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(_isMultiConfig)
if(NOT DEFINED CMAKE_CONFIGURATION_TYPES OR CMAKE_CONFIGURATION_TYPES STREQUAL "")
message(FATAL_ERROR "CMAKE_CONFIGURATION_TYPES is not defined or is empty "
"(but must be defined and non-empty for a multi-configuration generator)")
endif()
if(DEFINED CMAKE_BUILD_TYPE AND NOT CMAKE_BUILD_TYPE STREQUAL "")
message(FATAL_ERROR "CMAKE_BUILD_TYPE='${CMAKE_BUILD_TYPE}' is defined and non-empty "
"(but should not be for a multi-configuration generator)")
endif()
set(_configs ${CMAKE_CONFIGURATION_TYPES})
else()
# Populating CMAKE_CONFIGURATION_TYPES even for single config generators is
# common enough for user projects that we don't want to consider it an error.
# We just need CMAKE_BUILD_TYPE to be set and ignore CMAKE_CONFIGURATION_TYPES.
if(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
message(FATAL_ERROR "CMAKE_BUILD_TYPE is not defined or is empty "
"(but should be defined and non-empty for a single-configuration generator)")
endif()
add_definitions(-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}")
set(_configs ${CMAKE_BUILD_TYPE})
endif()
add_executable(ctc CTestConfig.cxx)
foreach(cfg ${_configs})
add_test(NAME ctc-${cfg} CONFIGURATIONS ${cfg} COMMAND ctc --config $<CONFIGURATION>)
if(_isMultiConfig)
set_property(TEST ctc-${cfg}
PROPERTY PASS_REGULAR_EXPRESSION "CMAKE_INTDIR is ${cfg}")
set_property(TEST ctc-${cfg}
PROPERTY FAIL_REGULAR_EXPRESSION "CMAKE_BUILD_TYPE is")
else()
set_property(TEST ctc-${cfg}
PROPERTY PASS_REGULAR_EXPRESSION "CMAKE_BUILD_TYPE is ${cfg}")
set_property(TEST ctc-${cfg}
PROPERTY FAIL_REGULAR_EXPRESSION "CMAKE_INTDIR is")
endif()
endforeach()
set(_isMultiConfig "@_isMultiConfig@")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestConfig2")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestConfig2/@cfg@-dashboard")
file(MAKE_DIRECTORY "${CTEST_BINARY_DIRECTORY}")
get_filename_component(dir "${CMAKE_COMMAND}" PATH)
set(CMAKE_CTEST_COMMAND "${dir}/ctest")
message("CMAKE_COMMAND='${CMAKE_COMMAND}'")
message("CMAKE_CTEST_COMMAND='${CMAKE_CTEST_COMMAND}'")
set(arg "")
if(NOT _isMultiConfig)
set(arg "-DCMAKE_BUILD_TYPE:STRING=@cfg@")
endif()
message("cmake initial configure")
execute_process(COMMAND ${CMAKE_COMMAND}
${arg}
-G "@CMAKE_GENERATOR@"
-A "@CMAKE_GENERATOR_PLATFORM@"
-T "@CMAKE_GENERATOR_TOOLSET@"
${CTEST_SOURCE_DIRECTORY}
WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY}
RESULT_VARIABLE rv)
if(NOT rv STREQUAL 0)
message(FATAL_ERROR "error calling cmake: rv='${rv}'")
endif()
function(call_ctest arg)
message("call_ctest ${arg}")
execute_process(COMMAND ${CMAKE_CTEST_COMMAND}
-C "@cfg@" -D ${arg} -VV
WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY}
RESULT_VARIABLE rv)
if(NOT rv STREQUAL 0)
message(FATAL_ERROR "error calling ctest: rv='${rv}'")
endif()
endfunction()
call_ctest(ExperimentalStart)
call_ctest(ExperimentalConfigure)
call_ctest(ExperimentalBuild)
call_ctest(ExperimentalTest)
set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
set(CTEST_CMAKE_GENERATOR_PLATFORM "@CMAKE_GENERATOR_PLATFORM@")
set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_PROJECT_NAME "CTestConfig2")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestConfig2")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestConfig2/@cfg@-script")
ctest_start(Experimental)
ctest_configure(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE rv)
if(NOT rv STREQUAL 0)
message(FATAL_ERROR "*** error in ctest_configure ***")
endif()
ctest_build(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE rv)
if(NOT rv STREQUAL 0)
message(FATAL_ERROR "*** error in ctest_build ***")
endif()
ctest_test(BUILD "${CTEST_BINARY_DIRECTORY}" RETURN_VALUE rv)
if(NOT rv STREQUAL 0)
message(FATAL_ERROR "*** error in ctest_test ***")
endif()
......@@ -73,7 +73,7 @@ endif ()
# get the stack of listfiles
include(Included.cmake)
if ("${LF_VALUE}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt;${CMAKE_CURRENT_SOURCE_DIR}/Included.cmake")
if ("${LF_VALUE}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}/build.cmake;${CMAKE_CURRENT_SOURCE_DIR}/Included.cmake")
add_definitions(-DCMAKE_FOUND_LISTFILE_STACK)
endif ()
......
......@@ -7,4 +7,4 @@
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack \(most recent call first\):
CMakeLists.txt:[0-9]+ \(include\)$
build.cmake:[0-9]+ \(include\)$
CMake Warning \(dev\) in CMakeLists.txt:
CMake Warning \(dev\) in build.cmake:
Policy CMP0019 is not set: Do not re-expand variables in include and link
information. Run "cmake --help-policy CMP0019" for policy details. Use
the cmake_policy command to set the policy and suppress this warning.
......
......@@ -2,4 +2,4 @@ CMake Error at CMP0039-NEW.cmake:7 \(target_link_libraries\):
Utility target "utility" must not be used as the target of a
target_link_libraries call.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
build.cmake:3 \(include\)
......@@ -7,4 +7,4 @@
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$
build.cmake:3 \(include\)$
......@@ -6,5 +6,5 @@ CMake Warning \(dev\) at CMP0039-WARN.cmake:5 \(target_link_libraries\):
Utility target "utility" should not be used as the target of a
target_link_libraries call.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
build.cmake:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
......@@ -6,5 +6,5 @@ CMake Warning \(dev\) at CMP0046-Duplicate.cmake:5 \(add_dependencies\):
The dependency target "ctgt_no_exist" of target "dummy" does not exist.
Call Stack \(most recent call first\):
CMP0046-Duplicate.cmake:8 \(add_dep\)
CMakeLists.txt:3 \(include\)
build.cmake:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Error at CMP0046-NEW-missing-dependency.cmake:4 \(add_dependencies\):
The dependency target "bar" of target "foo" does not exist.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
build.cmake:3 \(include\)
......@@ -7,4 +7,4 @@
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$
build.cmake:3 \(include\)$
......@@ -7,4 +7,4 @@
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$
build.cmake:3 \(include\)$
......@@ -5,5 +5,5 @@ CMake Warning \(dev\) at CMP0046-WARN-missing-dependency.cmake:2 \(add_dependenc
+
The dependency target "bar" of target "foo" does not exist.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
build.cmake:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
......@@ -7,4 +7,4 @@
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$
build.cmake:3 \(include\)$
......@@ -7,7 +7,7 @@ CMake Warning \(dev\) at CMP0054-WARN.cmake:3 \(if\):
Quoted variables like "FOO" will no longer be dereferenced when the policy
is set to NEW. Since the policy is not set the OLD behavior will be used.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
build.cmake:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
+
CMake Warning \(dev\) at CMP0054-WARN.cmake:5 \(elseif\):
......@@ -19,5 +19,5 @@ CMake Warning \(dev\) at CMP0054-WARN.cmake:5 \(elseif\):
Quoted variables like "FOO" will no longer be dereferenced when the policy
is set to NEW. Since the policy is not set the OLD behavior will be used.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
build.cmake:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
......@@ -8,7 +8,7 @@ CMake Warning \(dev\) at CMP0054-duplicate-warnings.cmake:4 \(if\):
is set to NEW. Since the policy is not set the OLD behavior will be used.
Call Stack \(most recent call first\):
CMP0054-duplicate-warnings.cmake:8 \(generate_warning\)
CMakeLists.txt:3 \(include\)
build.cmake:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning \(dev\) at CMP0054-duplicate-warnings.cmake:11 \(if\):
......@@ -20,5 +20,5 @@ CMake Warning \(dev\) at CMP0054-duplicate-warnings.cmake:11 \(if\):
Quoted variables like "FOO" will no longer be dereferenced when the policy
is set to NEW. Since the policy is not set the OLD behavior will be used.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
build.cmake:3 \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
......@@ -5,4 +5,4 @@ CMake Error at CMP0054-keywords-NEW.cmake:23 \(if\):
Unknown arguments specified
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
build.cmake:3 \(include\)
......@@ -7,4 +7,4 @@
specific short-term circumstances. Projects should be ported to the NEW
behavior and not rely on setting a policy to OLD.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)$
build.cmake:3 \(include\)$
This diff is collapsed.