mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Restore console mode when test runner exits.
This commit is contained in:
@@ -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)
|
fmt.assertf(err == nil, "Error writing JSON report: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
when ODIN_OS == .Windows {
|
||||||
|
console_ansi_fini()
|
||||||
|
}
|
||||||
|
|
||||||
return total_success_count == total_test_count
|
return total_success_count == total_test_count
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,20 +3,34 @@ package testing
|
|||||||
|
|
||||||
import win32 "core:sys/windows"
|
import win32 "core:sys/windows"
|
||||||
|
|
||||||
|
old_stdout_mode: u32
|
||||||
|
old_stderr_mode: u32
|
||||||
|
|
||||||
console_ansi_init :: proc() {
|
console_ansi_init :: proc() {
|
||||||
stdout := win32.GetStdHandle(win32.STD_OUTPUT_HANDLE)
|
stdout := win32.GetStdHandle(win32.STD_OUTPUT_HANDLE)
|
||||||
if stdout != win32.INVALID_HANDLE && stdout != nil {
|
if stdout != win32.INVALID_HANDLE && stdout != nil {
|
||||||
old_console_mode: u32
|
if win32.GetConsoleMode(stdout, &old_stdout_mode) {
|
||||||
if win32.GetConsoleMode(stdout, &old_console_mode) {
|
win32.SetConsoleMode(stdout, old_stdout_mode | win32.ENABLE_VIRTUAL_TERMINAL_PROCESSING)
|
||||||
win32.SetConsoleMode(stdout, old_console_mode | win32.ENABLE_VIRTUAL_TERMINAL_PROCESSING)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stderr := win32.GetStdHandle(win32.STD_ERROR_HANDLE)
|
stderr := win32.GetStdHandle(win32.STD_ERROR_HANDLE)
|
||||||
if stderr != win32.INVALID_HANDLE && stderr != nil {
|
if stderr != win32.INVALID_HANDLE && stderr != nil {
|
||||||
old_console_mode: u32
|
if win32.GetConsoleMode(stderr, &old_stderr_mode) {
|
||||||
if win32.GetConsoleMode(stderr, &old_console_mode) {
|
win32.SetConsoleMode(stderr, old_stderr_mode | win32.ENABLE_VIRTUAL_TERMINAL_PROCESSING)
|
||||||
win32.SetConsoleMode(stderr, old_console_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)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user