Skip to content

Commit ed82bfb

Browse files
committed
test(terminal): execute requested PowerShell profile
1 parent f408613 commit ed82bfb

1 file changed

Lines changed: 26 additions & 6 deletions

File tree

src-tauri/tests/terminal_manager_tests.rs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,33 @@ fn windows_profiles_and_long_unicode_workspace_round_trip() {
291291
assert!(String::from_utf8_lossy(&output).contains("W6_CMD_OK"));
292292

293293
let manager = Arc::new(TerminalManager::default());
294-
manager.start(|_| {}, |_| {});
295-
let fallback = spawn_profile(&manager, base.path(), "pwsh-fallback", "pwsh");
296-
if fallback.shell_name != "pwsh" {
297-
assert_eq!(fallback.shell_name, "powershell");
298-
assert!(fallback.fallback_reason.is_some());
294+
let (events_tx, events_rx) = mpsc::channel();
295+
manager.start(move |event| events_tx.send(event).unwrap(), |_| {});
296+
let pwsh = spawn_profile(&manager, base.path(), "pwsh-profile", "pwsh");
297+
manager
298+
.write(
299+
&pwsh.terminal_id,
300+
&owner("pwsh-profile"),
301+
&with_terminal_handshake(shell_line(
302+
&pwsh.shell_name,
303+
"Write-Output \"W6_PWSH_MAJOR=$($PSVersionTable.PSVersion.Major)\"; Write-Output 'W6_PWSH_OK'; exit 0",
304+
"echo W6_PWSH_UNEXPECTED_CMD & exit 1",
305+
"printf 'W6_PWSH_UNEXPECTED_UNIX\\n'; exit 1",
306+
)),
307+
)
308+
.unwrap();
309+
let (output, exit) = collect_until_exit(&events_rx, Instant::now() + Duration::from_secs(10));
310+
assert_eq!(exit.exit_code, Some(0));
311+
let output = String::from_utf8_lossy(&output);
312+
assert!(output.contains("W6_PWSH_OK"));
313+
if pwsh.shell_name == "pwsh" {
314+
assert!(output.contains("W6_PWSH_MAJOR=7"));
315+
assert!(pwsh.fallback_reason.is_none());
316+
} else {
317+
assert_eq!(pwsh.shell_name, "powershell");
318+
assert!(output.contains("W6_PWSH_MAJOR=5"));
319+
assert!(pwsh.fallback_reason.is_some());
299320
}
300-
manager.shutdown();
301321
}
302322

303323
#[test]

0 commit comments

Comments
 (0)