Run fewer redundant steps and configs in CI

This commit is contained in:
John Keiser 2020-04-16 17:49:54 -07:00
parent a8e892ba90
commit ff09b6c824
7 changed files with 257 additions and 180 deletions

View File

@ -7,231 +7,300 @@ executors:
- image: gcc:7 - image: gcc:7
environment: environment:
CXX: g++ CXX: g++
haswell-gcc7:
docker:
- image: gcc:7
environment:
CXX: g++
CMAKE_IMPLEMENTATION_FLAGS: -DSIMDJSON_IMPLEMENTATION_HASWELL=ON -DSIMDJSON_IMPLEMENTATION_WESTMERE=OFF -DSIMDJSON_IMPLEMENTATION_FALLBACK=OFF -DSIMDJSON_IMPLEMENTATION_ARM64=OFF
westmere-gcc7:
docker:
- image: gcc:7
environment:
CXX: g++
CMAKE_IMPLEMENTATION_FLAGS: -DSIMDJSON_IMPLEMENTATION_HASWELL=OFF -DSIMDJSON_IMPLEMENTATION_WESTMERE=ON -DSIMDJSON_IMPLEMENTATION_FALLBACK=OFF -DSIMDJSON_IMPLEMENTATION_ARM64=OFF
fallback-gcc7:
docker:
- image: gcc:7
environment:
CXX: g++
CMAKE_IMPLEMENTATION_FLAGS: -DSIMDJSON_IMPLEMENTATION_HASWELL=OFF -DSIMDJSON_IMPLEMENTATION_WESTMERE=OFF -DSIMDJSON_IMPLEMENTATION_FALLBACK=ON -DSIMDJSON_IMPLEMENTATION_ARM64=OFF
gcc8: gcc8:
docker: docker:
- image: gcc:8 - image: gcc:8
environment: environment:
CXX: g++ CXX: g++
haswell-gcc8:
docker:
- image: gcc:8
environment:
CXX: g++
CMAKE_IMPLEMENTATION_FLAGS: -DSIMDJSON_IMPLEMENTATION_HASWELL=ON -DSIMDJSON_IMPLEMENTATION_WESTMERE=OFF -DSIMDJSON_IMPLEMENTATION_FALLBACK=OFF -DSIMDJSON_IMPLEMENTATION_ARM64=OFF
gcc9: gcc9:
docker: docker:
- image: gcc:9 - image: gcc:9
environment: environment:
CXX: g++ CXX: g++
haswell-gcc9:
docker:
- image: gcc:9
environment:
CXX: g++
CMAKE_IMPLEMENTATION_FLAGS: -DSIMDJSON_IMPLEMENTATION_HASWELL=ON -DSIMDJSON_IMPLEMENTATION_WESTMERE=OFF -DSIMDJSON_IMPLEMENTATION_FALLBACK=OFF -DSIMDJSON_IMPLEMENTATION_ARM64=OFF
clang6: clang6:
docker: docker:
- image: ubuntu:18.04 - image: ubuntu:18.04
environment: environment:
CXX: clang++-6.0 CXX: clang++-6.0
haswell-clang6:
docker:
- image: ubuntu:18.04
environment:
CXX: clang++-6.0
CMAKE_IMPLEMENTATION_FLAGS: -DSIMDJSON_IMPLEMENTATION_HASWELL=ON -DSIMDJSON_IMPLEMENTATION_WESTMERE=OFF -DSIMDJSON_IMPLEMENTATION_FALLBACK=OFF -DSIMDJSON_IMPLEMENTATION_ARM64=OFF
westmere-clang6:
docker:
- image: ubuntu:18.04
environment:
CXX: clang++-6.0
CMAKE_IMPLEMENTATION_FLAGS: -DSIMDJSON_IMPLEMENTATION_HASWELL=OFF -DSIMDJSON_IMPLEMENTATION_WESTMERE=ON -DSIMDJSON_IMPLEMENTATION_FALLBACK=OFF -DSIMDJSON_IMPLEMENTATION_ARM64=OFF
fallback-clang6:
docker:
- image: ubuntu:18.04
environment:
CXX: clang++-6.0
CMAKE_IMPLEMENTATION_FLAGS: -DSIMDJSON_IMPLEMENTATION_HASWELL=OFF -DSIMDJSON_IMPLEMENTATION_WESTMERE=OFF -DSIMDJSON_IMPLEMENTATION_FALLBACK=ON -DSIMDJSON_IMPLEMENTATION_ARM64=OFF
# Reusable test commands (and initializer for clang 6) # Reusable test commands (and initializer for clang 6)
commands: commands:
init_clang6: init_clang6:
steps: steps:
- run: apt-get update -qq - run: apt-get update -qq
- run: apt-get install -y clang build-essential git - run: apt-get install -y clang build-essential git
make_test: make_test:
steps: steps:
- checkout - checkout
- run: make - run: make
- run: make amalgamate - run: make amalgamate
- run: ARCHFLAGS=-march=haswell make amalgamate # some users do this: https://github.com/lemire/simdjson/issues/444
- run: make test - run: make test
- run: make checkperf - run: make checkperf
- run: make clean
- run: ARCHFLAGS=-march=haswell make test # this breaks runtime dispatch, but see https://github.com/lemire/simdjson/issues/444... this is a code robustness test
- run: make clean
- run: EXTRAFLAGS=-DSIMDJSON_NO_COMPUTED_GOTO=true make test # this should run tests with computed gotos disabled
make_test_strict: # this version fails when a warning is detected.
steps:
- checkout
- run: EXTRAFLAGS=-Werror make
- run: EXTRAFLAGS=-Werror make amalgamate
- run: ARCHFLAGS=-march=haswell make amalgamate # some users do this: https://github.com/lemire/simdjson/issues/444
- run: EXTRAFLAGS=-Werror make quicktests
- run: make clean
cmake_simple_test: # this version just builds and test cmake_simple_test: # this version just builds and test
steps: steps:
- run: apt-get update -qq - run: apt-get update -qq
- run: apt-get install -y cmake - run: apt-get install -y cmake
- checkout - checkout
- run: cmake $CMAKE_TEST_FLAGS - run: cmake $CMAKE_FLAGS $CMAKE_IMPLEMENTATION_FLAGS
- run: make all - run: make all
- run: make test - run: ctest --output-on-failure
cmake_test: # this version builds, install, test and then verify from the installation cmake_test: # this version builds, install, test and then verify from the installation
steps: steps:
- run: apt-get update -qq - run: apt-get update -qq
- run: apt-get install -y cmake - run: apt-get install -y cmake
- checkout - checkout
- run: cmake $CMAKE_TEST_FLAGS -DCMAKE_INSTALL_PREFIX:PATH=destination - run: cmake $CMAKE_FLAGS $CMAKE_IMPLEMENTATION_FLAGS -DCMAKE_INSTALL_PREFIX:PATH=destination
- run: make all install - run: make all install
- run: make test - run: ctest --output-on-failure
- run: echo -e '#include <simdjson.h>\nint main(int argc,char**argv) {simdjson::dom::parser parser;simdjson::dom::element tweets = parser.load(argv[1]); }' > tmp.cpp && c++ -Idestination/include -Ldestination/lib -std=c++17 -Wl,-rpath,destination/lib -o linkandrun tmp.cpp -lsimdjson && ./linkandrun jsonexamples/twitter.json # we not only want cmake to build and run tests, but we want also a succesful installation from which we can build, link and run programs - run: echo -e '#include <simdjson.h>\nint main(int argc,char**argv) {simdjson::dom::parser parser;simdjson::dom::element tweets = parser.load(argv[1]); }' > tmp.cpp && c++ -Idestination/include -Ldestination/lib -std=c++17 -Wl,-rpath,destination/lib -o linkandrun tmp.cpp -lsimdjson && ./linkandrun jsonexamples/twitter.json # we not only want cmake to build and run tests, but we want also a succesful installation from which we can build, link and run programs
jobs: jobs:
gcc-avx-unthreaded: #
description: Build, run tests and check performance on GCC 7 and AVX 2 *without* threads # Generic
executor: gcc7 #
environment: { CMAKE_TEST_FLAGS: -DSIMDJSON_ENABLE_THREADS=OFF }
steps: [ cmake_test ]
gcc-avx-threaded:
description: Build, run tests and check performance on GCC 7 and AVX 2 with threads
executor: gcc7
environment: { CMAKE_TEST_FLAGS: -DSIMDJSON_ENABLE_THREADS=ON }
steps: [ cmake_test ]
clang-avx-unthreaded: # make (test and checkperf)
description: Build, run tests and check performance on Clang 6 and AVX 2 *without* threads gcc9:
executor: clang6 description: Build, run tests and check performance on GCC 7
environment: { CMAKE_TEST_FLAGS: -DSIMDJSON_ENABLE_THREADS=OFF }
steps: [ init_clang6, cmake_test ]
clang-avx-threaded:
description: Build, run tests and check performance on Clang 6 and AVX 2 with threads
executor: clang6
environment: { CMAKE_TEST_FLAGS: -DSIMDJSON_ENABLE_THREADS=ON }
steps: [ init_clang6, cmake_test ]
gcc-avx-noexcept:
description: Build, run tests and check performance on GCC 7 and AVX 2 *without* threads
executor: gcc7
environment: { CMAKE_TEST_FLAGS: -DSIMDJSON_DISABLE_EXCEPTIONS=ON }
steps: [ cmake_test ]
clang-avx-noexcept:
description: Build, run tests and check performance on Clang 6 and AVX 2 with threads
executor: clang6
environment: { CMAKE_TEST_FLAGS: -DSIMDJSON_DISABLE_EXCEPTIONS=ON }
steps: [ init_clang6, cmake_test ]
gcc9-avx:
description: Build, run tests and check performance on GCC 9 and AVX 2
executor: gcc9 executor: gcc9
steps: [ make_test_strict ] environment: { EXTRAFLAGS: -Werror }
gcc8-avx:
description: Build, run tests and check performance on GCC 8 and AVX 2
executor: gcc9
steps: [ make_test_strict ]
gcc-avx:
description: Build, run tests and check performance on GCC 7 and AVX 2
executor: gcc7
steps: [ make_test ] steps: [ make_test ]
gcc-avx-dynamic: clang6:
description: Build, run tests and check performance on GCC 7 and AVX 2 with a cmake dynamic build
executor: gcc7
environment: { CMAKE_TEST_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF }
steps: [ cmake_test ]
gcc-avx-static:
description: Build, run tests and check performance on GCC 7 and AVX 2 with a cmake static build
executor: gcc7
environment: { CMAKE_TEST_FLAGS: -DSIMDJSON_BUILD_STATIC=ON }
steps: [ cmake_test ]
gcc-avx-google-benchmarks:
description: Build, run tests and check performance on GCC 7 with google benchmarks enabled
executor: gcc7
environment: { CMAKE_TEST_FLAGS: -DSIMDJSON_GOOGLE_BENCHMARKS=ON }
steps: [ cmake_test ]
gcc-avx-sanitize:
description: Build, run tests and check performance on GCC 7 and AVX 2 with a cmake sanitize build
executor: gcc7
environment: { CMAKE_TEST_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE=ON }
steps: [ cmake_simple_test ]
gcc-sse:
description: Build, run tests and check performance on GCC 7 and SSE 4.2
executor: gcc7
environment: { ARCHFLAGS: -march=nehalem }
steps: [ make_test ]
gcc-sse-dynamic:
description: Build, run tests and check performance on GCC 7 and SSE 4.2 with a cmake dynamic build
executor: gcc7
environment: { CMAKE_TEST_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF }
steps: [ cmake_test ]
gcc-sse-static:
description: Build, run tests and check performance on GCC 7 and SSE 4.2 with a cmake static build
executor: gcc7
environment: { CMAKE_TEST_FLAGS: -DSIMDJSON_BUILD_STATIC=ON }
steps: [ cmake_test ]
gcc-sse-sanitize:
description: Build, run tests and check performance on GCC 7 and SSE 4.2 with a cmake sanitize build
executor: gcc7
environment: { CMAKE_TEST_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE=ON }
steps: [ cmake_simple_test ]
clang-avx:
description: Build, run tests and check performance on clang 6 and AVX 2 description: Build, run tests and check performance on clang 6 and AVX 2
executor: clang6 executor: clang6
environment: { EXTRAFLAGS: -Werror }
steps: [ init_clang6, make_test ] steps: [ init_clang6, make_test ]
clang-avx-dynamic: arch-haswell-gcc7:
description: Build, run tests and check performance on clang 6 and AVX 2 with a cmake dynamic build description: Build, run tests and check performance on GCC 7 with -march=haswell
executor: clang6 executor: gcc7
environment: { CMAKE_TEST_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF } environment: { ARCHFLAGS: -march=haswell }
steps: [ init_clang6, cmake_test ] steps: [ make_test ]
clang-avx-static: arch-nehalem-gcc7:
description: Build, run tests and check performance on clang 6 and AVX 2 with a cmake static build description: Build, run tests and check performance on GCC 7 with -march=nehalem
executor: clang6 executor: gcc7
environment: { CMAKE_TEST_FLAGS: -DSIMDJSON_BUILD_STATIC=ON }
steps: [ init_clang6, cmake_test ]
clang-avx-google-benchmarks:
description: Build, run tests and check performance on clang 6 with google benchmarks enabled
executor: clang6
environment: { CMAKE_TEST_FLAGS: -DSIMDJSON_GOOGLE_BENCHMARKS=ON }
steps: [ init_clang6, cmake_test ]
clang-avx-sanitize:
description: Build, run tests and check performance on clang 6 and AVX 2 with a cmake sanitize build
executor: clang6
environment: { CMAKE_TEST_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE=ON }
steps: [ init_clang6, cmake_simple_test ]
clang-sse:
description: Build, run tests and check performance on Clang 6 and SSE 4.2
executor: clang6
environment: { ARCHFLAGS: -march=nehalem } environment: { ARCHFLAGS: -march=nehalem }
steps: [ init_clang6, make_test ] steps: [ make_test ]
clang-sse-dynamic: no-computed-goto-gcc7:
description: Build, run tests and check performance on Clang 6 and SSE 4.2 with a cmake dynamic build description: Build, run tests and check performance on GCC 7 with -DSIMDJSON_NO_COMPUTED_GOTO=true
executor: gcc7
environment: { EXTRAFLAGS: -DSIMDJSON_NO_COMPUTED_GOTO=true }
steps: [ make_test ]
noexcept-gcc7:
description: Build and run tests on GCC 7 and AVX 2 with exceptions off
executor: gcc7
environment: { CMAKE_FLAGS: -DSIMDJSON_EXCEPTIONS=OFF }
steps: [ cmake_test ]
noexcept-clang6:
description: Build and run tests on GCC 7 and AVX 2 with exceptions off
executor: clang6 executor: clang6
environment: { CMAKE_TEST_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF } environment: { CMAKE_FLAGS: -DSIMDJSON_EXCEPTIONS=OFF }
steps: [ init_clang6, cmake_test ] steps: [ init_clang6, cmake_test ]
clang-sse-static:
description: Build, run tests and check performance on Clang 6 and SSE 4.2 with a cmake static build #
executor: clang6 # Haswell
environment: { CMAKE_TEST_FLAGS: -DSIMDJSON_BUILD_STATIC=ON } #
# static
haswell-gcc7:
description: Build and run tests on GCC 7 and AVX 2 with a cmake static build
executor: haswell-gcc7
environment: { CMAKE_FLAGS: -DSIMDJSON_GOOGLE_BENCHMARKS=ON }
steps: [ cmake_test ]
haswell-clang6:
description: Build and run tests on clang 6 and AVX 2 with a cmake static build
executor: haswell-clang6
environment: { CMAKE_FLAGS: -DSIMDJSON_GOOGLE_BENCHMARKS=ON }
steps: [ init_clang6, cmake_test ] steps: [ init_clang6, cmake_test ]
clang-sse-sanitize: haswell-gcc8:
description: Build, run tests and check performance on Clang 6 and SSE 4.2 with a cmake sanitize build description: Build and run tests on GCC 8 and AVX 2
executor: clang6 executor: haswell-gcc8
environment: { CMAKE_TEST_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE=ON } environment: { CMAKE_FLAGS: -DSIMDJSON_GOOGLE_BENCHMARKS=ON }
steps: [ cmake_test ]
haswell-gcc9:
description: Build and run tests on GCC 9 and AVX 2
executor: haswell-gcc9
environment: { EXTRAFLAGS: -DSIMDJSON_GOOGLE_BENCHMARKS=ON }
steps: [ cmake_test ]
# sanitize
haswell-sanitize-gcc7:
description: Build and run tests on GCC 7 and AVX 2 with a cmake sanitize build
executor: haswell-gcc7
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE=ON }
steps: [ cmake_simple_test ]
haswell-sanitize-clang6:
description: Build and run tests on clang 6 and AVX 2 with a cmake sanitize build
executor: haswell-clang6
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE=ON }
steps: [ init_clang6, cmake_simple_test ]
# dynamic
haswell-dynamic-gcc7:
description: Build and run tests on GCC 7 and AVX 2 with a cmake dynamic build
executor: haswell-gcc7
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF }
steps: [ cmake_test ]
haswell-dynamic-clang6:
description: Build and run tests on clang 6 and AVX 2 with a cmake dynamic build
executor: haswell-clang6
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF }
steps: [ init_clang6, cmake_test ]
# unthreaded
haswell-unthreaded-gcc7:
description: Build and run tests on GCC 7 and AVX 2 *without* threads
executor: haswell-gcc7
environment: { CMAKE_FLAGS: -DSIMDJSON_ENABLE_THREADS=OFF }
steps: [ cmake_test ]
haswell-unthreaded-clang6:
description: Build and run tests on Clang 6 and AVX 2 *without* threads
executor: haswell-clang6
environment: { CMAKE_FLAGS: -DSIMDJSON_ENABLE_THREADS=OFF }
steps: [ init_clang6, cmake_test ]
#
# Westmere
#
# static
westmere-gcc7:
description: Build and run tests on GCC 7 and SSE 4.2 with a cmake static build
executor: westmere-gcc7
environment: { CMAKE_FLAGS: -DSIMDJSON_GOOGLE_BENCHMARKS=ON }
steps: [ cmake_test ]
westmere-clang6:
description: Build and run tests on Clang 6 and SSE 4.2 with a cmake static build
executor: westmere-clang6
environment: { CMAKE_FLAGS: -DSIMDJSON_GOOGLE_BENCHMARKS=ON }
steps: [ init_clang6, cmake_test ]
# sanitize
westmere-sanitize-gcc7:
description: Build and run tests on GCC 7 and SSE 4.2 with a cmake sanitize build
executor: westmere-gcc7
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE=ON }
steps: [ cmake_simple_test ]
westmere-sanitize-clang6:
description: Build and run tests on Clang 6 and SSE 4.2 with a cmake sanitize build
executor: westmere-clang6
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE=ON }
steps: [ init_clang6, cmake_simple_test ]
#
# Fallback
#
# static
fallback-gcc7:
description: Build and run tests on GCC 7 and fallback implementation with a cmake static build
executor: fallback-gcc7
steps: [ cmake_test ]
fallback-clang6:
description: Build and run tests on Clang 6 and fallback implementation with a cmake static build
executor: fallback-clang6
environment: { CMAKE_FLAGS: -DSIMDJSON_GOOGLE_BENCHMARKS=ON }
steps: [ init_clang6, cmake_test ]
# sanitize
fallback-sanitize-gcc7:
description: Build and run tests on GCC 7 and fallback implementation with a cmake sanitize build
executor: fallback-gcc7
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE=ON }
steps: [ cmake_simple_test ]
fallback-sanitize-clang6:
description: Build and run tests on Clang 6 and fallback implementation with a cmake sanitize build
executor: fallback-clang6
environment: { CMAKE_FLAGS: -DSIMDJSON_BUILD_STATIC=OFF -DSIMDJSON_SANITIZE=ON }
steps: [ init_clang6, cmake_simple_test ] steps: [ init_clang6, cmake_simple_test ]
workflows: workflows:
version: 2.1 version: 2.1
build_and_test: build_and_test:
jobs: jobs:
- gcc-avx-noexcept - gcc9
- clang-avx-noexcept - haswell-gcc7
- gcc9-avx - westmere-gcc7
- gcc8-avx - fallback-gcc7
- gcc-avx
- gcc-avx-dynamic - clang6
- gcc-avx-static - haswell-clang6
- gcc-avx-google-benchmarks - westmere-clang6
- gcc-avx-sanitize - fallback-clang6
- gcc-sse
- gcc-sse-dynamic - haswell-dynamic-gcc7
- gcc-sse-static - haswell-dynamic-clang6
- gcc-sse-sanitize - haswell-unthreaded-gcc7
- clang-avx - haswell-unthreaded-clang6
- clang-avx-dynamic
- clang-avx-static - haswell-sanitize-gcc7
- clang-avx-google-benchmarks - haswell-sanitize-clang6
- clang-avx-sanitize - westmere-sanitize-gcc7
- clang-sse - westmere-sanitize-clang6
- clang-sse-dynamic - fallback-sanitize-gcc7
- clang-sse-static - fallback-sanitize-clang6
- clang-sse-sanitize
- gcc-avx-threaded - noexcept-gcc7
- gcc-avx-unthreaded - noexcept-clang6
- clang-avx-threaded - haswell-gcc8
- clang-avx-unthreaded - haswell-gcc9
- arch-haswell-gcc7
- arch-nehalem-gcc7
- no-computed-goto-gcc7
# TODO add windows: https://circleci.com/docs/2.0/configuration-reference/#windows # TODO add windows: https://circleci.com/docs/2.0/configuration-reference/#windows

1
.gitignore vendored
View File

@ -131,6 +131,7 @@ objs
/tests/allparserscheckfile /tests/allparserscheckfile
/tests/basictests /tests/basictests
/tests/errortests /tests/errortests
/tests/extracting_values_example
/tests/integer_tests /tests/integer_tests
/tests/jsoncheck /tests/jsoncheck
/tests/numberparsingcheck /tests/numberparsingcheck

View File

@ -145,7 +145,7 @@ add_subdirectory(benchmark)
# for fuzzing, read the comments in the fuzz/CMakeLists.txt file # for fuzzing, read the comments in the fuzz/CMakeLists.txt file
option(ENABLE_FUZZING "enable building the fuzzers" ON) option(ENABLE_FUZZING "enable building the fuzzers" ON)
if(ENABLE_FUZZING) if(ENABLE_FUZZING AND SIMDJSON_EXCEPTIONS)
add_subdirectory(fuzz) add_subdirectory(fuzz)
endif() endif()

View File

@ -30,7 +30,6 @@ if (NOT MSVC)
endif() endif()
endif() endif()
message(STATUS ${TEST_NAME})
add_test( add_test(
NAME ${TEST_NAME} NAME ${TEST_NAME}
COMMAND ${CMAKE_CXX_COMPILER} ${QUICKSTART_FLAGS} -I${PROJECT_SOURCE_DIR}/include -I${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/src/simdjson.cpp ${SOURCE_FILE} COMMAND ${CMAKE_CXX_COMPILER} ${QUICKSTART_FLAGS} -I${PROJECT_SOURCE_DIR}/include -I${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/src/simdjson.cpp ${SOURCE_FILE}

View File

@ -88,19 +88,20 @@ if(NOT (MSVC AND MSVC_VERSION LESS 1920))
TEST readme_examples TEST readme_examples
APPEND PROPERTY LABELS quicktests APPEND PROPERTY LABELS quicktests
) )
endif()
add_compile_test(readme_examples_noexceptions readme_examples_noexceptions.cpp quicktests)
add_compile_test(readme_examples11 readme_examples.cpp quicktests) add_compile_test(readme_examples11 readme_examples.cpp quicktests)
set_target_properties(readme_examples11 PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF) set_target_properties(readme_examples11 PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF)
if (!MSVC) if (!MSVC)
target_compile_options(readme_examples11 PRIVATE -Werror) target_compile_options(readme_examples11 PRIVATE -Werror)
endif()
endif() endif()
add_compile_test(readme_examples_noexceptions readme_examples_noexceptions.cpp quicktests)
add_compile_test(readme_examples_noexceptions11 readme_examples_noexceptions.cpp quicktests) add_compile_test(readme_examples_noexceptions11 readme_examples_noexceptions.cpp quicktests)
set_target_properties(readme_examples_noexceptions11 PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF) set_target_properties(readme_examples_noexceptions11 PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON CXX_EXTENSIONS OFF)
if (!MSVC) if (!MSVC)
target_compile_options(readme_examples11 PRIVATE -Werror) target_compile_options(readme_examples_noexceptions11 PRIVATE -Werror)
endif() endif()
# Compile tests that *should fail* # Compile tests that *should fail*

View File

@ -548,12 +548,17 @@ namespace parse_api_tests {
int count = 0; int count = 0;
for (auto [doc, error] : parser.load_many(AMAZON_CELLPHONES_NDJSON)) { for (auto [doc, error] : parser.load_many(AMAZON_CELLPHONES_NDJSON)) {
if (error) { cerr << error << endl; return false; } if (error) { cerr << error << endl; return false; }
if (!doc.is<dom::array>()) { cerr << "Document did not parse as an array" << endl; return false; }
auto arr = doc.get<dom::array>(); // let us get the array dom::array arr;
doc.get<dom::array>().tie(arr, error); // let us get the array
if (error) { cerr << error << endl; return false; }
if(arr.size() != 9) { cerr << "bad array size"<< endl; return false; } if(arr.size() != 9) { cerr << "bad array size"<< endl; return false; }
size_t c = 0; size_t c = 0;
for(auto v : arr) { c++; (void)v; } for(auto v : arr) { c++; (void)v; }
if(c != 9) { cerr << "mismatched array size"<< endl; return false; } if(c != 9) { cerr << "mismatched array size"<< endl; return false; }
count++; count++;
} }
if (count != 793) { cerr << "Expected 793 documents, but load_many loaded " << count << " documents." << endl; return false; } if (count != 793) { cerr << "Expected 793 documents, but load_many loaded " << count << " documents." << endl; return false; }

View File

@ -30,9 +30,11 @@ endfunction(add_dual_compile_test)
add_dual_compile_test(example_compiletest example_compiletest.cpp) add_dual_compile_test(example_compiletest example_compiletest.cpp)
add_dual_compile_test(dangling_parser_load dangling_parser_load.cpp) # These don't compile with exceptions off
add_dual_compile_test(dangling_parser_parse_uint8 dangling_parser_parse_uint8.cpp) if (SIMDJSON_EXCEPTIONS)
add_dual_compile_test(dangling_parser_parse_uchar dangling_parser_parse_uchar.cpp) add_dual_compile_test(dangling_parser_load dangling_parser_load.cpp)
add_dual_compile_test(dangling_parser_parse_stdstring dangling_parser_parse_stdstring.cpp) add_dual_compile_test(dangling_parser_parse_uint8 dangling_parser_parse_uint8.cpp)
add_dual_compile_test(dangling_parser_parse_padstring dangling_parser_parse_padstring.cpp) add_dual_compile_test(dangling_parser_parse_uchar dangling_parser_parse_uchar.cpp)
add_dual_compile_test(dangling_parser_parse_stdstring dangling_parser_parse_stdstring.cpp)
add_dual_compile_test(dangling_parser_parse_padstring dangling_parser_parse_padstring.cpp)
endif()