mirror of https://github.com/nlohmann/json.git
Add error message if test suite cannot be found (#3585)
* 🚸 add error message if test suite cannot be found Fixes #3584pull/3592/head
parent
527da54dcb
commit
feef0eb595
16
README.md
16
README.md
|
@ -1790,6 +1790,22 @@ $ ctest --output-on-failure
|
||||||
|
|
||||||
Note that during the `ctest` stage, several JSON test files are downloaded from an [external repository](https://github.com/nlohmann/json_test_data). If policies forbid downloading artifacts during testing, you can download the files yourself and pass the directory with the test files via `-DJSON_TestDataDirectory=path` to CMake. Then, no Internet connectivity is required. See [issue #2189](https://github.com/nlohmann/json/issues/2189) for more information.
|
Note that during the `ctest` stage, several JSON test files are downloaded from an [external repository](https://github.com/nlohmann/json_test_data). If policies forbid downloading artifacts during testing, you can download the files yourself and pass the directory with the test files via `-DJSON_TestDataDirectory=path` to CMake. Then, no Internet connectivity is required. See [issue #2189](https://github.com/nlohmann/json/issues/2189) for more information.
|
||||||
|
|
||||||
|
If the test suite is not found, several test suites will fail like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
===============================================================================
|
||||||
|
json/tests/src/make_test_data_available.hpp:21:
|
||||||
|
TEST CASE: check test suite is downloaded
|
||||||
|
|
||||||
|
json/tests/src/make_test_data_available.hpp:23: FATAL ERROR: REQUIRE( utils::check_testsuite_downloaded() ) is NOT correct!
|
||||||
|
values: REQUIRE( false )
|
||||||
|
logged: Test data not found in 'json/cmake-build-debug/json_test_data'.
|
||||||
|
Please execute target 'download_test_data' before running this test suite.
|
||||||
|
See <https://github.com/nlohmann/json#execute-unit-tests> for more information.
|
||||||
|
|
||||||
|
===============================================================================
|
||||||
|
```
|
||||||
|
|
||||||
In case you have downloaded the library rather than checked out the code via Git, test `cmake_fetch_content_configure` will fail. Please execute `ctest -LE git_required` to skip these tests. See [issue #2189](https://github.com/nlohmann/json/issues/2189) for more information.
|
In case you have downloaded the library rather than checked out the code via Git, test `cmake_fetch_content_configure` will fail. Please execute `ctest -LE git_required` to skip these tests. See [issue #2189](https://github.com/nlohmann/json/issues/2189) for more information.
|
||||||
|
|
||||||
Some tests change the installed files and hence make the whole process not reproducible. Please execute `ctest -LE not_reproducible` to skip these tests. See [issue #2324](https://github.com/nlohmann/json/issues/2324) for more information.
|
Some tests change the installed files and hence make the whole process not reproducible. Please execute `ctest -LE not_reproducible` to skip these tests. See [issue #2324](https://github.com/nlohmann/json/issues/2324) for more information.
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdio> // fopen, fclose, FILE
|
||||||
|
#include <memory> // unique_ptr
|
||||||
|
#include <test_data.hpp>
|
||||||
|
#include <doctest.h>
|
||||||
|
|
||||||
|
namespace utils
|
||||||
|
{
|
||||||
|
|
||||||
|
inline bool check_testsuite_downloaded()
|
||||||
|
{
|
||||||
|
std::unique_ptr<std::FILE, decltype(&std::fclose)> file(std::fopen(TEST_DATA_DIRECTORY "/README.md", "r"), &std::fclose);
|
||||||
|
return file != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("check test suite is downloaded")
|
||||||
|
{
|
||||||
|
REQUIRE_MESSAGE(utils::check_testsuite_downloaded(), "Test data not found in '" TEST_DATA_DIRECTORY "'. Please execute target 'download_test_data' before running this test suite. See <https://github.com/nlohmann/json#execute-unit-tests> for more information.");
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace utils
|
|
@ -12,7 +12,7 @@
|
||||||
using nlohmann::json;
|
using nlohmann::json;
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <test_data.hpp>
|
#include "make_test_data_available.hpp"
|
||||||
|
|
||||||
TEST_CASE("Binary Formats" * doctest::skip())
|
TEST_CASE("Binary Formats" * doctest::skip())
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,7 @@ using nlohmann::json;
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <test_data.hpp>
|
#include "make_test_data_available.hpp"
|
||||||
#include "test_utils.hpp"
|
#include "test_utils.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
|
|
@ -13,7 +13,7 @@ using nlohmann::json;
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <test_data.hpp>
|
#include "make_test_data_available.hpp"
|
||||||
#include "test_utils.hpp"
|
#include "test_utils.hpp"
|
||||||
|
|
||||||
TEST_CASE("BSON")
|
TEST_CASE("BSON")
|
||||||
|
|
|
@ -16,7 +16,7 @@ using nlohmann::json;
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <test_data.hpp>
|
#include "make_test_data_available.hpp"
|
||||||
#include "test_utils.hpp"
|
#include "test_utils.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
|
|
@ -13,7 +13,7 @@ using nlohmann::json;
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <test_data.hpp>
|
#include "make_test_data_available.hpp"
|
||||||
|
|
||||||
TEST_CASE("object inspection")
|
TEST_CASE("object inspection")
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
using nlohmann::json;
|
using nlohmann::json;
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <test_data.hpp>
|
#include "make_test_data_available.hpp"
|
||||||
|
|
||||||
TEST_CASE("JSON patch")
|
TEST_CASE("JSON patch")
|
||||||
{
|
{
|
||||||
|
|
|
@ -15,7 +15,7 @@ using nlohmann::json;
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <test_data.hpp>
|
#include "make_test_data_available.hpp"
|
||||||
#include "test_utils.hpp"
|
#include "test_utils.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
|
|
@ -19,7 +19,7 @@ using nlohmann::json;
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <test_data.hpp>
|
#include "make_test_data_available.hpp"
|
||||||
|
|
||||||
#ifdef JSON_HAS_CPP_17
|
#ifdef JSON_HAS_CPP_17
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
using nlohmann::json;
|
using nlohmann::json;
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <test_data.hpp>
|
#include "make_test_data_available.hpp"
|
||||||
|
|
||||||
TEST_CASE("compliance tests from json.org")
|
TEST_CASE("compliance tests from json.org")
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,7 +14,7 @@ using nlohmann::json;
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <test_data.hpp>
|
#include "make_test_data_available.hpp"
|
||||||
#include "test_utils.hpp"
|
#include "test_utils.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
|
|
@ -16,7 +16,7 @@ using nlohmann::json;
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <test_data.hpp>
|
#include "make_test_data_available.hpp"
|
||||||
|
|
||||||
TEST_CASE("Unicode (1/5)" * doctest::skip())
|
TEST_CASE("Unicode (1/5)" * doctest::skip())
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,7 +18,7 @@ using nlohmann::json;
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <test_data.hpp>
|
#include "make_test_data_available.hpp"
|
||||||
|
|
||||||
// this test suite uses static variables with non-trivial destructors
|
// this test suite uses static variables with non-trivial destructors
|
||||||
DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
|
DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
|
||||||
|
|
|
@ -18,7 +18,7 @@ using nlohmann::json;
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <test_data.hpp>
|
#include "make_test_data_available.hpp"
|
||||||
|
|
||||||
// this test suite uses static variables with non-trivial destructors
|
// this test suite uses static variables with non-trivial destructors
|
||||||
DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
|
DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
|
||||||
|
|
|
@ -18,7 +18,7 @@ using nlohmann::json;
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <test_data.hpp>
|
#include "make_test_data_available.hpp"
|
||||||
|
|
||||||
// this test suite uses static variables with non-trivial destructors
|
// this test suite uses static variables with non-trivial destructors
|
||||||
DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
|
DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
|
||||||
|
|
|
@ -18,7 +18,7 @@ using nlohmann::json;
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <test_data.hpp>
|
#include "make_test_data_available.hpp"
|
||||||
|
|
||||||
// this test suite uses static variables with non-trivial destructors
|
// this test suite uses static variables with non-trivial destructors
|
||||||
DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
|
DOCTEST_CLANG_SUPPRESS_WARNING_PUSH
|
||||||
|
|
Loading…
Reference in New Issue