diff --git a/CMakeLists.txt b/CMakeLists.txt index fedba4851..690e76d1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,27 +76,10 @@ c4_pack_project() # extern libraries, used only for testing/benchmarking if(RYML_BUILD_TESTS OR RYML_BUILD_BENCHMARKS) - set(ed ${CMAKE_CURRENT_BINARY_DIR}/subprojects) # casual ryml extern dir (these projects are not part of ryml and are downloaded and compiled on the fly) # these are used both for testing and benchmarking c4_require_subproject(c4fs REMOTE GIT_REPOSITORY https://github.com/biojppm/c4fs GIT_TAG master) - c4_require_subproject(libyaml REMOTE - GIT_REPOSITORY https://github.com/yaml/libyaml - GIT_TAG master - OVERRIDE BUILD_TESTING OFF - SET_FOLDER_TARGETS ext yaml) - c4_import_remote_proj(yaml-cpp ${ed}/yaml-cpp REMOTE - GIT_REPOSITORY https://github.com/jbeder/yaml-cpp - # the master branch regularly screws up on windows builds. - # so use fixed pre-validated commit hashes - GIT_TAG 587b24e2eedea1afa21d79419008ca5f7bda3bf4 - OVERRIDE YAML_CPP_BUILD_TESTS OFF YAML_CPP_BUILD_TOOLS OFF YAML_CPP_BUILD_CONTRIB OFF YAML_CPP_BUILD_INSTALL OFF - SET_FOLDER_TARGETS ext yaml-cpp format) - set(ryml_yaml_cpp_inc ${ed}/yaml-cpp/src/include) - if(MSVC) - target_compile_definitions(yaml-cpp PUBLIC -D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING) - endif() endif() c4_add_dev_targets() diff --git a/bm/CMakeLists.txt b/bm/CMakeLists.txt index 60b570d3b..899bae942 100644 --- a/bm/CMakeLists.txt +++ b/bm/CMakeLists.txt @@ -1,10 +1,29 @@ c4_setup_benchmarking() -# ----------------------------------------------------------------------------- -# json libs that will be compared with ryml (and the other yaml libs) +# thirdparty libs that will be compared with ryml set(_ed ${CMAKE_CURRENT_BINARY_DIR}/ext) # casual ryml extern dir (these projects are not part of ryml and are downloaded and compiled on the fly) +# libyaml +c4_require_subproject(libyaml REMOTE + GIT_REPOSITORY https://github.com/yaml/libyaml + GIT_TAG master + OVERRIDE BUILD_TESTING OFF + SET_FOLDER_TARGETS ext yaml) + +# yaml-cpp +c4_import_remote_proj(yaml-cpp ${_ed}/yaml-cpp REMOTE + GIT_REPOSITORY https://github.com/jbeder/yaml-cpp + # the master branch regularly screws up on windows builds. + # so use fixed pre-validated commit hashes + GIT_TAG 587b24e2eedea1afa21d79419008ca5f7bda3bf4 + OVERRIDE YAML_CPP_BUILD_TESTS OFF YAML_CPP_BUILD_TOOLS OFF YAML_CPP_BUILD_CONTRIB OFF YAML_CPP_BUILD_INSTALL OFF + SET_FOLDER_TARGETS ext yaml-cpp format) +set(ryml_yaml_cpp_inc ${_ed}/yaml-cpp/src/include) +if(MSVC) + target_compile_definitions(yaml-cpp PUBLIC -D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING) +endif() + # jsoncpp needs to be compiled c4_require_subproject(jsoncpp REMOTE GIT_REPOSITORY https://github.com/open-source-parsers/jsoncpp diff --git a/bm/bm_parse.cpp b/bm/bm_parse.cpp index 6d08f157e..6da869abf 100644 --- a/bm/bm_parse.cpp +++ b/bm/bm_parse.cpp @@ -1,7 +1,7 @@ #include #include #include -#include "../test/libyaml.hpp" +#include "./libyaml.hpp" #include #include diff --git a/test/libyaml.hpp b/bm/libyaml.hpp similarity index 100% rename from test/libyaml.hpp rename to bm/libyaml.hpp diff --git a/changelog/current.md b/changelog/current.md index 58c1d8e83..e90a37eb0 100644 --- a/changelog/current.md +++ b/changelog/current.md @@ -10,9 +10,10 @@ Tree expected = parse("{keyval0: val0, keyval1: {}, keyval2: []}"); assert(emitrs(t) == emitrs(expected)); ``` -- Add support for compilation with emscripten (WebAssembly+javascript) ([PR #173](https://github.com/biojppm/rapidyaml/pull/173)). +- Add support for compilation with emscripten (WebAssembly+javascript) ([PR #176](https://github.com/biojppm/rapidyaml/pull/176)). ### Fixes - Prefer passing `substr` and `csubstr` by value instead of const reference ([PR #171](https://github.com/biojppm/rapidyaml/pull/171)) - Fix [#173](https://github.com/biojppm/rapidyaml/issues/173): add alias target `ryml::ryml` ([PR #174](https://github.com/biojppm/rapidyaml/pull/174)) +- Speedup compilation of tests by removing linking with yaml-cpp and libyaml. ([PR #177](https://github.com/biojppm/rapidyaml/pull/177)) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 375200acd..5d08a4bf5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -24,9 +24,9 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL GNU) endif() endif() c4_add_library(ryml-_testlib LIBRARY_TYPE STATIC - SOURCES test_case.hpp test_case.cpp libyaml.hpp + SOURCES test_case.hpp test_case.cpp INC_DIRS ${CMAKE_CURRENT_LIST_DIR} ${ryml_yaml_cpp_inc} - LIBS ryml c4fs yaml yaml-cpp gtest + LIBS ryml c4fs gtest FOLDER test) if(RYML_DBG) target_compile_definitions(ryml-_testlib PUBLIC RYML_DBG) diff --git a/test/test_case.hpp b/test/test_case.hpp index 3b98e0ba6..abeba4c1b 100644 --- a/test/test_case.hpp +++ b/test/test_case.hpp @@ -1,10 +1,8 @@ #ifndef _TEST_CASE_HPP_ #define _TEST_CASE_HPP_ -#include - -#include "./libyaml.hpp" - +#include "c4/std/vector.hpp" +#include "c4/std/string.hpp" #include #include #include @@ -417,12 +415,8 @@ struct CaseNode //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- typedef enum { - IGNORE_LIBYAML_PARSE_FAIL = (1<<0), - IGNORE_YAMLCPP_PARSE_FAIL = (1<<1), - EXPECT_PARSE_ERROR = (1<<2), - RESOLVE_REFS = (1<<3), - IGNORE_THIRDPARTY_PARSE_FAIL = IGNORE_LIBYAML_PARSE_FAIL|IGNORE_YAMLCPP_PARSE_FAIL, - HAS_PARSE_ERROR = EXPECT_PARSE_ERROR|IGNORE_THIRDPARTY_PARSE_FAIL, + EXPECT_PARSE_ERROR = (1<<0), + RESOLVE_REFS = (1<<1), } TestCaseFlags_e; diff --git a/test/test_double_quoted.cpp b/test/test_double_quoted.cpp index 0229bf364..b2b6dc24a 100644 --- a/test/test_double_quoted.cpp +++ b/test/test_double_quoted.cpp @@ -374,7 +374,7 @@ R"("This is a key\nthat has multiple lines\n": and this is its value L{N(QK, "This is a key\nthat has multiple lines\n", "and this is its value")} ), -C("dquoted, example 2.1", IGNORE_LIBYAML_PARSE_FAIL|IGNORE_YAMLCPP_PARSE_FAIL, +C("dquoted, example 2.1", R"("This is a key that has multiple lines diff --git a/test/test_github_issues.cpp b/test/test_github_issues.cpp index d248f0e78..8246891cb 100644 --- a/test/test_github_issues.cpp +++ b/test/test_github_issues.cpp @@ -489,7 +489,7 @@ L{ } ), -C("github35/expected_error11", HAS_PARSE_ERROR, +C("github35/expected_error11", EXPECT_PARSE_ERROR, R"( # *segfault* // not anymore! - key1: true1 @@ -498,7 +498,7 @@ R"( LineCol(4, 1) ), -C("github35/expected_error12", HAS_PARSE_ERROR, +C("github35/expected_error12", EXPECT_PARSE_ERROR, R"( # *segfault* // not anymore! - key2: true2 @@ -507,7 +507,7 @@ R"( LineCol(4, 1) ), -C("github35/expected_error21", HAS_PARSE_ERROR, +C("github35/expected_error21", EXPECT_PARSE_ERROR, R"( # *segfault* // not anymore! - key1: true1 @@ -516,7 +516,7 @@ R"( LineCol(4, 15) ), -C("github35/expected_error22", HAS_PARSE_ERROR, +C("github35/expected_error22", EXPECT_PARSE_ERROR, R"( # *segfault* // not anymore! - key2: true2 @@ -525,7 +525,7 @@ R"( LineCol(4, 15) ), -C("github128/1", RESOLVE_REFS | HAS_PARSE_ERROR, "a: *invalid"), +C("github128/1", RESOLVE_REFS | EXPECT_PARSE_ERROR, "a: *invalid"), C("github128/2", RESOLVE_REFS/* | HAS_PARSE_ERROR*/, "*", N(DOCVAL, "*")), C("github129", RESOLVE_REFS, R"( diff --git a/test/test_plain_scalar.cpp b/test/test_plain_scalar.cpp index 1771e2c1b..ceacaa63f 100644 --- a/test/test_plain_scalar.cpp +++ b/test/test_plain_scalar.cpp @@ -662,7 +662,7 @@ R"( } ), -C("plain scalar, do not accept ': ' mid line", HAS_PARSE_ERROR, +C("plain scalar, do not accept ': ' mid line", EXPECT_PARSE_ERROR, R"(- Several lines of text, with special:characters, like:this-or-this - - and some "quotes" of various 'types'. @@ -671,7 +671,7 @@ R"(- Several lines of text, LineCol(4, 11) ), -C("plain scalar, do not accept ': ' start line", HAS_PARSE_ERROR, +C("plain scalar, do not accept ': ' start line", EXPECT_PARSE_ERROR, R"( - Several lines of text, with special:characters, like:this-or-this - @@ -682,7 +682,7 @@ R"( LineCol(6, 3) ), -C("plain scalar, do not accept ': ' at line end", HAS_PARSE_ERROR, +C("plain scalar, do not accept ': ' at line end", EXPECT_PARSE_ERROR, R"(- Several lines of text, with special:characters, like:this-or-this - - and some "quotes" of various 'types'. @@ -691,7 +691,7 @@ R"(- Several lines of text, LineCol(4, 36) ), -C("plain scalar, do not accept ':' at line end", HAS_PARSE_ERROR, +C("plain scalar, do not accept ':' at line end", EXPECT_PARSE_ERROR, R"(- Several lines of text, with special:characters, like:this-or-this - - and some "quotes" of various 'types'. @@ -767,7 +767,7 @@ and yet more, deindented } ), -C("plain scalar, explicit, early end, seq", HAS_PARSE_ERROR, +C("plain scalar, explicit, early end, seq", EXPECT_PARSE_ERROR, R"([ a plain scalar with several lines @@ -775,7 +775,7 @@ R"([ LineCol(4, 1) ), -C("plain scalar, explicit, early end, map", HAS_PARSE_ERROR, +C("plain scalar, explicit, early end, map", EXPECT_PARSE_ERROR, R"({foo: a plain scalar with several lines diff --git a/test/test_scalar_names.cpp b/test/test_scalar_names.cpp index 6bd805af5..ddc7c4829 100644 --- a/test/test_scalar_names.cpp +++ b/test/test_scalar_names.cpp @@ -59,7 +59,7 @@ L{_(a), _(b:b), _(c{c), _(cc{), _(c}c), _(cc}), _(c!c), _(cc!), _(.foo), _(.), } ), -C("funny names, seq expl", IGNORE_LIBYAML_PARSE_FAIL, +C("funny names, seq expl", R"([a, b, c, .foo, ., -a, +b, /b, :c, $g])", L{_(a), _(b), _(c), _(.foo), _(.), _(-a), _(+b), _(/b), _(:c), _($g)} ), @@ -83,7 +83,7 @@ L{__(a), __(b), __(c), __(.foo), __(.), __(-a), __(+b), __(/b), __(:c), __($g), N(QKV, "*", "*"), N(QKV, "*a", "*a")} ), -C("funny names, map expl", IGNORE_LIBYAML_PARSE_FAIL, +C("funny names, map expl", R"({a: a, b: b, c: c, .foo: .foo, .: ., -a: -a, +b: +b, /b: /b, :c: :c, $g: $g, '*': '*', '*a':'*a'})", L{__(a), __(b), __(c), __(.foo), __(.), __(-a), __(+b), __(/b), __(:c), __($g), diff --git a/test/test_simple_map.cpp b/test/test_simple_map.cpp index 485aeca2c..e69938c54 100644 --- a/test/test_simple_map.cpp +++ b/test/test_simple_map.cpp @@ -474,7 +474,7 @@ h }i: val }000 } ), -C("simple map expl, scalars with special chars, comma", IGNORE_YAMLCPP_PARSE_FAIL, +C("simple map expl, scalars with special chars, comma", R"({ a0,b0: val0,0000 c0,d0: val0, 0000 diff --git a/test/test_simple_seq.cpp b/test/test_simple_seq.cpp index 8375cbda8..da4843de8 100644 --- a/test/test_simple_seq.cpp +++ b/test/test_simple_seq.cpp @@ -531,28 +531,28 @@ L{ }), }), -C("simple seq, invalid character 1", HAS_PARSE_ERROR, +C("simple seq, invalid character 1", EXPECT_PARSE_ERROR, R"(- 0 # this is a foo } )", LineCol(2, 1) ), -C("simple seq, invalid character 2", HAS_PARSE_ERROR, +C("simple seq, invalid character 2", EXPECT_PARSE_ERROR, R"(- 0 # this is a foo ] )", LineCol(2, 1) ), -C("simple seq, invalid character 3", HAS_PARSE_ERROR, +C("simple seq, invalid character 3", EXPECT_PARSE_ERROR, R"(- 0 # this is a foo : )", LineCol(2, 1) ), -C("simple seq, invalid character 4", HAS_PARSE_ERROR, +C("simple seq, invalid character 4", EXPECT_PARSE_ERROR, R"(- 0 # this is a foo abcdef! )",