mirror of
https://github.com/nlohmann/json.git
synced 2026-08-22 09:03:18 +00:00
🚨 add new CI and fix warnings (#2561)
* ⚗️ move CI targets to CMake * ♻️ add target for cpplint * ♻️ add target for self-contained binaries * ♻️ add targets for iwyu and infer * 🔊 add version output * ♻️ add target for oclint * 🚨 fix warnings * ♻️ rename targets * ♻️ use iwyu properly * 🚨 fix warnings * ♻️ use iwyu properly * ♻️ add target for benchmarks * ♻️ add target for CMake flags * 👷 use GitHub Actions * ⚗️ try to install Clang 11 * ⚗️ try to install GCC 11 * ⚗️ try to install Clang 11 * ⚗️ try to install GCC 11 * ⚗️ add clang analyze target * 🔥 remove Google Benchmark * ⬆️ Google Benchmark 1.5.2 * 🔥 use fetchcontent * 🐧 add target to download a Linux version of CMake * 🔨 fix dependency * 🚨 fix includes * 🚨 fix comment * 🔧 adjust flags for GCC 11.0.0 20210110 (experimental) * 🐳 user Docker image to run CI * 🔧 add target for Valgrind * 👷 add target for Valgrind tests * ⚗️ add Dart * ⏪ remove Dart * ⚗️ do not call ctest in test subdirectory * ⚗️ download test data explicitly * ⚗️ only execute Valgrind tests * ⚗️ fix labels * 🔥 remove unneeded jobs * 🔨 cleanup * 🐛 fix OCLint call * ✅ add targets for offline and git-independent tests * ✅ add targets for C++ language versions and reproducible tests * 🔨 clean up * 👷 add CI steps for cppcheck and cpplint * 🚨 fix warnings from Clang-Tidy * 👷 add CI steps for Clang-Tidy * 🚨 fix warnings * 🔧 select proper binary * 🚨 fix warnings * 🚨 suppress some unhelpful warnings * 🚨 fix warnings * 🎨 fix format * 🚨 fix warnings * 👷 add CI steps for Sanitizers * 🚨 fix warnings * ⚡ add optimization to sanitizer build * 🚨 fix warnings * 🚨 add missing header * 🚨 fix warnings * 👷 add CI step for coverage * 👷 add CI steps for disabled exceptions and implicit conversions * 🚨 fix warnings * 👷 add CI steps for checking indentation * 🐛 fix variable use * 💚 fix build * ➖ remove CircleCI * 👷 add CI step for diagnostics * 🚨 fix warning * 🔥 clean Travis
This commit is contained in:
Vendored
+70
-16
@@ -48,8 +48,8 @@
|
||||
|
||||
#define DOCTEST_VERSION_MAJOR 2
|
||||
#define DOCTEST_VERSION_MINOR 4
|
||||
#define DOCTEST_VERSION_PATCH 3
|
||||
#define DOCTEST_VERSION_STR "2.4.3"
|
||||
#define DOCTEST_VERSION_PATCH 4
|
||||
#define DOCTEST_VERSION_STR "2.4.4"
|
||||
|
||||
#define DOCTEST_VERSION \
|
||||
(DOCTEST_VERSION_MAJOR * 10000 + DOCTEST_VERSION_MINOR * 100 + DOCTEST_VERSION_PATCH)
|
||||
@@ -3718,6 +3718,7 @@ namespace detail {
|
||||
}
|
||||
|
||||
bool TestCase::operator<(const TestCase& other) const {
|
||||
// this will be used only to differentiate between test cases - not relevant for sorting
|
||||
if(m_line != other.m_line)
|
||||
return m_line < other.m_line;
|
||||
const int file_cmp = m_file.compare(other.m_file);
|
||||
@@ -4043,15 +4044,29 @@ namespace {
|
||||
struct FatalConditionHandler
|
||||
{
|
||||
static LONG CALLBACK handleException(PEXCEPTION_POINTERS ExceptionInfo) {
|
||||
for(size_t i = 0; i < DOCTEST_COUNTOF(signalDefs); ++i) {
|
||||
if(ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) {
|
||||
reportFatal(signalDefs[i].name);
|
||||
break;
|
||||
// Multiple threads may enter this filter/handler at once. We want the error message to be printed on the
|
||||
// console just once no matter how many threads have crashed.
|
||||
static std::mutex mutex;
|
||||
static bool execute = true;
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
if(execute) {
|
||||
bool reported = false;
|
||||
for(size_t i = 0; i < DOCTEST_COUNTOF(signalDefs); ++i) {
|
||||
if(ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) {
|
||||
reportFatal(signalDefs[i].name);
|
||||
reported = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(reported == false)
|
||||
reportFatal("Unhandled SEH exception caught");
|
||||
if(isDebuggerActive() && !g_cs->no_breaks)
|
||||
DOCTEST_BREAK_INTO_DEBUGGER();
|
||||
}
|
||||
execute = false;
|
||||
}
|
||||
// If its not an exception we care about, pass it along.
|
||||
// This stops us from eating debugger breaks etc.
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
FatalConditionHandler() {
|
||||
@@ -4073,6 +4088,8 @@ namespace {
|
||||
original_terminate_handler = std::get_terminate();
|
||||
std::set_terminate([]() noexcept {
|
||||
reportFatal("Terminate handler called");
|
||||
if(isDebuggerActive() && !g_cs->no_breaks)
|
||||
DOCTEST_BREAK_INTO_DEBUGGER();
|
||||
std::exit(EXIT_FAILURE); // explicitly exit - otherwise the SIGABRT handler may be called as well
|
||||
});
|
||||
|
||||
@@ -4083,8 +4100,29 @@ namespace {
|
||||
prev_sigabrt_handler = std::signal(SIGABRT, [](int signal) noexcept {
|
||||
if(signal == SIGABRT) {
|
||||
reportFatal("SIGABRT - Abort (abnormal termination) signal");
|
||||
if(isDebuggerActive() && !g_cs->no_breaks)
|
||||
DOCTEST_BREAK_INTO_DEBUGGER();
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
});
|
||||
|
||||
// The following settings are taken from google test, and more
|
||||
// specifically from UnitTest::Run() inside of gtest.cc
|
||||
|
||||
// the user does not want to see pop-up dialogs about crashes
|
||||
prev_error_mode_1 = SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOALIGNMENTFAULTEXCEPT |
|
||||
SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
|
||||
// This forces the abort message to go to stderr in all circumstances.
|
||||
prev_error_mode_2 = _set_error_mode(_OUT_TO_STDERR);
|
||||
// In the debug version, Visual Studio pops up a separate dialog
|
||||
// offering a choice to debug the aborted program - we want to disable that.
|
||||
prev_abort_behavior = _set_abort_behavior(0x0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
|
||||
// In debug mode, the Windows CRT can crash with an assertion over invalid
|
||||
// input (e.g. passing an invalid file descriptor). The default handling
|
||||
// for these assertions is to pop up a dialog and wait for user input.
|
||||
// Instead ask the CRT to dump such assertions to stderr non-interactively.
|
||||
prev_report_mode = _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);
|
||||
prev_report_file = _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
|
||||
}
|
||||
|
||||
static void reset() {
|
||||
@@ -4092,16 +4130,25 @@ namespace {
|
||||
// Unregister handler and restore the old guarantee
|
||||
SetUnhandledExceptionFilter(previousTop);
|
||||
SetThreadStackGuarantee(&guaranteeSize);
|
||||
previousTop = nullptr;
|
||||
isSet = false;
|
||||
std::set_terminate(original_terminate_handler);
|
||||
std::signal(SIGABRT, prev_sigabrt_handler);
|
||||
SetErrorMode(prev_error_mode_1);
|
||||
_set_error_mode(prev_error_mode_2);
|
||||
_set_abort_behavior(prev_abort_behavior, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
|
||||
_CrtSetReportMode(_CRT_ASSERT, prev_report_mode);
|
||||
_CrtSetReportFile(_CRT_ASSERT, prev_report_file);
|
||||
isSet = false;
|
||||
}
|
||||
}
|
||||
|
||||
~FatalConditionHandler() { reset(); }
|
||||
|
||||
private:
|
||||
static UINT prev_error_mode_1;
|
||||
static int prev_error_mode_2;
|
||||
static unsigned int prev_abort_behavior;
|
||||
static int prev_report_mode;
|
||||
static _HFILE prev_report_file;
|
||||
static void (*prev_sigabrt_handler)(int);
|
||||
static std::terminate_handler original_terminate_handler;
|
||||
static bool isSet;
|
||||
@@ -4109,6 +4156,11 @@ namespace {
|
||||
static LPTOP_LEVEL_EXCEPTION_FILTER previousTop;
|
||||
};
|
||||
|
||||
UINT FatalConditionHandler::prev_error_mode_1;
|
||||
int FatalConditionHandler::prev_error_mode_2;
|
||||
unsigned int FatalConditionHandler::prev_abort_behavior;
|
||||
int FatalConditionHandler::prev_report_mode;
|
||||
_HFILE FatalConditionHandler::prev_report_file;
|
||||
void (*FatalConditionHandler::prev_sigabrt_handler)(int);
|
||||
std::terminate_handler FatalConditionHandler::original_terminate_handler;
|
||||
bool FatalConditionHandler::isSet = false;
|
||||
@@ -5046,7 +5098,6 @@ namespace {
|
||||
|
||||
struct JUnitTestCaseData
|
||||
{
|
||||
DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wdeprecated-declarations") // gmtime
|
||||
static std::string getCurrentTimestamp() {
|
||||
// Beware, this is not reentrant because of backward compatibility issues
|
||||
// Also, UTC only, again because of backward compatibility (%z is C++11)
|
||||
@@ -5054,16 +5105,19 @@ DOCTEST_CLANG_SUPPRESS_WARNING_WITH_PUSH("-Wdeprecated-declarations") // gmtime
|
||||
std::time(&rawtime);
|
||||
auto const timeStampSize = sizeof("2017-01-16T17:06:45Z");
|
||||
|
||||
std::tm* timeInfo;
|
||||
timeInfo = std::gmtime(&rawtime);
|
||||
std::tm timeInfo;
|
||||
#ifdef DOCTEST_PLATFORM_WINDOWS
|
||||
gmtime_s(&timeInfo, &rawtime);
|
||||
#else // DOCTEST_PLATFORM_WINDOWS
|
||||
gmtime_r(&rawtime, &timeInfo);
|
||||
#endif // DOCTEST_PLATFORM_WINDOWS
|
||||
|
||||
char timeStamp[timeStampSize];
|
||||
const char* const fmt = "%Y-%m-%dT%H:%M:%SZ";
|
||||
|
||||
std::strftime(timeStamp, timeStampSize, fmt, timeInfo);
|
||||
std::strftime(timeStamp, timeStampSize, fmt, &timeInfo);
|
||||
return std::string(timeStamp);
|
||||
}
|
||||
DOCTEST_CLANG_SUPPRESS_WARNING_POP
|
||||
|
||||
struct JUnitTestMessage
|
||||
{
|
||||
|
||||
+4
-4
@@ -99,7 +99,7 @@ template <
|
||||
class T,
|
||||
class Compare = fifo_map_compare<Key>,
|
||||
class Allocator = std::allocator<std::pair<const Key, T>>
|
||||
> class fifo_map
|
||||
> class fifo_map // NOLINT(cppcoreguidelines-special-member-functions,hicpp-special-member-functions,-warnings-as-errors)
|
||||
{
|
||||
public:
|
||||
using key_type = Key;
|
||||
@@ -514,10 +514,10 @@ template <
|
||||
internal_map_type m_map;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace nlohmann
|
||||
|
||||
// specialization of std::swap
|
||||
namespace std
|
||||
namespace std // NOLINT(cert-dcl58-cpp,-warnings-as-errors)
|
||||
{
|
||||
template <class Key, class T, class Compare, class Allocator>
|
||||
inline void swap(nlohmann::fifo_map<Key, T, Compare, Allocator>& m1,
|
||||
@@ -525,6 +525,6 @@ inline void swap(nlohmann::fifo_map<Key, T, Compare, Allocator>& m1,
|
||||
{
|
||||
m1.swap(m2);
|
||||
}
|
||||
}
|
||||
} // namespace std
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user