nlohmann-json: Add ptest support

* 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
PASS: test-allocator
PASS: test-alt-string
PASS: test-assert_macro
PASS: test-bson
PASS: test-byte_container_with_subtype
PASS: test-capacity
PASS: test-cbor
PASS: test-class_const_iterator
PASS: test-class_iterator
PASS: test-class_lexer
PASS: test-class_parser
PASS: test-comparison
PASS: test-concepts
PASS: test-constructor1
PASS: test-constructor2
PASS: test-convenience
PASS: test-conversions
PASS: test-conversions_cpp17
PASS: test-deserialization
PASS: test-diagnostics
PASS: test-disabled_exceptions
PASS: test-element_access1
PASS: test-element_access2
PASS: test-hash
PASS: test-inspection
PASS: test-items
PASS: test-items_cpp17
PASS: test-iterators1
PASS: test-iterators2
PASS: test-json_patch
PASS: test-json_pointer
PASS: test-large_json
PASS: test-merge_patch
PASS: test-meta
PASS: test-modifiers
PASS: test-msgpack
PASS: test-noexcept
PASS: test-ordered_json
PASS: test-ordered_map
PASS: test-pointer_access
PASS: test-readme
PASS: test-reference_access
PASS: test-regression1
PASS: test-regression1_cpp17
PASS: test-regression2
PASS: test-regression2_cpp17
PASS: test-serialization
PASS: test-testsuites
PASS: test-to_chars
PASS: test-ubjson
PASS: test-udt
PASS: test-udt_macro
PASS: test-unicode1
PASS: test-unicode2
PASS: test-unicode3
PASS: test-unicode4
PASS: test-unicode5
PASS: test-user_defined_input
PASS: test-wstring

Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
This commit is contained in:
Mingli Yu
2023-11-15 13:47:20 +08:00
committed by Armin Kuster
parent a7e6f56a68
commit 3f0d6ed420
2 changed files with 29 additions and 3 deletions
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
cd tests
for atest in test-* ; do
rm -rf tests.log
./${atest} > tests.log 2>&1
if [ $? = 0 ] ; then
echo "PASS: ${atest}"
else
echo "FAIL: ${atest}"
fi
done
@@ -7,22 +7,36 @@ LIC_FILES_CHKSUM = "file://LICENSE.MIT;md5=f969127d7b7ed0a8a63c2bbeae002588"
CVE_PRODUCT = "json-for-modern-cpp"
SRC_URI = "git://github.com/nlohmann/json.git;branch=develop;protocol=https \
"
git://github.com/nlohmann/json_test_data.git;destsuffix=git/json_test_data;name=json-test-data;branch=master;protocol=https \
file://run-ptest \
"
SRCREV = "4f8fba14066156b73f1189a2b8bd568bde5284c5"
SRCREV_json-test-data = "a1375cea09d27cc1c4cadb8d00470375b421ac37"
SRCREV_FORMAT = "json-test-data"
S = "${WORKDIR}/git"
inherit cmake
inherit cmake ptest
EXTRA_OECMAKE += "-DJSON_BuildTests=OFF"
EXTRA_OECMAKE += "${@bb.utils.contains('PTEST_ENABLED', '1', '-DJSON_BuildTests=ON -DJSON_TestDataDirectory=${PTEST_PATH}/json_test_data', '-DJSON_BuildTests=OFF', d)}"
# nlohmann-json is a header only C++ library, so the main package will be empty.
ALLOW_EMPTY:${PN} = "1"
RDEPENDS:${PN}-dev = ""
RDEPENDS:${PN}-ptest = "perl"
BBCLASSEXTEND = "native nativesdk"
do_install_ptest () {
install -d ${D}${PTEST_PATH}/tests
cp -r ${S}/json_test_data/ ${D}${PTEST_PATH}/
cp -r ${B}/test/test-* ${D}${PTEST_PATH}/tests
}
# other packages commonly reference the file directly as "json.hpp"
# create symlink to allow this usage
do_install:append() {