Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download test data from an external source during build #1588

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ benchmarks/files/numbers/*.json
cmake-build-debug

test/test-*
test/data
/.vs
20 changes: 20 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -97,6 +99,18 @@ if(MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /bigobj")
endif()

if(NOT DEFINED ENV{LGTM_WORKSPACE})
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 ""
)
endif()

#############################################################################
# one executable for each unit test file
#############################################################################
Expand All @@ -107,6 +121,11 @@ foreach(file ${files})
string(REGEX REPLACE "unit-([^$]+)" "test-\\1" testcase ${file_basename})

add_executable(${testcase} $<TARGET_OBJECTS:doctest_main> ${file})

if(NOT DEFINED ENV{LGTM_WORKSPACE})
add_dependencies(${testcase} ExternalTestData)
endif()

target_compile_definitions(${testcase} PRIVATE
DOCTEST_CONFIG_SUPER_FAST_ASSERTS
)
Expand Down Expand Up @@ -148,3 +167,4 @@ endforeach()
add_subdirectory(cmake_import)
add_subdirectory(cmake_import_minver)
add_subdirectory(cmake_add_subdirectory)

15 changes: 14 additions & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ OBJECTS = $(SOURCES:.cpp=.o)

TESTCASES = $(patsubst src/unit-%.cpp,test-%,$(wildcard src/unit-*.cpp))


##############################################################################
# external test data
##############################################################################

EXTERNAL_DATA_URL = https://github.com/nickaein/nlohmann-json-testdata.git
EXTERNAL_DATA_TAG = 310048a5c34195b935f8062c53f30f3253fc5f50
EXTERNAL_DATA_DIR = data

external_data:
@test -d $(EXTERNAL_DATA_DIR) || (echo "Downloading test data..." && git clone $(EXTERNAL_DATA_URL) $(EXTERNAL_DATA_DIR) && cd $@ && git checkout $(EXTERNAL_DATA_TAG) && cd ..) || exit 1;


##############################################################################
# main rules
##############################################################################
Expand Down Expand Up @@ -82,7 +95,7 @@ test-%: src/unit-%.o src/unit.o ../single_include/nlohmann/json.hpp thirdparty/d

TEST_PATTERN ?= "*"
TEST_PREFIX = ""
check: $(OBJECTS) $(TESTCASES)
check: external_data $(OBJECTS) $(TESTCASES)
@cd .. ; for testcase in $(TESTCASES); do echo "Executing $$testcase..."; $(TEST_PREFIX)test/$$testcase $(TEST_PATTERN) || exit 1; done


Expand Down
22 changes: 0 additions & 22 deletions test/data/big-list-of-naughty-strings/LICENSE

This file was deleted.

496 changes: 0 additions & 496 deletions test/data/big-list-of-naughty-strings/blns.json

This file was deleted.

1 change: 0 additions & 1 deletion test/data/cbor_regression/test01

This file was deleted.

Binary file removed test/data/cbor_regression/test02
Binary file not shown.
Binary file removed test/data/cbor_regression/test03
Binary file not shown.
Binary file removed test/data/cbor_regression/test04
Binary file not shown.
Binary file removed test/data/cbor_regression/test05
Binary file not shown.
Binary file removed test/data/cbor_regression/test06
Binary file not shown.
Binary file removed test/data/cbor_regression/test07
Binary file not shown.
Binary file removed test/data/cbor_regression/test08
Binary file not shown.
Binary file removed test/data/cbor_regression/test09
Binary file not shown.
1 change: 0 additions & 1 deletion test/data/cbor_regression/test10

This file was deleted.

Binary file removed test/data/cbor_regression/test11
Binary file not shown.
Binary file removed test/data/cbor_regression/test12
Binary file not shown.
Binary file removed test/data/cbor_regression/test13
Binary file not shown.
Binary file removed test/data/cbor_regression/test14
Binary file not shown.
Binary file removed test/data/cbor_regression/test15
Binary file not shown.
Binary file removed test/data/cbor_regression/test16
Binary file not shown.
Binary file removed test/data/cbor_regression/test17
Binary file not shown.
Binary file removed test/data/cbor_regression/test18
Binary file not shown.
Binary file removed test/data/cbor_regression/test19
Binary file not shown.
Binary file removed test/data/cbor_regression/test20
Binary file not shown.
Binary file removed test/data/cbor_regression/test21
Binary file not shown.
75 changes: 0 additions & 75 deletions test/data/json-patch-tests/README.md

This file was deleted.

Loading