From 9f572cb92738c2f6d435f47fef9bad7344bc6e09 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 8 Nov 2022 14:56:22 +1100 Subject: Working test runner!!! --- lib/catch2/catch_runner.cpp | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'lib/catch2/catch_runner.cpp') diff --git a/lib/catch2/catch_runner.cpp b/lib/catch2/catch_runner.cpp index 8cd5c120..2b8f9678 100644 --- a/lib/catch2/catch_runner.cpp +++ b/lib/catch2/catch_runner.cpp @@ -3,8 +3,28 @@ #define CATCH_CONFIG_RUNNER #include "catch2/catch.hpp" -void run_catch(void) { - int argc = 1; - char *argv = "catch2"; - Catch::Session().run( argc, &argv ); +#include +#include +#include "esp_console.h" +#include "esp_log.h" +#include "esp_system.h" + +// There must be exactly on Session instance at all times; attempting to destroy +// this will result in memory corruption. +static Catch::Session sCatchSession; + +int exec_catch2(int argc, char** argv) { + // Reset the existing configuration before applying a new one. Otherwise we + // will get the combination of all configs. + sCatchSession.configData() = Catch::ConfigData(); + + int result = sCatchSession.applyCommandLine(argc, argv); + if (result != 0) { + return result; + } + + // Returns number of failures. + int failures = sCatchSession.run(); + + return failures > 0; } -- cgit v1.2.3