Skip to content

Commit

Permalink
[test] do not link with yaml-cpp or libyaml
Browse files Browse the repository at this point in the history
  • Loading branch information
biojppm committed Dec 25, 2021
1 parent 8a624dc commit ae52a6f
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 52 deletions.
17 changes: 0 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
23 changes: 21 additions & 2 deletions bm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion bm/bm_parse.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <ryml.hpp>
#include <ryml_std.hpp>
#include <c4/fs/fs.hpp>
#include "../test/libyaml.hpp"
#include "./libyaml.hpp"

#include <vector>
#include <iostream>
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion changelog/current.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
Tree expected = parse("{keyval0: val0, keyval1: {}, keyval2: []}");
assert(emitrs<std::string>(t) == emitrs<std::string>(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))
4 changes: 2 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 4 additions & 10 deletions test/test_case.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#ifndef _TEST_CASE_HPP_
#define _TEST_CASE_HPP_

#include <vector>

#include "./libyaml.hpp"

#include "c4/std/vector.hpp"
#include "c4/std/string.hpp"
#include <c4/yml/yml.hpp>
#include <gtest/gtest.h>
#include <functional>
Expand Down Expand Up @@ -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;


Expand Down
2 changes: 1 addition & 1 deletion test/test_double_quoted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions test/test_github_issues.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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"(
Expand Down
12 changes: 6 additions & 6 deletions test/test_plain_scalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand All @@ -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 -
Expand All @@ -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'.
Expand All @@ -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'.
Expand Down Expand Up @@ -767,15 +767,15 @@ 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
)",
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
Expand Down
4 changes: 2 additions & 2 deletions test/test_scalar_names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
),
Expand All @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion test/test_simple_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions test/test_simple_seq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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!
)",
Expand Down

0 comments on commit ae52a6f

Please sign in to comment.