diff options
| author | Mingli Yu <mingli.yu@windriver.com> | 2023-11-10 19:52:40 +0800 |
|---|---|---|
| committer | Khem Raj <raj.khem@gmail.com> | 2023-11-10 09:13:40 -0800 |
| commit | 013b4d50432a3eba08a9cb54b9edf6b25a6378a8 (patch) | |
| tree | 588cd7f66076ecc80c29adcd8bddf7ade8759944 /meta-oe/recipes-devtools/nlohmann-json/files | |
| parent | e76ffb220aceac16bee1928bd3739a347414ccee (diff) | |
| download | meta-openembedded-013b4d50432a3eba08a9cb54b9edf6b25a6378a8.tar.gz | |
nlohmann-json: Add ptest support
* Backport 2 patches [1] [2] to fix the build failure under tests dir.
* Fetch the test data during do_fetch phase to avoid internet access
during test as some tests need test data.
# ./run-ptest
PASS: test-algorithms_cpp11
PASS: test-allocator_cpp11
PASS: test-alt-string_cpp11
PASS: test-assert_macro_cpp11
PASS: test-binary_formats_cpp11
[snip]
PASS: test-unicode5_cpp11
PASS: test-user_defined_input_cpp11
PASS: test-windows_h_cpp11
PASS: test-wstring_cpp11
[1] https://github.com/nlohmann/json/commit/6cec5aefc97ad219b6fd5a4132f88f7c8f6800ee
[2] https://github.com/nlohmann/json/commit/660d0b58565073975d6f5d94365d6cbf150a4cf8
Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-oe/recipes-devtools/nlohmann-json/files')
3 files changed, 104 insertions, 0 deletions
diff --git a/meta-oe/recipes-devtools/nlohmann-json/files/0001-custom-allocators-define-missing-rebind-type-3895.patch b/meta-oe/recipes-devtools/nlohmann-json/files/0001-custom-allocators-define-missing-rebind-type-3895.patch new file mode 100644 index 0000000000..d964586c1c --- /dev/null +++ b/meta-oe/recipes-devtools/nlohmann-json/files/0001-custom-allocators-define-missing-rebind-type-3895.patch | |||
| @@ -0,0 +1,61 @@ | |||
| 1 | From 6cec5aefc97ad219b6fd5a4132f88f7c8f6800ee Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Sergei Trofimovich <slyich@gmail.com> | ||
| 3 | Date: Wed, 8 Mar 2023 11:31:56 +0000 | ||
| 4 | Subject: [PATCH] custom allocators: define missing 'rebind' type (#3895) | ||
| 5 | |||
| 6 | Upstream-Status: Backport [https://github.com/nlohmann/json/commit/6cec5aefc97ad219b6fd5a4132f88f7c8f6800ee] | ||
| 7 | |||
| 8 | Signed-off-by: Mingli Yu <mingli.yu@windriver.com> | ||
| 9 | --- | ||
| 10 | tests/src/unit-allocator.cpp | 9 +++++++++ | ||
| 11 | tests/src/unit-regression2.cpp | 9 +++++++++ | ||
| 12 | 2 files changed, 18 insertions(+) | ||
| 13 | |||
| 14 | diff --git a/tests/src/unit-allocator.cpp b/tests/src/unit-allocator.cpp | ||
| 15 | index 76e3b03f..f2e63552 100644 | ||
| 16 | --- a/tests/src/unit-allocator.cpp | ||
| 17 | +++ b/tests/src/unit-allocator.cpp | ||
| 18 | @@ -20,11 +20,20 @@ struct bad_allocator : std::allocator<T> | ||
| 19 | { | ||
| 20 | using std::allocator<T>::allocator; | ||
| 21 | |||
| 22 | + bad_allocator() = default; | ||
| 23 | + template<class U> bad_allocator(const bad_allocator<U>& /*unused*/) { } | ||
| 24 | + | ||
| 25 | template<class... Args> | ||
| 26 | void construct(T* /*unused*/, Args&& ... /*unused*/) | ||
| 27 | { | ||
| 28 | throw std::bad_alloc(); | ||
| 29 | } | ||
| 30 | + | ||
| 31 | + template <class U> | ||
| 32 | + struct rebind | ||
| 33 | + { | ||
| 34 | + using other = bad_allocator<U>; | ||
| 35 | + }; | ||
| 36 | }; | ||
| 37 | } // namespace | ||
| 38 | |||
| 39 | diff --git a/tests/src/unit-regression2.cpp b/tests/src/unit-regression2.cpp | ||
| 40 | index 2bb9b32e..dbafb436 100644 | ||
| 41 | --- a/tests/src/unit-regression2.cpp | ||
| 42 | +++ b/tests/src/unit-regression2.cpp | ||
| 43 | @@ -189,6 +189,15 @@ class my_allocator : public std::allocator<T> | ||
| 44 | { | ||
| 45 | public: | ||
| 46 | using std::allocator<T>::allocator; | ||
| 47 | + | ||
| 48 | + my_allocator() = default; | ||
| 49 | + template<class U> my_allocator(const my_allocator<U>& /*unused*/) { } | ||
| 50 | + | ||
| 51 | + template <class U> | ||
| 52 | + struct rebind | ||
| 53 | + { | ||
| 54 | + using other = my_allocator<U>; | ||
| 55 | + }; | ||
| 56 | }; | ||
| 57 | |||
| 58 | ///////////////////////////////////////////////////////////////////// | ||
| 59 | -- | ||
| 60 | 2.25.1 | ||
| 61 | |||
diff --git a/meta-oe/recipes-devtools/nlohmann-json/files/0001-tests-unit-iterators2-use-std-ranges-equals-for-rang.patch b/meta-oe/recipes-devtools/nlohmann-json/files/0001-tests-unit-iterators2-use-std-ranges-equals-for-rang.patch new file mode 100644 index 0000000000..463912e4b6 --- /dev/null +++ b/meta-oe/recipes-devtools/nlohmann-json/files/0001-tests-unit-iterators2-use-std-ranges-equals-for-rang.patch | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | From 660d0b58565073975d6f5d94365d6cbf150a4cf8 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: =?UTF-8?q?Arsen=20Arsenovi=C4=87?= <arsen@aarsen.me> | ||
| 3 | Date: Sun, 5 Mar 2023 14:11:22 +0100 | ||
| 4 | Subject: [PATCH] tests/unit-iterators2: use std::ranges::equals for range | ||
| 5 | comparisons (#3950) | ||
| 6 | |||
| 7 | Closes https://github.com/nlohmann/json/issues/3927 | ||
| 8 | |||
| 9 | Upstream-Status: Backport [https://github.com/nlohmann/json/commit/660d0b58565073975d6f5d94365d6cbf150a4cf8] | ||
| 10 | |||
| 11 | Signed-off-by: Mingli Yu <mingli.yu@windriver.com> | ||
| 12 | --- | ||
| 13 | tests/src/unit-iterators2.cpp | 2 +- | ||
| 14 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
| 15 | |||
| 16 | diff --git a/tests/src/unit-iterators2.cpp b/tests/src/unit-iterators2.cpp | ||
| 17 | index 27926084..72a5d9dc 100644 | ||
| 18 | --- a/tests/src/unit-iterators2.cpp | ||
| 19 | +++ b/tests/src/unit-iterators2.cpp | ||
| 20 | @@ -943,7 +943,7 @@ TEST_CASE("iterators 2") | ||
| 21 | json j_expected{5, 4, 3, 2, 1}; | ||
| 22 | |||
| 23 | auto reversed = j | std::views::reverse; | ||
| 24 | - CHECK(reversed == j_expected); | ||
| 25 | + CHECK(std::ranges::equal(reversed, j_expected)); | ||
| 26 | } | ||
| 27 | |||
| 28 | SECTION("transform") | ||
| 29 | -- | ||
| 30 | 2.25.1 | ||
| 31 | |||
diff --git a/meta-oe/recipes-devtools/nlohmann-json/files/run-ptest b/meta-oe/recipes-devtools/nlohmann-json/files/run-ptest new file mode 100755 index 0000000000..2f00267d50 --- /dev/null +++ b/meta-oe/recipes-devtools/nlohmann-json/files/run-ptest | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | cd tests | ||
| 4 | for atest in test-* ; do | ||
| 5 | rm -rf tests.log | ||
| 6 | ./${atest} > tests.log 2>&1 | ||
| 7 | if [ $? = 0 ] ; then | ||
| 8 | echo "PASS: ${atest}" | ||
| 9 | else | ||
| 10 | echo "FAIL: ${atest}" | ||
| 11 | fi | ||
| 12 | done | ||
