diff options
Diffstat (limited to 'Tests')
33 files changed, 415 insertions, 18 deletions
diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt index d1a1df5..9f09185 100644 --- a/Tests/CMakeLib/CMakeLists.txt +++ b/Tests/CMakeLib/CMakeLists.txt @@ -12,6 +12,7 @@ set(CMakeLib_TESTS testXMLParser testXMLSafe testFindPackageCommand + testUVRAII ) set(testRST_ARGS ${CMAKE_CURRENT_SOURCE_DIR}) @@ -31,6 +32,9 @@ create_test_sourcelist(CMakeLib_TEST_SRCS CMakeLibTests.cxx ${CMakeLib_TESTS}) add_executable(CMakeLibTests ${CMakeLib_TEST_SRCS}) target_link_libraries(CMakeLibTests CMakeLib) +set_property(TARGET CMakeLibTests PROPERTY C_CLANG_TIDY "") +set_property(TARGET CMakeLibTests PROPERTY CXX_CLANG_TIDY "") + add_executable(testEncoding testEncoding.cxx) target_link_libraries(testEncoding cmsys) diff --git a/Tests/CMakeLib/testUVRAII.cxx b/Tests/CMakeLib/testUVRAII.cxx new file mode 100644 index 0000000..44def25 --- /dev/null +++ b/Tests/CMakeLib/testUVRAII.cxx @@ -0,0 +1,181 @@ +#include "cmUVHandlePtr.h" + +#include <algorithm> +#include <chrono> +#include <iostream> +#include <thread> + +#include "cm_uv.h" + +static void signal_reset_fn(uv_async_t* handle) +{ + auto ptr = static_cast<cm::uv_async_ptr*>(handle->data); + ptr->reset(); +} + +// A common pattern is to use an async signal to shutdown the server. +static bool testAsyncShutdown() +{ + uv_loop_t Loop; + auto err = uv_loop_init(&Loop); + if (err != 0) { + std::cerr << "Could not init loop" << std::endl; + return false; + } + + { + cm::uv_async_ptr signal; + signal.init(Loop, &signal_reset_fn, &signal); + + std::thread([&] { + std::this_thread::sleep_for(std::chrono::seconds(2)); + signal.send(); + }).detach(); + + if (uv_run(&Loop, UV_RUN_DEFAULT) != 0) { + std::cerr << "Unclean exit state in testAsyncDtor" << std::endl; + return false; + } + + if (signal.get()) { + std::cerr << "Loop exited with signal not being cleaned up" << std::endl; + return false; + } + } + + uv_loop_close(&Loop); + + return true; +} + +static void signal_fn(uv_async_t*) +{ +} + +// Async dtor is sort of a pain; since it locks a mutex we must be sure its +// dtor always calls reset otherwise the mutex is deleted then locked. +static bool testAsyncDtor() +{ + uv_loop_t Loop; + auto err = uv_loop_init(&Loop); + if (err != 0) { + std::cerr << "Could not init loop" << std::endl; + return false; + } + + { + cm::uv_async_ptr signal; + signal.init(Loop, signal_fn); + } + + if (uv_run(&Loop, UV_RUN_DEFAULT) != 0) { + std::cerr << "Unclean exit state in testAsyncDtor" << std::endl; + return false; + } + + uv_loop_close(&Loop); + + return true; +} + +// Async needs a relatively stateful deleter; make sure that is properly +// accounted for and doesn't try to hold on to invalid state when it is +// moved +static bool testAsyncMove() +{ + uv_loop_t Loop; + auto err = uv_loop_init(&Loop); + if (err != 0) { + std::cerr << "Could not init loop" << std::endl; + return false; + } + + { + cm::uv_async_ptr signal; + { + cm::uv_async_ptr signalTmp; + signalTmp.init(Loop, signal_fn); + signal = std::move(signalTmp); + } + } + + if (uv_run(&Loop, UV_RUN_DEFAULT) != 0) { + std::cerr << "Unclean exit state in testAsyncDtor" << std::endl; + return false; + } + + uv_loop_close(&Loop); + return true; +} + +// When a type is castable to another uv type (pipe -> stream) here, +// and the deleter is convertible as well, we should allow moves from +// one type to the other. +static bool testCrossAssignment() +{ + uv_loop_t Loop; + auto err = uv_loop_init(&Loop); + if (err != 0) { + std::cerr << "Could not init loop" << std::endl; + return false; + } + + { + cm::uv_pipe_ptr pipe; + pipe.init(Loop, 0); + + cm::uv_stream_ptr stream = std::move(pipe); + if (pipe.get()) { + std::cerr << "Move should be sure to invalidate the previous ptr" + << std::endl; + return false; + } + cm::uv_handle_ptr handle = std::move(stream); + if (stream.get()) { + std::cerr << "Move should be sure to invalidate the previous ptr" + << std::endl; + return false; + } + } + + if (uv_run(&Loop, UV_RUN_DEFAULT) != 0) { + std::cerr << "Unclean exit state in testCrossAssignment" << std::endl; + return false; + } + + uv_loop_close(&Loop); + return true; +} + +// This test can't fail at run time; but this makes sure we have all our move +// ctors created correctly. +static bool testAllMoves() +{ + using namespace cm; + struct allTypes + { + uv_stream_ptr _7; + uv_timer_ptr _8; + uv_tty_ptr _9; + uv_process_ptr _11; + uv_pipe_ptr _12; + uv_async_ptr _13; + uv_signal_ptr _14; + uv_handle_ptr _15; + }; + + allTypes a; + allTypes b(std::move(a)); + allTypes c = std::move(b); + return true; +}; + +int testUVRAII(int, char** const) +{ + if ((testAsyncShutdown() && + testAsyncDtor() & testAsyncMove() & testCrossAssignment() & + testAllMoves()) == 0) { + return -1; + } + return 0; +} diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 4a7b8c9..9507880 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -149,9 +149,7 @@ if(BUILD_TESTING) if(NOT CMake_TEST_EXTERNAL_CMAKE) add_subdirectory(CMakeLib) - if(CMake_TEST_SERVER_MODE) - add_subdirectory(CMakeServerLib) - endif() + add_subdirectory(CMakeServerLib) endif() add_subdirectory(CMakeOnly) add_subdirectory(RunCMake) @@ -1433,6 +1431,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(GoogleTest) endif() + if(CMake_TEST_FindIconv) + add_subdirectory(FindIconv) + endif() + if(CMake_TEST_FindICU) add_subdirectory(FindICU) endif() diff --git a/Tests/CMakeServerLib/CMakeLists.txt b/Tests/CMakeServerLib/CMakeLists.txt index f5351fd..5e1ad0c 100644 --- a/Tests/CMakeServerLib/CMakeLists.txt +++ b/Tests/CMakeServerLib/CMakeLists.txt @@ -12,6 +12,9 @@ create_test_sourcelist(CMakeLib_TEST_SRCS CMakeServerLibTests.cxx ${CMakeServerL add_executable(CMakeServerLibTests ${CMakeLib_TEST_SRCS}) target_link_libraries(CMakeServerLibTests CMakeLib CMakeServerLib) +SET_PROPERTY(TARGET CMakeServerLibTests PROPERTY C_CLANG_TIDY "") +SET_PROPERTY(TARGET CMakeServerLibTests PROPERTY CXX_CLANG_TIDY "") + foreach(test ${CMakeServerLib_TESTS}) add_test(CMakeServerLib.${test} CMakeServerLibTests ${test} ${${test}_ARGS}) endforeach() diff --git a/Tests/CMakeServerLib/testServerBuffering.cpp b/Tests/CMakeServerLib/testServerBuffering.cpp index 97be891..7330ead 100644 --- a/Tests/CMakeServerLib/testServerBuffering.cpp +++ b/Tests/CMakeServerLib/testServerBuffering.cpp @@ -1,7 +1,6 @@ #include "cmConnection.h" #include "cmServerConnection.h" #include <iostream> -#include <stddef.h> #include <string> #include <vector> @@ -51,8 +50,8 @@ int testServerBuffering(int, char** const) std::unique_ptr<cmConnectionBufferStrategy>(new cmServerBufferStrategy); std::vector<std::string> response; std::string rawBuffer; - for (size_t i = 0; i < fullMessage.size(); i++) { - rawBuffer += fullMessage[i]; + for (auto& messageChar : fullMessage) { + rawBuffer += messageChar; std::string packet = bufferingStrategy->BufferMessage(rawBuffer); do { if (!packet.empty() && packet != "\r\n") { diff --git a/Tests/FindIconv/CMakeLists.txt b/Tests/FindIconv/CMakeLists.txt new file mode 100644 index 0000000..b205b80 --- /dev/null +++ b/Tests/FindIconv/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindIconv.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindIconv/Test" + "${CMake_BINARY_DIR}/Tests/FindIconv/Test" + ${build_generator_args} + --build-project TestFindIconv + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindIconv/Test/CMakeLists.txt b/Tests/FindIconv/Test/CMakeLists.txt new file mode 100644 index 0000000..c59adb3 --- /dev/null +++ b/Tests/FindIconv/Test/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.10) +project(TestFindIconv CXX) +include(CTest) + +find_package(Iconv REQUIRED) + +add_executable(test_iconv_tgt main.cxx) +target_link_libraries(test_iconv_tgt Iconv::Iconv) +add_test(NAME test_iconv_tgt COMMAND test_iconv_tgt) + +add_executable(test_iconv_var main.cxx) +target_include_directories(test_iconv_var PRIVATE ${Iconv_INCLUDE_DIRS}) +target_link_libraries(test_iconv_var PRIVATE ${Iconv_LIBRARIES}) +add_test(NAME test_iconv_var COMMAND test_iconv_var) diff --git a/Tests/FindIconv/Test/main.cxx b/Tests/FindIconv/Test/main.cxx new file mode 100644 index 0000000..415ee37 --- /dev/null +++ b/Tests/FindIconv/Test/main.cxx @@ -0,0 +1,52 @@ +extern "C" { +#include <iconv.h> +} +#include <array> +#include <cstddef> +#include <cstdlib> +#include <iostream> +#include <string> +#include <system_error> + +class iconv_desc +{ +private: + iconv_t iconvd_; + +public: + iconv_desc(const std::string& tocode, const std::string& fromcode) + { + iconvd_ = iconv_open(tocode.c_str(), fromcode.c_str()); + if (iconvd_ == reinterpret_cast<iconv_t>(-1)) + throw std::system_error(errno, std::system_category()); + } + + ~iconv_desc() { iconv_close(iconvd_); } + + operator iconv_t() { return this->iconvd_; } +}; + +int main() +{ + try { + auto conv_d = iconv_desc{ "ISO-8859-1", "UTF-8" }; + auto from_str = std::array<char, 10>{ u8"a\xC3\xA4o\xC3\xB6u\xC3\xBC" }; + auto to_str = std::array<char, 7>{}; + + auto from_str_ptr = from_str.data(); + auto from_len = from_str.size(); + auto to_str_ptr = to_str.data(); + auto to_len = to_str.size(); + const auto iconv_ret = + iconv(conv_d, &from_str_ptr, &from_len, &to_str_ptr, &to_len); + if (iconv_ret == static_cast<std::size_t>(-1)) + throw std::system_error(errno, std::system_category()); + std::cout << '\'' << from_str.data() << "\' converted to \'" + << to_str.data() << '\'' << std::endl; + return EXIT_SUCCESS; + } catch (const std::system_error& ex) { + std::cerr << "ERROR: " << ex.code() << '\n' + << ex.code().message() << std::endl; + } + return EXIT_FAILURE; +} diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 83fd11d..5165970 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -258,8 +258,13 @@ add_custom_target(check-part4 ALL VERBATIM ) -add_executable(srcgenex srcgenex.c) -set_property(SOURCE srcgenex.c PROPERTY COMPILE_FLAGS "-DNAME=$<TARGET_PROPERTY:NAME>") +#----------------------------------------------------------------------------- +# Cover source file properties with generator expressions. +add_executable(srcgenex_flags srcgenex_flags.c) +set_property(SOURCE srcgenex_flags.c PROPERTY COMPILE_FLAGS "-DNAME=$<TARGET_PROPERTY:NAME>") + +add_executable(srcgenex_defs srcgenex_defs.c) +set_property(SOURCE srcgenex_defs.c PROPERTY COMPILE_DEFINITIONS NAME=$<TARGET_PROPERTY:NAME>) #----------------------------------------------------------------------------- # Cover test properties with generator expressions. diff --git a/Tests/GeneratorExpression/srcgenex.c b/Tests/GeneratorExpression/srcgenex_defs.c index 56d3c3f..883e631 100644 --- a/Tests/GeneratorExpression/srcgenex.c +++ b/Tests/GeneratorExpression/srcgenex_defs.c @@ -1,4 +1,4 @@ -int srcgenex(void) +int srcgenex_defs(void) { return 0; } diff --git a/Tests/GeneratorExpression/srcgenex_flags.c b/Tests/GeneratorExpression/srcgenex_flags.c new file mode 100644 index 0000000..3de2b12 --- /dev/null +++ b/Tests/GeneratorExpression/srcgenex_flags.c @@ -0,0 +1,12 @@ +int srcgenex_flags(void) +{ + return 0; +} + +int main(int argc, char* argv[]) +{ +#ifndef NAME +#error NAME not defined +#endif + return NAME(); +} diff --git a/Tests/RunCMake/Cpplint/C-error-Build-result.txt b/Tests/RunCMake/Cpplint/C-error-Build-result.txt index d197c91..573541a 100644 --- a/Tests/RunCMake/Cpplint/C-error-Build-result.txt +++ b/Tests/RunCMake/Cpplint/C-error-Build-result.txt @@ -1 +1 @@ -[^0] +0 diff --git a/Tests/RunCMake/Cpplint/C-error-launch-Build-result.txt b/Tests/RunCMake/Cpplint/C-error-launch-Build-result.txt index d197c91..573541a 100644 --- a/Tests/RunCMake/Cpplint/C-error-launch-Build-result.txt +++ b/Tests/RunCMake/Cpplint/C-error-launch-Build-result.txt @@ -1 +1 @@ -[^0] +0 diff --git a/Tests/RunCMake/Cpplint/CXX-error-Build-result.txt b/Tests/RunCMake/Cpplint/CXX-error-Build-result.txt index d197c91..573541a 100644 --- a/Tests/RunCMake/Cpplint/CXX-error-Build-result.txt +++ b/Tests/RunCMake/Cpplint/CXX-error-Build-result.txt @@ -1 +1 @@ -[^0] +0 diff --git a/Tests/RunCMake/Cpplint/CXX-error-launch-Build-result.txt b/Tests/RunCMake/Cpplint/CXX-error-launch-Build-result.txt index d197c91..573541a 100644 --- a/Tests/RunCMake/Cpplint/CXX-error-launch-Build-result.txt +++ b/Tests/RunCMake/Cpplint/CXX-error-launch-Build-result.txt @@ -1 +1 @@ -[^0] +0 diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test-missing-result.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test-missing-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test-missing-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-test-missing-stderr.txt b/Tests/RunCMake/GoogleTest/GoogleTest-test-missing-stderr.txt new file mode 100644 index 0000000..55a4a7a --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-test-missing-stderr.txt @@ -0,0 +1,2 @@ +Unable to find executable: timeout_test_NOT_BUILT +Errors while running CTest diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-timeout-result.txt b/Tests/RunCMake/GoogleTest/GoogleTest-timeout-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-timeout-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-timeout-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-timeout-stdout.txt new file mode 100644 index 0000000..8464c80 --- /dev/null +++ b/Tests/RunCMake/GoogleTest/GoogleTest-timeout-stdout.txt @@ -0,0 +1,7 @@ +( *|[0-9]+>)CMake Error at .*GoogleTestAddTests.cmake:[0-9]+ \(message\): +( *|[0-9]+>) Error running test executable. +?( *|[0-9]+>) +( *|[0-9]+>) Path: '.*timeout_test(\.exe)?' +( *|[0-9]+>) Result: Process terminated due to timeout +( *|[0-9]+>) Output: +( *|[0-9]+>) + diff --git a/Tests/RunCMake/GoogleTest/GoogleTest.cmake b/Tests/RunCMake/GoogleTest/GoogleTest.cmake index 58f4196..5e4b8ef 100644 --- a/Tests/RunCMake/GoogleTest/GoogleTest.cmake +++ b/Tests/RunCMake/GoogleTest/GoogleTest.cmake @@ -21,3 +21,9 @@ gtest_discover_tests( EXTRA_ARGS how now "\"brown\" cow" PROPERTIES LABELS TEST2 ) + +add_executable(timeout_test timeout_test.cpp) + +gtest_discover_tests( + timeout_test +) diff --git a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake index b79af26..73014d1 100644 --- a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake +++ b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake @@ -9,24 +9,45 @@ function(run_GoogleTest) endif() file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(GoogleTest) + run_cmake_command(GoogleTest-build ${CMAKE_COMMAND} --build . --config Debug + --target fake_gtest + ) + + set(RunCMake_TEST_OUTPUT_MERGE 1) + run_cmake_command(GoogleTest-timeout + ${CMAKE_COMMAND} + --build . + --config Debug + --target timeout_test ) + set(RunCMake_TEST_OUTPUT_MERGE 0) + run_cmake_command(GoogleTest-test1 ${CMAKE_CTEST_COMMAND} -C Debug -L TEST1 --no-label-summary ) + run_cmake_command(GoogleTest-test2 ${CMAKE_CTEST_COMMAND} -C Debug -L TEST2 --no-label-summary ) + + run_cmake_command(GoogleTest-test-missing + ${CMAKE_CTEST_COMMAND} + -C Debug + -R timeout + --no-label-summary + ) endfunction() run_GoogleTest() diff --git a/Tests/RunCMake/GoogleTest/timeout_test.cpp b/Tests/RunCMake/GoogleTest/timeout_test.cpp new file mode 100644 index 0000000..a8e5c1c --- /dev/null +++ b/Tests/RunCMake/GoogleTest/timeout_test.cpp @@ -0,0 +1,15 @@ +#if defined(_WIN32) +#include <windows.h> +#else +#include <unistd.h> +#endif + +int main() +{ +#if defined(_WIN32) + Sleep(10000); +#else + sleep(10); +#endif + return 0; +} diff --git a/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-stderr.txt b/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-stderr.txt index 8809f89..d5ee4f9 100644 --- a/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-stderr.txt +++ b/Tests/RunCMake/ObjectLibrary/LinkObjRHS1-stderr.txt @@ -1,6 +1,6 @@ CMake Error at LinkObjRHS1.cmake:3 \(target_link_libraries\): Target "AnObjLib" of type OBJECT_LIBRARY may not be linked into another - target. One may link only to STATIC or SHARED libraries, or to executables - with the ENABLE_EXPORTS property set. + target. One may link only to INTERFACE, STATIC or SHARED libraries, or to + executables with the ENABLE_EXPORTS property set. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index 6e7c2f3..7100b31 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -5,3 +5,4 @@ run_cmake(VsCustomProps) run_cmake(VsDebuggerWorkingDir) run_cmake(VsCSharpCustomTags) run_cmake(VsCSharpReferenceProps) +run_cmake(VsCSharpWithoutSources) diff --git a/Tests/RunCMake/VS10Project/VsCSharpWithoutSources-check.cmake b/Tests/RunCMake/VS10Project/VsCSharpWithoutSources-check.cmake new file mode 100644 index 0000000..90ae7c3 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCSharpWithoutSources-check.cmake @@ -0,0 +1,5 @@ +set(csProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.csproj") +if(NOT EXISTS "${csProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${csProjectFile} does not exist.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsCSharpWithoutSources.cmake b/Tests/RunCMake/VS10Project/VsCSharpWithoutSources.cmake new file mode 100644 index 0000000..5fdeaa0 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsCSharpWithoutSources.cmake @@ -0,0 +1,7 @@ +enable_language(CSharp) + +add_library(foo SHARED + "${CMAKE_CURRENT_LIST_FILE}") + +set_target_properties(foo PROPERTIES + LINKER_LANGUAGE CSharp) diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-result.txt b/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-stderr.txt b/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-stderr.txt new file mode 100644 index 0000000..46a294d --- /dev/null +++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions-stderr.txt @@ -0,0 +1,8 @@ +^CMake Error in CMakeLists.txt: + Xcode does not support per-config per-source COMPILE_DEFINITIONS: + + \$<\$<CONFIG:Debug>:MYDEBUG> + + specified for source: + + .*/Tests/RunCMake/XcodeProject/main.c$ diff --git a/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions.cmake b/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions.cmake new file mode 100644 index 0000000..f9df55f --- /dev/null +++ b/Tests/RunCMake/XcodeProject/PerConfigPerSourceDefinitions.cmake @@ -0,0 +1,3 @@ +enable_language(C) +add_executable(main main.c) +set_property(SOURCE main.c PROPERTY COMPILE_DEFINITIONS "$<$<CONFIG:Debug>:MYDEBUG>") diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index f730b83..7eb624c 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -19,6 +19,7 @@ if (NOT XCODE_VERSION VERSION_LESS 6) endif() run_cmake(PerConfigPerSourceFlags) +run_cmake(PerConfigPerSourceDefinitions) # Use a single build tree for a few tests without cleaning. diff --git a/Tests/RunCMake/interface_library/whitelist.cmake b/Tests/RunCMake/interface_library/whitelist.cmake index 98ef05c..bf64f01 100644 --- a/Tests/RunCMake/interface_library/whitelist.cmake +++ b/Tests/RunCMake/interface_library/whitelist.cmake @@ -4,3 +4,13 @@ add_library(iface INTERFACE) set_property(TARGET iface PROPERTY OUTPUT_NAME output) set_property(TARGET iface APPEND PROPERTY OUTPUT_NAME append) get_target_property(outname iface OUTPUT_NAME) + +# Properties starting with `_` are allowed. +set_property(TARGET iface PROPERTY "_custom_property" output) +set_property(TARGET iface APPEND PROPERTY "_custom_property" append) +get_target_property(outname iface "_custom_property") + +# Properties starting with a lowercase letter are allowed. +set_property(TARGET iface PROPERTY "custom_property" output) +set_property(TARGET iface APPEND PROPERTY "custom_property" append) +get_target_property(outname iface "custom_property") diff --git a/Tests/RunCMake/target_link_libraries/MixedSignature-stderr.txt b/Tests/RunCMake/target_link_libraries/MixedSignature-stderr.txt index a0c66db..c6237f4 100644 --- a/Tests/RunCMake/target_link_libraries/MixedSignature-stderr.txt +++ b/Tests/RunCMake/target_link_libraries/MixedSignature-stderr.txt @@ -1,5 +1,5 @@ CMake Error at MixedSignature.cmake:6 \(target_link_libraries\): - The PUBLIC or PRIVATE option must appear as the second argument, just after - the target name. + The INTERFACE, PUBLIC or PRIVATE option must appear as the second argument, + just after the target name. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/Server/cmakelib.py b/Tests/Server/cmakelib.py index 39e3618..6e8761a 100644 --- a/Tests/Server/cmakelib.py +++ b/Tests/Server/cmakelib.py @@ -100,6 +100,14 @@ def waitForRawMessage(cmakeCommand): return jsonPayload stdoutdata = stdoutdata[(end+len(']== "CMake Server" ==]')):] +# Python2 has no problem writing the output of encodes directly, +# but Python3 returns only 'int's for encode and so must be turned +# into bytes. We use the existence of 'to_bytes' on an int to +# determine which behavior is appropriate. It might be more clear +# to do this in the code which uses the flag, but introducing +# this lookup cost at every byte sent isn't ideal. +has_to_bytes = "to_bytes" in dir(10) + def writeRawData(cmakeCommand, content): writeRawData.counter += 1 payload = """ @@ -116,7 +124,25 @@ def writeRawData(cmakeCommand, content): if print_communication: printClient(content, "(Use \\r\\n:", rn, ")") - cmakeCommand.write(payload.encode('utf-8')) + # To stress test how cmake deals with fragmentation in the + # communication channel, we send only one byte at a time. + # Certain communication methods / platforms might still buffer + # it all into one message since its so close together, but in + # general this will catch places where we assume full buffers + # come in all at once. + encoded_payload = payload.encode('utf-8') + + # Python version 3+ can't write ints directly; but 'to_bytes' + # for int was only added in python 3.2. If this is a 3+ version + # of python without that conversion function; just write the whole + # thing out at once. + if sys.version_info[0] > 2 and not has_to_bytes: + cmakeCommand.write(encoded_payload) + else: + for c in encoded_payload: + if has_to_bytes: + c = c.to_bytes(1, byteorder='big') + cmakeCommand.write(c) writeRawData.counter = 0 |