Debian Codegraph @

src/lib.rs

raw symbols SCIP
1 mod pid;
2 pub use self::pid::*;
3 mod state;
4 pub use self::state::*;
5
6 #[cfg(unix)]
7 mod unix;
8 #[cfg(unix)]
9 pub use self::unix::*;
10
11 #[cfg(windows)]
12 mod windows;
13 #[cfg(windows)]
14 pub use self::windows::*;
15
16 #[cfg(test)]
17 mod tests {
18 use super::*;
19 use std::process::Command;
20
21 #[test]
22 fn test_alive() {
23 let mut child = Command::new("sleep").arg("5").spawn().unwrap();
24 let pid = child.id().into();
25 let state = state(pid);
26 child.kill().unwrap();
27 child.wait().unwrap();
28 assert_eq!(State::Alive, state);
29 }
30
31 #[test]
32 fn test_dead() {
33 let mut child = Command::new("sleep").arg("5").spawn().unwrap();
34 let pid = child.id().into();
35 child.kill().unwrap();
36 child.wait().unwrap();
37 let state = state(pid);
38 assert_eq!(State::Dead, state);
39 }
40 }