fix: suppress console windows in headless mode
Browse files- Launcher: pass CREATE_NO_WINDOW | CREATE_SUSPENDED when creating
WA.exe in headless mode, plus SW_HIDE in STARTUPINFO
- Test runner: use CREATE_NO_WINDOW when spawning launcher
- run-tests.ps1: build test runner then run binary directly
Console/terminal windows no longer appear during headless tests.
WA's own "Loading" GUI dialog still flashes briefly (suppressing it
via ShowWindow hook causes WA to hang or throttle).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
crates/openwa-launcher/src/main.rs
CHANGED
|
@@ -52,6 +52,7 @@ struct PROCESS_INFORMATION {
|
|
| 52 |
}
|
| 53 |
|
| 54 |
const CREATE_SUSPENDED: DWORD = 0x0000_0004;
|
|
|
|
| 55 |
const STARTF_USESHOWWINDOW: DWORD = 0x0000_0001;
|
| 56 |
const SW_HIDE: u16 = 0;
|
| 57 |
const SW_SHOWMINIMIZED: u16 = 2;
|
|
@@ -160,9 +161,14 @@ unsafe fn launch(
|
|
| 160 |
let mut cmdline_buf: Vec<u8> = cmdline.bytes().chain(std::iter::once(0u8)).collect();
|
| 161 |
let wd_cstr = path_to_cstring(working_dir)?;
|
| 162 |
|
|
|
|
|
|
|
| 163 |
let mut si: STARTUPINFOA = mem::zeroed();
|
| 164 |
si.cb = mem::size_of::<STARTUPINFOA>() as DWORD;
|
| 165 |
-
if
|
|
|
|
|
|
|
|
|
|
| 166 |
si.dwFlags |= STARTF_USESHOWWINDOW;
|
| 167 |
si.wShowWindow = SW_SHOWMINIMIZED;
|
| 168 |
}
|
|
@@ -175,7 +181,7 @@ unsafe fn launch(
|
|
| 175 |
ptr::null_mut(),
|
| 176 |
ptr::null_mut(),
|
| 177 |
0, // bInheritHandles = FALSE
|
| 178 |
-
CREATE_SUSPENDED,
|
| 179 |
ptr::null_mut(), // inherit environment
|
| 180 |
wd_cstr.as_ptr().cast(),
|
| 181 |
&si,
|
|
|
|
| 52 |
}
|
| 53 |
|
| 54 |
const CREATE_SUSPENDED: DWORD = 0x0000_0004;
|
| 55 |
+
const CREATE_NO_WINDOW: DWORD = 0x0800_0000;
|
| 56 |
const STARTF_USESHOWWINDOW: DWORD = 0x0000_0001;
|
| 57 |
const SW_HIDE: u16 = 0;
|
| 58 |
const SW_SHOWMINIMIZED: u16 = 2;
|
|
|
|
| 161 |
let mut cmdline_buf: Vec<u8> = cmdline.bytes().chain(std::iter::once(0u8)).collect();
|
| 162 |
let wd_cstr = path_to_cstring(working_dir)?;
|
| 163 |
|
| 164 |
+
let headless = std::env::var("OPENWA_HEADLESS").is_ok();
|
| 165 |
+
|
| 166 |
let mut si: STARTUPINFOA = mem::zeroed();
|
| 167 |
si.cb = mem::size_of::<STARTUPINFOA>() as DWORD;
|
| 168 |
+
if headless {
|
| 169 |
+
si.dwFlags |= STARTF_USESHOWWINDOW;
|
| 170 |
+
si.wShowWindow = SW_HIDE;
|
| 171 |
+
} else if minimized {
|
| 172 |
si.dwFlags |= STARTF_USESHOWWINDOW;
|
| 173 |
si.wShowWindow = SW_SHOWMINIMIZED;
|
| 174 |
}
|
|
|
|
| 181 |
ptr::null_mut(),
|
| 182 |
ptr::null_mut(),
|
| 183 |
0, // bInheritHandles = FALSE
|
| 184 |
+
CREATE_SUSPENDED | if headless { CREATE_NO_WINDOW } else { 0 },
|
| 185 |
ptr::null_mut(), // inherit environment
|
| 186 |
wd_cstr.as_ptr().cast(),
|
| 187 |
&si,
|
crates/openwa-test-runner/src/main.rs
CHANGED
|
@@ -15,6 +15,7 @@ use std::thread;
|
|
| 15 |
use std::time::{Duration, Instant};
|
| 16 |
|
| 17 |
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
|
|
|
|
| 18 |
|
| 19 |
// βββ Configuration ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 20 |
|
|
|
|
| 15 |
use std::time::{Duration, Instant};
|
| 16 |
|
| 17 |
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
|
| 18 |
+
const DETACHED_PROCESS: u32 = 0x0000_0008;
|
| 19 |
|
| 20 |
// βββ Configuration ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 21 |
|
run-tests.ps1
CHANGED
|
@@ -5,4 +5,8 @@
|
|
| 5 |
# .\run-tests.ps1 longbow # only tests matching "longbow"
|
| 6 |
# .\run-tests.ps1 -j 1 # serial mode
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
# .\run-tests.ps1 longbow # only tests matching "longbow"
|
| 6 |
# .\run-tests.ps1 -j 1 # serial mode
|
| 7 |
|
| 8 |
+
# Build the test runner first to ensure it's up-to-date
|
| 9 |
+
cargo build -p openwa-test-runner --release
|
| 10 |
+
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
| 11 |
+
|
| 12 |
+
& "$PSScriptRoot\target\i686-pc-windows-msvc\release\openwa-test.exe" @args
|