refactor: hectic C: logger rules and results
This commit is contained in:
@@ -81,7 +81,8 @@ void test_struct2_to_debug_str(Arena *arena) {
|
||||
|
||||
int main(void) {
|
||||
printf("%sRunning %s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
init_logger();
|
||||
debug_color_mode = COLOR_MODE_DISABLE;
|
||||
logger_init();
|
||||
|
||||
Arena arena = arena_init(MEM_MiB);
|
||||
|
||||
@@ -92,6 +93,7 @@ int main(void) {
|
||||
test_struct2_to_debug_str(&arena);
|
||||
|
||||
arena_free(&arena);
|
||||
logger_free();
|
||||
printf("%sAll tests passed %s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
return 0;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
#include "hectic.h"
|
||||
#include <assert.h>
|
||||
|
||||
int main(void) {
|
||||
printf("%sRunning %s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
init_logger();
|
||||
|
||||
Arena arena = arena_init(MEM_MiB);
|
||||
|
||||
char *rules = arena_alloc(&arena, MEM_KiB);
|
||||
strcpy(rules, "trace:file:test.c:100-150");
|
||||
|
||||
arena_free(&arena);
|
||||
printf("%sAll tests passed %s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
return 0;
|
||||
}
|
||||
29
package/c/hectic/test/02-logger-rules.c
Executable file
29
package/c/hectic/test/02-logger-rules.c
Executable file
@@ -0,0 +1,29 @@
|
||||
#include "hectic.h"
|
||||
#include <assert.h>
|
||||
|
||||
void test_parse_rules(Arena *arena) {
|
||||
char *rules = arena_alloc(arena, MEM_KiB);
|
||||
strcpy(rules, "ERROR,02-logger-rules.c@5:13=INFO,hectic.c@arena_alloc__=NOTICE");
|
||||
|
||||
LogRuleResult result = logger_parse_rules__(__FILE__, __func__, __LINE__, arena, rules);
|
||||
|
||||
raise_notice("result.type: %s", result_type_to_string(result.type));
|
||||
assert(result.type != RESULT_ERROR);
|
||||
|
||||
raise_notice("result.some: %s", LOG_RULES_TO_DEBUG_STR(arena, "result.some", &RESULT_SOME_VALUE(result)));
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
printf("%sRunning %s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
debug_color_mode = COLOR_MODE_DISABLE;
|
||||
logger_init();
|
||||
|
||||
Arena arena = arena_init(MEM_MiB);
|
||||
|
||||
test_parse_rules(&arena);
|
||||
|
||||
arena_free(&arena);
|
||||
logger_free();
|
||||
printf("%sAll tests passed %s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
return 0;
|
||||
}
|
||||
@@ -92,7 +92,7 @@ void test_arena_overwrite_detection() {
|
||||
|
||||
int main() {
|
||||
printf("%sRunning %s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
init_logger();
|
||||
logger_init();
|
||||
|
||||
test_arena_init();
|
||||
test_arena_alloc();
|
||||
@@ -103,6 +103,7 @@ int main() {
|
||||
test_arena_repstr();
|
||||
test_arena_overwrite_detection();
|
||||
|
||||
logger_free();
|
||||
printf("%sall tests passed.%s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ static void test_arena_reset_reuse(void) {
|
||||
|
||||
int main(void) {
|
||||
printf("%sRunning %s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
init_logger();
|
||||
logger_init();
|
||||
|
||||
test_parse_json_object();
|
||||
test_parse_json_number();
|
||||
@@ -137,6 +137,7 @@ int main(void) {
|
||||
test_nested_json_object();
|
||||
test_arena_reset_reuse();
|
||||
|
||||
logger_free();
|
||||
printf("%sall tests passed.%s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -84,14 +84,15 @@ void test_slice_string() {
|
||||
|
||||
int main() {
|
||||
printf("%sRunning %s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
init_logger();
|
||||
logger_init();
|
||||
|
||||
test_slice_create();
|
||||
test_slice_subslice();
|
||||
test_slice_copy();
|
||||
test_slice_edge_cases();
|
||||
test_slice_string();
|
||||
|
||||
|
||||
logger_free();
|
||||
printf("%sall tests passed.%s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
return 0;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ static void test_template_node_to_debug_str(Arena *arena) {
|
||||
|
||||
int main(void) {
|
||||
printf("%sRunning %s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
init_logger();
|
||||
logger_init();
|
||||
|
||||
Arena arena = arena_init(ARENA_SIZE);
|
||||
|
||||
@@ -87,6 +87,7 @@ int main(void) {
|
||||
//printf("%sTest 1: template_parse passed%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_RESET));
|
||||
//arena_reset(&arena);
|
||||
|
||||
logger_free();
|
||||
arena_free(&arena);
|
||||
printf("%sall tests passed.%s%s%s\n", OPTIONAL_COLOR(COLOR_GREEN), OPTIONAL_COLOR(COLOR_CYAN), __FILE__, OPTIONAL_COLOR(COLOR_RESET));
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user