Skip to content

Commit

Permalink
Add section logging to test loggers (#116)
Browse files Browse the repository at this point in the history
* Add section logging to test loggers

* Avoid duplicate section logging

* Macro-ise
  • Loading branch information
Shillaker committed Jun 17, 2021
1 parent 0605083 commit fe6d33a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 28 deletions.
15 changes: 1 addition & 14 deletions tests/dist/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,7 @@

using namespace faabric::scheduler;

struct LogListener : Catch::TestEventListenerBase
{
using TestEventListenerBase::TestEventListenerBase;

void testCaseStarting(Catch::TestCaseInfo const& testInfo) override
{

SPDLOG_INFO("---------------------------------------------");
SPDLOG_INFO("TEST: {}", testInfo.name);
SPDLOG_INFO("---------------------------------------------");
}
};

CATCH_REGISTER_LISTENER(LogListener)
FAABRIC_CATCH_LOGGER

int main(int argc, char* argv[])
{
Expand Down
15 changes: 1 addition & 14 deletions tests/test/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,7 @@
#include <faabric/util/logging.h>
#include <faabric/util/testing.h>

struct LogListener : Catch::TestEventListenerBase
{
using TestEventListenerBase::TestEventListenerBase;

void testCaseStarting(Catch::TestCaseInfo const& testInfo) override
{

SPDLOG_INFO("---------------------------------------------");
SPDLOG_INFO("TEST: {}", testInfo.name);
SPDLOG_INFO("---------------------------------------------");
}
};

CATCH_REGISTER_LISTENER(LogListener)
FAABRIC_CATCH_LOGGER

int main(int argc, char* argv[])
{
Expand Down
24 changes: 24 additions & 0 deletions tests/utils/faabric_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,30 @@ using namespace faabric;

#define SHORT_TEST_TIMEOUT_MS 1000

#define FAABRIC_CATCH_LOGGER \
struct LogListener : Catch::TestEventListenerBase \
{ \
using TestEventListenerBase::TestEventListenerBase; \
void testCaseStarting(Catch::TestCaseInfo const& testInfo) override \
{ \
this->Catch::TestEventListenerBase::testCaseStarting(testInfo); \
SPDLOG_INFO("============================================="); \
SPDLOG_INFO("TEST: {}", testInfo.name); \
SPDLOG_INFO("============================================="); \
} \
\
void sectionStarting(Catch::SectionInfo const& sectionInfo) override \
{ \
this->Catch::TestEventListenerBase::sectionStarting(sectionInfo); \
if (sectionInfo.name != currentTestCaseInfo->name) { \
SPDLOG_INFO("---------------------------------------------"); \
SPDLOG_INFO("SECTION: {}", sectionInfo.name); \
SPDLOG_INFO("---------------------------------------------"); \
} \
} \
}; \
CATCH_REGISTER_LISTENER(LogListener)

namespace tests {
void cleanFaabric();

Expand Down

0 comments on commit fe6d33a

Please sign in to comment.