aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFeoramund <161657516+Feoramund@users.noreply.github.com>2024-06-01 14:04:49 -0400
committerFeoramund <161657516+Feoramund@users.noreply.github.com>2024-06-02 14:54:32 -0400
commit5e3e958574a7654a70382fb04cea2212f8652ff0 (patch)
tree2117e471f6f399d955db456d60fc47cbd4a8a3e5
parent6a9203328bfd34c59abeb46d61f1cb5d238b24a7 (diff)
Add `-define:ODIN_TEST_LOG_LEVEL` to set lowest log level
-rw-r--r--core/testing/runner.odin19
1 files changed, 17 insertions, 2 deletions
diff --git a/core/testing/runner.odin b/core/testing/runner.odin
index 4a45dabd1..dcc7c10ce 100644
--- a/core/testing/runner.odin
+++ b/core/testing/runner.odin
@@ -39,8 +39,23 @@ PROGRESS_WIDTH : int : #config(ODIN_TEST_PROGRESS_WIDTH, 24)
// This is the random seed that will be sent to each test.
// If it is unspecified, it will be set to the system cycle counter at startup.
SHARED_RANDOM_SEED : u64 : #config(ODIN_TEST_RANDOM_SEED, 0)
+// Set the lowest log level for this test run.
+LOG_LEVEL : string : #config(ODIN_TEST_LOG_LEVEL, "info")
+get_log_level :: #force_inline proc() -> runtime.Logger_Level {
+ when ODIN_DEBUG {
+ // Always use .Debug in `-debug` mode.
+ return .Debug
+ } else {
+ when LOG_LEVEL == "debug" { return .Debug }
+ else when LOG_LEVEL == "info" { return .Info }
+ else when LOG_LEVEL == "warning" { return .Warning }
+ else when LOG_LEVEL == "error" { return .Error }
+ else when LOG_LEVEL == "fatal" { return .Fatal }
+ }
+}
+
end_t :: proc(t: ^T) {
for i := len(t.cleanups)-1; i >= 0; i -= 1 {
#no_bounds_check c := t.cleanups[i]
@@ -82,7 +97,7 @@ run_test_task :: proc(task: thread.Task) {
context.logger = {
procedure = test_logger_proc,
data = &data.t,
- lowest_level = .Debug if ODIN_DEBUG else .Info,
+ lowest_level = get_log_level(),
options = Default_Test_Logger_Opts,
}
@@ -355,7 +370,7 @@ runner :: proc(internal_tests: []Internal_Test) -> bool {
context.logger = {
procedure = runner_logger_proc,
data = &log_messages,
- lowest_level = .Debug if ODIN_DEBUG else .Info,
+ lowest_level = get_log_level(),
options = Default_Test_Logger_Opts - {.Short_File_Path, .Line, .Procedure},
}