From 42ee92ed0f8eec9484335d10c803641f6bf1ef97 Mon Sep 17 00:00:00 2001 From: bvonhall Date: Tue, 28 Apr 2020 14:37:52 +0200 Subject: [PATCH 1/3] Fix JSON parsing in CCDB api test --- CCDB/test/testCcdbApi.cxx | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/CCDB/test/testCcdbApi.cxx b/CCDB/test/testCcdbApi.cxx index 8fd0e308b584e..95bb7b85fa1b2 100644 --- a/CCDB/test/testCcdbApi.cxx +++ b/CCDB/test/testCcdbApi.cxx @@ -40,6 +40,11 @@ #include #include +#include +#include +#include +#include + using namespace std; using namespace o2::ccdb; namespace utf = boost::unit_test; @@ -308,30 +313,16 @@ void countItems(const string& s, int& countObjects, int& countSubfolders) countObjects = 0; countSubfolders = 0; std::stringstream ss(s); - std::string line; - bool subfolderMode = false; - while (std::getline(ss, line, '\n')) { - o2::utils::ltrim(line); - o2::utils::rtrim(line); - if (line.length() == 0) { - continue; - } - if (line.find("subfolders") != std::string::npos) { - subfolderMode = true; - continue; - } + boost::property_tree::ptree pt; + boost::property_tree::read_json(ss, pt); - if (subfolderMode) { - countSubfolders++; - if (line.find(']') != std::string::npos) { - break; - } - } + if(pt.count("objects") > 0) { + countObjects = pt.get_child("objects").size(); + } - if (line.find(R"("path")") == 0) { - countObjects++; - } + if(pt.count("subfolders") > 0) { + countSubfolders = pt.get_child("subfolders").size(); } } From b838f480677ba8737249cf0cd31674b48c3aa77f Mon Sep 17 00:00:00 2001 From: Barthelemy Date: Tue, 28 Apr 2020 14:39:59 +0200 Subject: [PATCH 2/3] format --- CCDB/test/testCcdbApi.cxx | 4 ++-- cmake/O2ReportNonTestedMacros.cmake | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CCDB/test/testCcdbApi.cxx b/CCDB/test/testCcdbApi.cxx index 95bb7b85fa1b2..4a17989508245 100644 --- a/CCDB/test/testCcdbApi.cxx +++ b/CCDB/test/testCcdbApi.cxx @@ -317,11 +317,11 @@ void countItems(const string& s, int& countObjects, int& countSubfolders) boost::property_tree::ptree pt; boost::property_tree::read_json(ss, pt); - if(pt.count("objects") > 0) { + if (pt.count("objects") > 0) { countObjects = pt.get_child("objects").size(); } - if(pt.count("subfolders") > 0) { + if (pt.count("subfolders") > 0) { countSubfolders = pt.get_child("subfolders").size(); } } diff --git a/cmake/O2ReportNonTestedMacros.cmake b/cmake/O2ReportNonTestedMacros.cmake index 6a204039bff38..73a6fa87386c5 100644 --- a/cmake/O2ReportNonTestedMacros.cmake +++ b/cmake/O2ReportNonTestedMacros.cmake @@ -76,11 +76,11 @@ function(o2_report_non_tested_macros) if(NOT ${m} IN_LIST LIST_OF_ROOT_MACRO_TESTS AND NOT ${m} IN_LIST LIST_OF_ROOT_MACRO_TESTS_COMPILED AND NOT ${m} IN_LIST O2_ROOT_MACRO_EXCLUSION_LIST) - if(NOT A_DO_NOT_FAIL) - message(FATAL_ERROR "Macro ${m} should be tested") - else() - message(WARNING "Macro ${m} is not tested at all !!!") - endif() +# if(NOT A_DO_NOT_FAIL) +# message(FATAL_ERROR "Macro ${m} should be tested") +# else() +# message(WARNING "Macro ${m} is not tested at all !!!") +# endif() endif() endforeach() message(STATUS) From b90ca0845525f428af1077d5cd5e5ddc95508d9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barth=C3=A9l=C3=A9my=20von=20Haller?= Date: Tue, 28 Apr 2020 15:44:18 +0200 Subject: [PATCH 3/3] Update O2ReportNonTestedMacros.cmake --- cmake/O2ReportNonTestedMacros.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake/O2ReportNonTestedMacros.cmake b/cmake/O2ReportNonTestedMacros.cmake index 73a6fa87386c5..6a204039bff38 100644 --- a/cmake/O2ReportNonTestedMacros.cmake +++ b/cmake/O2ReportNonTestedMacros.cmake @@ -76,11 +76,11 @@ function(o2_report_non_tested_macros) if(NOT ${m} IN_LIST LIST_OF_ROOT_MACRO_TESTS AND NOT ${m} IN_LIST LIST_OF_ROOT_MACRO_TESTS_COMPILED AND NOT ${m} IN_LIST O2_ROOT_MACRO_EXCLUSION_LIST) -# if(NOT A_DO_NOT_FAIL) -# message(FATAL_ERROR "Macro ${m} should be tested") -# else() -# message(WARNING "Macro ${m} is not tested at all !!!") -# endif() + if(NOT A_DO_NOT_FAIL) + message(FATAL_ERROR "Macro ${m} should be tested") + else() + message(WARNING "Macro ${m} is not tested at all !!!") + endif() endif() endforeach() message(STATUS)