Merge branch 'emsesp:dev' into dev

This commit is contained in:
Proddy
2024-08-05 10:51:39 +02:00
committed by GitHub
8 changed files with 19 additions and 22 deletions

View File

@@ -56,7 +56,7 @@ void ClientLoop(void * arg) {
} }
} }
#ifndef UNITY_INCLUDE_CONFIG_H #ifndef EMSESP_UNITY
// we have another main that overrides this when using Unity in test_api.cpp // we have another main that overrides this when using Unity in test_api.cpp
int main(int argc __attribute__((unused)), char * argv[] __attribute__((unused))) { int main(int argc __attribute__((unused)), char * argv[] __attribute__((unused))) {
setup(); setup();

View File

@@ -232,7 +232,7 @@ build_flags =
-std=gnu++14 -Og -ggdb -std=gnu++14 -Og -ggdb
build_type = debug build_type = debug
build_src_flags = build_src_flags =
-Wall -Wextra -Werror -Wall -Wextra
-Wno-unused-parameter -Wno-sign-compare -Wno-missing-braces -Wno-unused-parameter -Wno-sign-compare -Wno-missing-braces
-I./lib_standalone -I./lib_standalone
-I./lib/uuid-common/src -I./lib/uuid-common/src
@@ -261,17 +261,17 @@ lib_ignore = Module EMS-ESP-Modules
; unit tests ; unit tests
; pio run -e native-test -t exec ; pio run -e native-test -t exec
; works on Linux, Windows, and MacOS ; works on Linux, Windows, and MacOS
; to auto generate the API exepected test results, compile with -DUNITY_CREATE and capture the output, and paste into the test_api.cpp file ; to auto generate the API exepected test results, compile with -DEMSESP_UNITY_CREATE and capture the output, and paste into the test_api.cpp file
[env:native-test] [env:native-test]
platform = native platform = native
test_build_src = true test_build_src = true
build_flags = build_flags =
-DARDUINOJSON_ENABLE_ARDUINO_STRING=1 -DARDUINOJSON_ENABLE_ARDUINO_STRING=1
-DEMSESP_STANDALONE -DEMSESP_TEST -DEMSESP_STANDALONE -DEMSESP_TEST
-DUNITY_INCLUDE_CONFIG_H -DEMSESP_UNITY
; -DUNITY_CREATE ; -DEMSESP_UNITY_CREATE
-DEMSESP_DEFAULT_LOCALE=\"en\" -DEMSESP_DEFAULT_TX_MODE=8 -DEMSESP_DEFAULT_VERSION=\"3.7.0-dev.0\" -DEMSESP_DEFAULT_BOARD_PROFILE=\"S32\" -DEMSESP_DEFAULT_LOCALE=\"en\" -DEMSESP_DEFAULT_TX_MODE=8 -DEMSESP_DEFAULT_VERSION=\"3.7.0-dev.0\" -DEMSESP_DEFAULT_BOARD_PROFILE=\"S32\"
-std=gnu++14 -Os -ggdb -Wall -Wextra -Werror -std=gnu++14 -Os -ggdb -Wall -Wextra
-lgcov --coverage -fprofile-arcs -ftest-coverage -lgcov --coverage -fprofile-arcs -ftest-coverage
build_type = debug build_type = debug
build_src_flags = build_src_flags =

View File

@@ -1539,25 +1539,22 @@ EMSESP::EMSESP()
// the services must be loaded in the correct order // the services must be loaded in the correct order
void EMSESP::start() { void EMSESP::start() {
// don't need shell if running unit tests // don't need shell if running unit tests
#if !defined(UNITY_INCLUDE_CONFIG_H) #ifndef EMSESP_UNITY
// Serial console's shell
serial_console_.begin(SERIAL_CONSOLE_BAUD_RATE); serial_console_.begin(SERIAL_CONSOLE_BAUD_RATE);
shell_ = std::make_shared<EMSESPConsole>(*this, serial_console_, true); shell_ = std::make_shared<EMSESPConsole>(*this, serial_console_, true);
shell_->maximum_log_messages(100); shell_->maximum_log_messages(100);
shell_->start(); shell_->start();
#if defined(EMSESP_DEBUG) #if defined(EMSESP_DEBUG)
shell_->log_level(uuid::log::Level::DEBUG); shell_->log_level(uuid::log::Level::DEBUG);
#else #else
shell_->log_level(uuid::log::Level::TRACE); shell_->log_level(uuid::log::Level::TRACE);
#endif #endif
#if defined(EMSESP_STANDALONE) #if defined(EMSESP_STANDALONE)
shell_->add_flags(CommandFlags::ADMIN); // always start in su/admin mode when running tests shell_->add_flags(CommandFlags::ADMIN); // always start in su/admin mode when running tests
#endif #endif
#else
#warning "Shell is disabled when running Unity tests."
#endif #endif
// start the file system // start the file system

View File

@@ -1544,7 +1544,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject output
node = output["api"].to<JsonObject>(); node = output["api"].to<JsonObject>();
// if we're generating test data for Unit Tests we dont want to count these API calls as it will pollute the data response // if we're generating test data for Unit Tests we dont want to count these API calls as it will pollute the data response
#if defined(UNITY_INCLUDE_CONFIG_H) #if defined(EMSESP_UNITY)
node["APICalls"] = 0; node["APICalls"] = 0;
node["APIFails"] = 0; node["APIFails"] = 0;
#else #else
@@ -1618,7 +1618,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject output
node["analogEnabled"] = settings.analog_enabled; node["analogEnabled"] = settings.analog_enabled;
node["telnetEnabled"] = settings.telnet_enabled; node["telnetEnabled"] = settings.telnet_enabled;
node["maxWebLogBuffer"] = settings.weblog_buffer; node["maxWebLogBuffer"] = settings.weblog_buffer;
#if defined(UNITY_INCLUDE_CONFIG_H) #if defined(EMSESP_UNITY)
node["webLogBuffer"] = 0; node["webLogBuffer"] = 0;
#else #else
node["webLogBuffer"] = EMSESP::webLogService.num_log_messages(); node["webLogBuffer"] = EMSESP::webLogService.num_log_messages();

View File

@@ -1 +1 @@
#define EMSESP_APP_VERSION "3.7.0-dev.29" #define EMSESP_APP_VERSION "3.7.0-dev.30"

View File

@@ -138,7 +138,7 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject input) {
// store the result so we can test with Unity later // store the result so we can test with Unity later
storeResponse(output); storeResponse(output);
#endif #endif
#if defined(EMSESP_STANDALONE) && !defined(UNITY_INCLUDE_CONFIG_H) #if defined(EMSESP_STANDALONE) && !defined(EMSESP_UNITY)
Serial.printf("%sweb output: %s[%s] %s(200)%s ", COLOR_WHITE, COLOR_BRIGHT_CYAN, request->url().c_str(), COLOR_BRIGHT_GREEN, COLOR_MAGENTA); Serial.printf("%sweb output: %s[%s] %s(200)%s ", COLOR_WHITE, COLOR_BRIGHT_CYAN, request->url().c_str(), COLOR_BRIGHT_GREEN, COLOR_MAGENTA);
serializeJson(output, Serial); serializeJson(output, Serial);
Serial.println(COLOR_RESET); Serial.println(COLOR_RESET);
@@ -165,7 +165,7 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject input) {
// store the result so we can test with Unity later // store the result so we can test with Unity later
storeResponse(output); storeResponse(output);
#endif #endif
#if defined(EMSESP_STANDALONE) && !defined(UNITY_INCLUDE_CONFIG_H) #if defined(EMSESP_STANDALONE) && !defined(EMSESP_UNITY)
Serial.printf("%sweb output: %s[%s]", COLOR_WHITE, COLOR_BRIGHT_CYAN, request->url().c_str()); Serial.printf("%sweb output: %s[%s]", COLOR_WHITE, COLOR_BRIGHT_CYAN, request->url().c_str());
Serial.printf(" %s(%d)%s ", ret_codes[return_code] == 200 ? COLOR_BRIGHT_GREEN : COLOR_BRIGHT_RED, ret_codes[return_code], COLOR_YELLOW); Serial.printf(" %s(%d)%s ", ret_codes[return_code] == 200 ? COLOR_BRIGHT_GREEN : COLOR_BRIGHT_RED, ret_codes[return_code], COLOR_YELLOW);
serializeJson(output, Serial); serializeJson(output, Serial);

View File

@@ -38,7 +38,7 @@ void run_tests();
const char * call_url(const char * url); const char * call_url(const char * url);
// load the tests // load the tests
// this is generated from this file when compiled with -DUNITY_CREATE // this is generated from this file when compiled with -DEMSESP_UNITY_CREATE
// copy the output to the test_api.h file // copy the output to the test_api.h file
#include "test_api.h" // generated test functions #include "test_api.h" // generated test functions
@@ -165,7 +165,7 @@ const char * call_url(const char * url, const char * data) {
} }
// capture the response and print it out as a test, auto-generates the test functions // capture the response and print it out as a test, auto-generates the test functions
// use with -DUNITY_CREATE in the platformio build flags // use with -DEMSESP_UNITY_CREATE in the platformio build flags
// only needs to be done once // only needs to be done once
void capture(const char * url = nullptr) { void capture(const char * url = nullptr) {
static uint8_t count = 1; static uint8_t count = 1;
@@ -263,7 +263,7 @@ int main() {
add_devices(); // add devices add_devices(); // add devices
#if defined(UNITY_CREATE) #if defined(EMSESP_UNITY_CREATE)
// These tests should all pass.... // These tests should all pass....

View File

@@ -1,6 +1,6 @@
// ************************************************************************************************** // **************************************************************************************************
// //
// Compile with -DUNITY_CREATE to generate the test functions // Compile with -DEMSESP_UNITY_CREATE to generate the test functions
// and copy the output and paste below. // and copy the output and paste below.
// //
// TODO: convert output to JSON and compare, showing differences // TODO: convert output to JSON and compare, showing differences