From 7c33ab467b443a7001d6ea5449645fe58b17936a Mon Sep 17 00:00:00 2001 From: Isaac Nickaein Date: Sun, 28 Apr 2019 22:06:47 +0430 Subject: [PATCH] Download test data as external project in CMake --- .gitignore | 1 + test/CMakeLists.txt | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/.gitignore b/.gitignore index 086e855c0..a35388477 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,5 @@ benchmarks/files/numbers/*.json cmake-build-debug test/test-* +test/data /.vs diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b73dfc9ad..6cd996f1f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,3 +1,5 @@ +include(ExternalProject) + option(JSON_Sanitizer "Build test suite with Clang sanitizer" OFF) option(JSON_Valgrind "Execute test suite with Valgrind" OFF) option(JSON_NoExceptions "Build test suite without exceptions" OFF) @@ -97,6 +99,16 @@ if(MSVC) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj") endif() +ExternalProject_Add(ExternalTestData + GIT_REPOSITORY https://github.com/nickaein/nlohmann-json-testdata.git + GIT_TAG 310048a5c34195b935f8062c53f30f3253fc5f50 + SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" +) + ############################################################################# # one executable for each unit test file ############################################################################# @@ -107,6 +119,8 @@ foreach(file ${files}) string(REGEX REPLACE "unit-([^$]+)" "test-\\1" testcase ${file_basename}) add_executable(${testcase} $ ${file}) + add_dependencies(${testcase} ExternalTestData) + target_compile_definitions(${testcase} PRIVATE DOCTEST_CONFIG_SUPER_FAST_ASSERTS ) @@ -148,3 +162,4 @@ endforeach() add_subdirectory(cmake_import) add_subdirectory(cmake_import_minver) add_subdirectory(cmake_add_subdirectory) +