Skip to content

Commit 7fb6787

Browse files
committed
Try problem test with escargot
1 parent 8e84cbe commit 7fb6787

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ procfs = "0.17"
3232
assert_cmd = "2.0.11"
3333
retry = "2.0.0"
3434
tokio = { version = "1", features = ["time", "rt", "macros"] }
35+
escargot = "0.5"
3536

3637
[features]
3738
default = ["proc"]

tests/lib_test.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use assert_cmd::cargo::CommandCargoExt;
22
use retry::delay::Fixed;
33
use retry::retry;
4-
use std::io::Write;
54
use std::process::Command;
65

76
struct DropChild(std::process::Child);
@@ -123,24 +122,17 @@ async fn port_query_with_async_retry() {
123122
fn proc_query_by_name() {
124123
use proc_ctl::ProcQuery;
125124

126-
let binder = Command::cargo_bin("waiter").unwrap();
127-
let mut handle = DropChild::spawn(binder);
125+
let _cmd = escargot::CargoBuild::new().bin("waiter").run().unwrap().command().spawn().unwrap();
128126

129127
let query = ProcQuery::new().process_name("waiter");
130128

131-
let processes = retry(Fixed::from_millis(100).take(1000), move || {
129+
let processes = retry(Fixed::from_millis(100).take(10), move || {
132130
match query.list_processes().ok() {
133131
Some(processes) if !processes.is_empty() => Ok(processes),
134132
_ => Err("No processes found"),
135133
}
136134
})
137-
.expect("Failed to find process in time");
138-
139-
if let Some(stdin) = handle.stdin.as_mut() {
140-
stdin.write_all(b"\r\n").unwrap();
141-
} else {
142-
handle.kill().unwrap();
143-
}
135+
.expect("Failed to find process in time");
144136

145137
assert_eq!(1, processes.len());
146138
}
@@ -166,7 +158,7 @@ fn proc_query_for_children() {
166158
.children()
167159
.map(|v| v.into_iter().map(|p| p.name).collect::<Vec<String>>())
168160
})
169-
.unwrap();
161+
.unwrap();
170162

171163
handle.kill().unwrap();
172164

0 commit comments

Comments
 (0)