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

This commit is contained in:
Michael Bolin
2026-04-02 16:12:19 -07:00
parent 0bd31dc382
commit fa49cae719
2 changed files with 40 additions and 31 deletions

View File

@@ -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

View File

@@ -385,23 +385,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.exe".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(),
],
)
};
@@ -436,13 +441,12 @@ exit 1
#[cfg(windows)]
let (command, args) = (
"powershell.exe".to_string(),
"cmd.exe".to_string(),
vec![
"-NoProfile".to_string(),
"-ExecutionPolicy".to_string(),
"Bypass".to_string(),
"-Command".to_string(),
"exit 1".to_string(),
"/d".to_string(),
"/s".to_string(),
"/c".to_string(),
"exit /b 1".to_string(),
],
);
@@ -457,8 +461,8 @@ exit 1
serde_json::from_value(json!({
"command": self.command,
"args": self.args,
// `powershell.exe` startup can be slow on loaded Windows CI workers, so leave enough
// slack to avoid turning these auth-cache assertions into a process-launch timing test.
// Process startup can be slow on loaded Windows CI workers, so leave enough slack to
// avoid turning these auth-cache assertions into a process-launch timing test.
"timeout_ms": 10_000,
"refresh_interval_ms": 60000,
"cwd": self.tempdir.path(),