From 5dee40fcc0a18c148429aa1fbb3959bd2113a3c9 Mon Sep 17 00:00:00 2001 From: xxxigm Date: Sat, 6 Jun 2026 22:22:05 +0700 Subject: [PATCH] test(bootstrap-installer): cover PowerShell path layout cross-platform Make `powershell_under_root` visible under `cfg(test)` so the %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe layout is asserted on any host (the rest of the resolution is gated to Windows). --- .../src-tauri/src/powershell.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/apps/bootstrap-installer/src-tauri/src/powershell.rs b/apps/bootstrap-installer/src-tauri/src/powershell.rs index 3fc187c070b..f37a3c68b36 100644 --- a/apps/bootstrap-installer/src-tauri/src/powershell.rs +++ b/apps/bootstrap-installer/src-tauri/src/powershell.rs @@ -202,7 +202,9 @@ fn build_command(script_path: &Path, args: &[String]) -> Command { } /// Canonical PowerShell 5.1 location under a Windows root (`%SystemRoot%`). -#[cfg(target_os = "windows")] +/// Kept separate (and test-visible) so the path layout is unit-tested on any +/// host, not just Windows. +#[cfg(any(target_os = "windows", test))] fn powershell_under_root(root: &Path) -> std::path::PathBuf { root.join("System32") .join("WindowsPowerShell") @@ -342,4 +344,14 @@ info line let cwd = stable_script_cwd(script, Some("/")); assert_eq!(cwd, Some(Path::new("/"))); } + + #[test] + fn powershell_under_root_uses_system32_v1_layout() { + let resolved = powershell_under_root(Path::new("C:\\Windows")); + let normalized = resolved.to_string_lossy().replace('\\', "/"); + assert!( + normalized.ends_with("System32/WindowsPowerShell/v1.0/powershell.exe"), + "unexpected powershell path: {normalized}" + ); + } }