test: use cmd.exe for provider auth scripts on Windows

This commit is contained in:
Michael Bolin
2026-04-02 16:12:20 -07:00
parent 0bd31dc382
commit fa49cae719
2 changed files with 40 additions and 31 deletions
@@ -142,23 +142,28 @@ mv tokens.next tokens.txt
#[cfg(windows)]
let (command, args) = {
let script_path = tempdir.path().join("print-token.ps1");
let script_path = tempdir.path().join("print-token.cmd");
std::fs::write(
&script_path,
r#"$lines = @(Get-Content -Path tokens.txt)
if ($lines.Count -eq 0) { exit 1 }
Write-Output $lines[0]
$lines | Select-Object -Skip 1 | Set-Content -Path tokens.txt
r#"@echo off
setlocal EnableExtensions DisableDelayedExpansion
set "first_line="
<tokens.txt set /p "first_line="
if not defined first_line exit /b 1
setlocal EnableDelayedExpansion
echo(!first_line!
endlocal
more +2 tokens.txt > tokens.next
move /y tokens.next tokens.txt >nul
"#,
)?;
(
"powershell".to_string(),
"cmd.exe".to_string(),
vec![
"-NoProfile".to_string(),
"-ExecutionPolicy".to_string(),
"Bypass".to_string(),
"-File".to_string(),
".\\print-token.ps1".to_string(),
"/d".to_string(),
"/s".to_string(),
"/c".to_string(),
".\\print-token.cmd".to_string(),
],
)
};
@@ -172,7 +177,7 @@ $lines | Select-Object -Skip 1 | Set-Content -Path tokens.txt
fn auth_config(&self) -> ModelProviderAuthInfo {
let timeout_ms = if cfg!(windows) {
// `powershell.exe` startup can be slow on loaded Windows CI workers
// Process startup can be slow on loaded Windows CI workers.
10_000
} else {
2_000