diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2025-05-20 16:51:24 +0200 |
|---|---|---|
| committer | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2025-05-20 16:51:24 +0200 |
| commit | 8bffd247b77bf757449d326a4e6ae6cf49167e94 (patch) | |
| tree | 8f5e8031a1f5af0e1076f7e25c08206f4639ad32 /core/testing | |
| parent | e36db15b48091a5924e6c35b220546862c51ed70 (diff) | |
Restore console mode when test runner exits.
Diffstat (limited to 'core/testing')
| -rw-r--r-- | core/testing/runner.odin | 4 | ||||
| -rw-r--r-- | core/testing/runner_windows.odin | 26 |
2 files changed, 24 insertions, 6 deletions
diff --git a/core/testing/runner.odin b/core/testing/runner.odin index 83a5ac4e7..db0587370 100644 --- a/core/testing/runner.odin +++ b/core/testing/runner.odin @@ -949,5 +949,9 @@ To partly mitigate this, redirect STDERR to a file or use the -define:ODIN_TEST_ fmt.assertf(err == nil, "Error writing JSON report: %v", err) } + when ODIN_OS == .Windows { + console_ansi_fini() + } + return total_success_count == total_test_count } diff --git a/core/testing/runner_windows.odin b/core/testing/runner_windows.odin index 401804c71..b35914c72 100644 --- a/core/testing/runner_windows.odin +++ b/core/testing/runner_windows.odin @@ -3,20 +3,34 @@ package testing import win32 "core:sys/windows" +old_stdout_mode: u32 +old_stderr_mode: u32 + console_ansi_init :: proc() { stdout := win32.GetStdHandle(win32.STD_OUTPUT_HANDLE) if stdout != win32.INVALID_HANDLE && stdout != nil { - old_console_mode: u32 - if win32.GetConsoleMode(stdout, &old_console_mode) { - win32.SetConsoleMode(stdout, old_console_mode | win32.ENABLE_VIRTUAL_TERMINAL_PROCESSING) + if win32.GetConsoleMode(stdout, &old_stdout_mode) { + win32.SetConsoleMode(stdout, old_stdout_mode | win32.ENABLE_VIRTUAL_TERMINAL_PROCESSING) } } stderr := win32.GetStdHandle(win32.STD_ERROR_HANDLE) if stderr != win32.INVALID_HANDLE && stderr != nil { - old_console_mode: u32 - if win32.GetConsoleMode(stderr, &old_console_mode) { - win32.SetConsoleMode(stderr, old_console_mode | win32.ENABLE_VIRTUAL_TERMINAL_PROCESSING) + if win32.GetConsoleMode(stderr, &old_stderr_mode) { + win32.SetConsoleMode(stderr, old_stderr_mode | win32.ENABLE_VIRTUAL_TERMINAL_PROCESSING) } } } + +// Restore the cursor on exit +console_ansi_fini :: proc() { + stdout := win32.GetStdHandle(win32.STD_OUTPUT_HANDLE) + if stdout != win32.INVALID_HANDLE && stdout != nil { + win32.SetConsoleMode(stdout, old_stdout_mode) + } + + stderr := win32.GetStdHandle(win32.STD_ERROR_HANDLE) + if stderr != win32.INVALID_HANDLE && stderr != nil { + win32.SetConsoleMode(stderr, old_stderr_mode) + } +}
\ No newline at end of file |