Files
javis_bot/app/tests/vdisplay_elevated.rs
javis-bot 9b53af169d fix(app): what is left of the virtual monitor's driver stays ours and can be removed from the screen
- a failed install forgets the driver (registry value, settings folder) only when its clean-up
  left no device and no package, and never when it was ours before; otherwise it stays ours and
  the error gives both the install's reason and that something is left to remove
- the driver status separates a usable monitor (installed) from what this app left without one
  (leftover) and names the button (action): uninstall for both, so a removal whose package step
  failed can be retried from the features screen
- pure rules after_failed_install and driver_status with unit tests; checked again on the win-ci
  VM: a declined install leaves nothing, then install and uninstall

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 03:00:54 +09:00

32 lines
1.6 KiB
Rust

//! Installing and removing the virtual monitor's driver through the app's elevated half
//! (admin.spec.md, "Virtual monitor"). Windows only, with the driver files in `display-driver/` next
//! to this program and `JARVIS_TEST_VDISPLAY=install` or `uninstall`, or `install-declined` (the
//! person answers no to Windows' question: the install fails and leaves nothing installed); Windows
//! asks for the administrator (and on install whether to trust the SignPath Foundation). Elsewhere
//! it skips.
//! No test harness: started elevated, this same program is the elevated half.
fn main() {
let args: Vec<String> = std::env::args().collect();
if let Some(code) = jarvis_app::vdisplay::elevated_main(&args) {
std::process::exit(code);
}
let Ok(action) = std::env::var("JARVIS_TEST_VDISPLAY") else {
eprintln!("skipped: set JARVIS_TEST_VDISPLAY=install|install-declined|uninstall");
return;
};
let rt = tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap();
let declined = action == "install-declined";
let outcome = rt.block_on(jarvis_app::vdisplay::run_elevated(if declined { "install" } else { &action }));
let status = jarvis_app::vdisplay::status();
println!("{action}: {outcome:?} -> {status:?}");
if declined {
assert!(outcome.is_err(), "a declined install fails");
} else {
outcome.expect("the elevated half succeeds");
}
assert_eq!(status.installed, action == "install");
assert!(!status.other, "nothing this app made looks like another program's driver");
assert!(!status.leftover, "nothing of this app's is left to clean up");
}