Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src-tauri/crates/terminal/src/pty_commands/pty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1080,6 +1080,30 @@ mod tests {
use super::{collect_sweep_sids, leader_is_sweep_candidate, pending_exit_session_leaders};
use std::collections::HashMap;

#[cfg(target_os = "linux")]
mod parse_tpgid_tests {
use super::super::parse_tpgid_from_stat;

#[test]
fn parses_standard_stat() {
// pid (comm) state ppid pgrp session tty_nr tpgid ...
let stat = "12345 (bash) S 1 12345 12345 34816 12400 4194304";
assert_eq!(parse_tpgid_from_stat(stat), Some(12400));
}

#[test]
fn parses_comm_with_spaces() {
let stat = "12345 (my shell) S 1 12345 12345 34816 99999 4194304";
assert_eq!(parse_tpgid_from_stat(stat), Some(99999));
}

#[test]
fn rejects_invalid_stat() {
assert_eq!(parse_tpgid_from_stat("garbage"), None);
assert_eq!(parse_tpgid_from_stat(""), None);
}
}

// The session-leader registry is a process-global static shared across
// tests; this helper drains it so each case starts from a known state.
fn reset_registry() {
Expand Down
28 changes: 0 additions & 28 deletions src-tauri/crates/terminal/src/pty_commands/tests/shells_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,31 +174,3 @@ fn test_shell_categories() {
assert_eq!(ShellKind::Python.category(), ShellCategory::Repl);
assert_eq!(ShellKind::Ruby.category(), ShellCategory::Repl);
}

// ============================================
// Linux-specific: parse_tpgid_from_stat
// ============================================

#[cfg(target_os = "linux")]
mod linux_tests {
use super::super::parse_tpgid_from_stat;

#[test]
fn test_parse_tpgid_standard() {
// pid (comm) state ppid pgrp session tty_nr tpgid ...
let stat = "12345 (bash) S 1 12345 12345 34816 12400 4194304";
assert_eq!(parse_tpgid_from_stat(stat), Some(12400));
}

#[test]
fn test_parse_tpgid_comm_with_spaces() {
let stat = "12345 (my shell) S 1 12345 12345 34816 99999 4194304";
assert_eq!(parse_tpgid_from_stat(stat), Some(99999));
}

#[test]
fn test_parse_tpgid_invalid() {
assert_eq!(parse_tpgid_from_stat("garbage"), None);
assert_eq!(parse_tpgid_from_stat(""), None);
}
}
Loading