1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! G29 regression test: ensures `terminal::init_console` is callable and the
//! windows-sys 0.59+ `HANDLE` type is used correctly.
//!
//! The test is compiled on ALL platforms but only exercises the Windows path
//! under `cfg(windows)`. On non-Windows, it is a no-op that confirms the
//! function is reachable from outside the crate (public re-export check).
use ;
/// `init_console` must be callable from any platform without panicking.
/// On non-Windows this is a no-op (UTF-8 + ANSI already supported natively);
/// on Windows it routes to `init_windows_console` which uses
/// `windows_sys::Win32::Foundation::{HANDLE, INVALID_HANDLE_VALUE}`.
/// `should_use_ansi` honours `NO_COLOR` and `CLICOLOR_FORCE` env vars.
///
/// We snapshot the current `NO_COLOR` value to restore after the test,
/// because the function reads it eagerly and our test must not pollute the
/// environment for downstream tests running in the same process.
/// On Windows, the `HANDLE` constant from `windows-sys 0.59+` is a
/// `*mut c_void` (not `isize` as in 0.48/0.52). The fix in `terminal.rs`
/// imports it via `use windows_sys::Win32::Foundation::{HANDLE, INVALID_HANDLE_VALUE}`
/// and uses `.is_null()` + `!= INVALID_HANDLE_VALUE` for type-safe comparison.
///
/// This test simply references the function to make sure the build is wired
/// up; if the type check regresses, `cargo check --target x86_64-pc-windows-msvc`
/// in CI will fail before this test is even reached.